summaryrefslogtreecommitdiff
path: root/plugins/Ping/log.cpp
diff options
context:
space:
mode:
authorVadim Dashevskiy <watcherhd@gmail.com>2012-11-28 17:40:59 +0000
committerVadim Dashevskiy <watcherhd@gmail.com>2012-11-28 17:40:59 +0000
commit6e7708ae1760c85840f2e30e9af7221d2b149905 (patch)
tree05cb1aea34b3ecfd3b3729840766db1b722b7182 /plugins/Ping/log.cpp
parent5e9e63c45e37917ffb0acd83832d0d8f99d01883 (diff)
- Ping: folder rename
git-svn-id: http://svn.miranda-ng.org/main/trunk@2541 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Ping/log.cpp')
-rw-r--r--plugins/Ping/log.cpp59
1 files changed, 59 insertions, 0 deletions
diff --git a/plugins/Ping/log.cpp b/plugins/Ping/log.cpp
new file mode 100644
index 0000000000..de2889fde1
--- /dev/null
+++ b/plugins/Ping/log.cpp
@@ -0,0 +1,59 @@
+#include "common.h"
+#include "log.h"
+
+INT_PTR Log(WPARAM wParam, LPARAM lParam) {
+
+ TCHAR buf[1024], tbuf[512], dbuf[512];
+ CallService(PLUG "/GetLogFilename", (WPARAM)1024, (LPARAM)buf);
+
+ //char TBcapt[255];
+ SYSTEMTIME systime;
+
+ GetLocalTime(&systime);
+
+ GetTimeFormat(LOCALE_USER_DEFAULT, 0, &systime, 0, tbuf, 512);
+ GetDateFormat(LOCALE_USER_DEFAULT, 0, &systime, 0, dbuf, 512);
+
+ char *line = (char *)wParam;
+
+ FILE *f = _tfopen(buf, _T("a+"));
+ if(f) {
+ if(options.log_csv) {
+ fprintf(f, "%s, %s, %s\n", dbuf, tbuf, line);
+ } else {
+ fprintf(f, "%s, %s: %s\n", dbuf, tbuf, line);
+ }
+ fclose(f);
+ }
+
+ return 0;
+}
+
+INT_PTR GetLogFilename(WPARAM wParam, LPARAM lParam) {
+ DBVARIANT dbv;
+ char *filename = (char *)lParam;
+ if(DBGetContactSetting(0, PLUG, "LogFilename", &dbv)) {
+ CallService(MS_DB_GETPROFILEPATH, (WPARAM)wParam, (LPARAM)filename);
+ strcat(filename, "\\");
+ strcat(filename, "ping_log.txt");
+ } else {
+ strncpy(filename, dbv.pszVal, wParam);
+ DBFreeVariant(&dbv);
+ }
+
+ ((char *)lParam)[wParam - 1] = 0;
+
+ return 0;
+}
+
+INT_PTR SetLogFilename(WPARAM wParam, LPARAM lParam) {
+ DBWriteContactSettingString(0, PLUG, "LogFilename", (char *)lParam);
+ return 0;
+}
+
+INT_PTR ViewLogData(WPARAM wParam, LPARAM lParam) {
+ char buf[1024];
+ CallService(PLUG "/GetLogFilename", (WPARAM)MAX_PATH, (LPARAM)buf);
+ return (INT_PTR)ShellExecute((HWND)wParam, _T("edit"), buf, _T(""), _T(""), SW_SHOW);
+}
+