From 49b4d6dd9d4d35adc9f02df4010a1a6b33faba63 Mon Sep 17 00:00:00 2001 From: sje Date: Wed, 1 Nov 2006 14:44:34 +0000 Subject: git-svn-id: https://server.scottellis.com.au/svn/mim_plugs@12 4f64403b-2f21-0410-a795-97e2b3489a10 --- ping_protocol/log.cpp | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 ping_protocol/log.cpp (limited to 'ping_protocol/log.cpp') diff --git a/ping_protocol/log.cpp b/ping_protocol/log.cpp new file mode 100644 index 0000000..608db44 --- /dev/null +++ b/ping_protocol/log.cpp @@ -0,0 +1,58 @@ +#include "stdafx.h" +#include "log.h" + +int Log(WPARAM wParam, LPARAM lParam) { + + char buf[1024]; + CallService(PROTO "/GetLogFilename", (WPARAM)1024, (LPARAM)buf); + + char TBcapt[255]; + SYSTEMTIME systime; + + GetLocalTime(&systime); + + wsprintf(TBcapt,"%02d:%02d:%02d",systime.wHour,systime.wMinute,systime.wSecond); + + std::string timestring = TBcapt; + + std::string line = (char *)wParam; + + std::ofstream out(buf, std::ios_base::out | std::ios_base::app); + if(out.is_open()) { + out << timestring << ": " << line << std::endl; + out.close(); + } + + return 0; +} + +int GetLogFilename(WPARAM wParam, LPARAM lParam) { + DBVARIANT dbv; + std::string filename; + if(DBGetContactSetting(0, PROTO, "LogFilename", &dbv)) { + char buf[MAX_PATH]; + CallService(MS_DB_GETPROFILEPATH, (WPARAM)MAX_PATH, (LPARAM)buf); + filename = buf; + filename += "\\"; + filename += "ping_log.txt"; + } else { + filename = dbv.pszVal; + } + + strncpy((char *)lParam, filename.c_str(), (size_t)wParam); + + DBFreeVariant(&dbv); + return 0; +} + +int SetLogFilename(WPARAM wParam, LPARAM lParam) { + DBWriteContactSettingString(0, PROTO, "LogFilename", (char *)lParam); + return 0; +} + +int ViewLogData(WPARAM wParam, LPARAM lParam) { + char buf[1024]; + CallService(PROTO "/GetLogFilename", (WPARAM)MAX_PATH, (LPARAM)buf); + return (int)ShellExecute((HWND)wParam, "edit", buf, "", "", SW_SHOW); +} + -- cgit v1.2.3