summaryrefslogtreecommitdiff
path: root/plugins/New_GPG
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2020-03-18 14:00:04 +0300
committerGeorge Hazan <ghazan@miranda.im>2020-03-18 14:00:04 +0300
commit25d467883b6f659cd2a986ec9036d9182c9da973 (patch)
tree55e7754d714fbe69791751f7a5309581d416d4c9 /plugins/New_GPG
parentebfa7bb38008959e52a20fcd8a4330e07058dabf (diff)
NewGPG: logger optimization
Diffstat (limited to 'plugins/New_GPG')
-rwxr-xr-xplugins/New_GPG/src/gpg_wrapper.cpp12
-rwxr-xr-xplugins/New_GPG/src/log.cpp66
-rw-r--r--plugins/New_GPG/src/log.h17
-rwxr-xr-xplugins/New_GPG/src/messages.cpp70
-rwxr-xr-xplugins/New_GPG/src/options.cpp2
-rwxr-xr-xplugins/New_GPG/src/ui.cpp4
-rwxr-xr-xplugins/New_GPG/src/utilities.cpp40
-rwxr-xr-xplugins/New_GPG/src/utilities.h1
8 files changed, 82 insertions, 130 deletions
diff --git a/plugins/New_GPG/src/gpg_wrapper.cpp b/plugins/New_GPG/src/gpg_wrapper.cpp
index b590598e30..b31dca5475 100755
--- a/plugins/New_GPG/src/gpg_wrapper.cpp
+++ b/plugins/New_GPG/src/gpg_wrapper.cpp
@@ -26,7 +26,7 @@ void pxEexcute_thread(gpg_execution_params *params)
CMStringW bin_path(g_plugin.getMStringW("szGpgBinPath"));
if (_waccess(bin_path, 0)) {
if (globals.bDebugLog)
- globals.debuglog << std::string(time_str() + ": GPG executable not found");
+ globals.debuglog << "GPG executable not found";
params->result = pxNotFound;
return;
}
@@ -56,7 +56,7 @@ void pxEexcute_thread(gpg_execution_params *params)
}
args.erase(args.size() - 1, 1);
- globals.debuglog << std::string(time_str() + ": gpg in: " + toUTF8(args));
+ globals.debuglog << "gpg in: " << toUTF8(args);
}
params->out.Empty();
@@ -81,14 +81,14 @@ void pxEexcute_thread(gpg_execution_params *params)
params->out.Replace("\r\r", "");
if (globals.bDebugLog)
- globals.debuglog << std::string(time_str() + ": gpg out: " + params->out.c_str());
+ globals.debuglog << "gpg out: " << params->out.c_str();
params->code = c.exit_code();
params->child = nullptr;
if (params->code) {
if (globals.bDebugLog)
- globals.debuglog << std::string(time_str() + ": warning: wrong gpg exit status, gpg output: " + params->out.c_str());
+ globals.debuglog << ": warning: wrong gpg exit status, gpg output: " << params->out.c_str();
params->result = pxSuccessExitCodeInvalid;
}
else params->result = pxSuccess;
@@ -103,7 +103,7 @@ bool gpg_launcher(gpg_execution_params &params, boost::posix_time::time_duration
if (params.child)
params.child->terminate();
if (globals.bDebugLog)
- globals.debuglog << std::string(time_str() + ": GPG execution timed out, aborted");
+ globals.debuglog << "GPG execution timed out, aborted";
}
return ret;
}
@@ -120,7 +120,7 @@ void pxEexcute_passwd_change_thread(gpg_execution_params_pass *params)
CMStringW bin_path(g_plugin.getMStringW("szGpgBinPath"));
if (_waccess(bin_path, 0)) {
if (globals.bDebugLog)
- globals.debuglog << std::string(time_str() + ": GPG executable not found");
+ globals.debuglog << "GPG executable not found";
params->result = pxNotFound;
return;
}
diff --git a/plugins/New_GPG/src/log.cpp b/plugins/New_GPG/src/log.cpp
index 8f198c8561..feebd738e8 100755
--- a/plugins/New_GPG/src/log.cpp
+++ b/plugins/New_GPG/src/log.cpp
@@ -16,72 +16,38 @@
#include "stdafx.h"
-logtofile& logtofile::operator<<(wchar_t *buf)
+static string time_str()
{
- if (_bDebugLog != globals.bDebugLog)
- init();
-
- mir_cslock l(csLock);
- log.open(path, std::ios::app | std::ios::ate);
- log << buf;
- log << "\n";
- log.close();
- return *this;
-}
-
-logtofile& logtofile::operator<<(char *buf)
-{
- if (_bDebugLog != globals.bDebugLog)
- init();
-
- mir_cslock l(csLock);
- log.open(path, std::ios::app | std::ios::ate);
- log << buf;
- log << "\n";
- log.close();
- return *this;
+ boost::posix_time::ptime now = boost::posix_time::second_clock::local_time();
+ return (string)boost::posix_time::to_simple_string(now) + ": ";
}
-logtofile& logtofile::operator<<(string buf)
+logtofile &logtofile::operator<<(const char *buf)
{
- if (_bDebugLog != globals.bDebugLog)
+ if (bEnabled != globals.bDebugLog)
init();
- mir_cslock l(csLock);
- char *tmp = mir_utf8encode(buf.c_str());
- log.open(path, std::ios::app | std::ios::ate);
- log << tmp;
- log << "\n";
- log.close();
- mir_free(tmp);
+ mir_writeLogA(hLogger, "%s: %s\n", time_str().c_str(), buf);
return *this;
}
-logtofile& logtofile::operator<<(wstring buf)
+logtofile& logtofile::operator<<(const string &buf)
{
- if (_bDebugLog != globals.bDebugLog)
+ if (bEnabled != globals.bDebugLog)
init();
- mir_cslock l(csLock);
- log.open(path, std::ios::app | std::ios::ate);
- log << T2Utf(buf.c_str());
- log << "\n";
- log.close();
+ mir_writeLogA(hLogger, "%s: %s\n", time_str().c_str(), buf.c_str());
return *this;
}
void logtofile::init()
{
if (globals.bDebugLog)
- path = g_plugin.getMStringW("szLogFilePath", L"C:\\GPGdebug.log");
-
- _bDebugLog = globals.bDebugLog;
-}
-
-logtofile::logtofile()
-{
-}
-
-logtofile::~logtofile()
-{
+ hLogger = mir_createLog("NewGPG", L"NewGPG log file", g_plugin.getMStringW("szLogFilePath", L"C:\\GPGdebug.log"), 0);
+ else {
+ mir_closeLog(hLogger);
+ hLogger = nullptr;
+ }
+
+ bEnabled = globals.bDebugLog;
}
diff --git a/plugins/New_GPG/src/log.h b/plugins/New_GPG/src/log.h
index 56847943cc..e48d298bd6 100644
--- a/plugins/New_GPG/src/log.h
+++ b/plugins/New_GPG/src/log.h
@@ -18,20 +18,13 @@
class logtofile
{
+ HANDLE hLogger;
+ bool bEnabled = false;
+
public:
- logtofile& operator<<(wchar_t *buf);
- logtofile& operator<<(char *buf);
- logtofile& operator<<(string buf);
- logtofile& operator<<(wstring buf);
+ logtofile& operator<<(const char *buf);
+ logtofile& operator<<(const std::string &buf);
void init();
- ~logtofile();
- logtofile();
-
-private:
- fstream log;
- CMStringW path;
- bool _bDebugLog;
- mir_cs csLock;
};
#endif
diff --git a/plugins/New_GPG/src/messages.cpp b/plugins/New_GPG/src/messages.cpp
index 0dd3b471ae..81b0c94a58 100755
--- a/plugins/New_GPG/src/messages.cpp
+++ b/plugins/New_GPG/src/messages.cpp
@@ -46,7 +46,7 @@ static void RecvMsgSvc_func(RecvParams *param)
if (s2 != wstring::npos && s1 != wstring::npos) { //this is generic encrypted data block
if (!isContactSecured(hContact)) {
if (globals.bDebugLog)
- globals.debuglog << std::string(time_str() + ": info: received encrypted message from: " + toUTF8(Clist_GetContactDisplayName(hContact)) + " with turned off encryption");
+ globals.debuglog << "info: received encrypted message from: " + toUTF8(Clist_GetContactDisplayName(hContact)) + " with turned off encryption";
if (MessageBox(nullptr, TranslateT("We received encrypted message from contact with encryption turned off.\nDo you want to turn on encryption for this contact?"), TranslateT("Warning"), MB_YESNO) == IDYES) {
if (!isContactHaveKey(hContact))
ShowLoadPublicKeyDialog(hContact, true);
@@ -69,7 +69,7 @@ static void RecvMsgSvc_func(RecvParams *param)
}
}
else if (globals.bDebugLog)
- globals.debuglog << std::string(time_str() + ": info: received encrypted message from: " + toUTF8(Clist_GetContactDisplayName(hContact)));
+ globals.debuglog << "info: received encrypted message from: " + toUTF8(Clist_GetContactDisplayName(hContact));
boost::algorithm::erase_all(param->str, "\r");
s2 += mir_wstrlen(L"-----END PGP MESSAGE-----");
@@ -95,7 +95,7 @@ static void RecvMsgSvc_func(RecvParams *param)
g_plugin.setByte(hContact, "GPGEncryption", 0);
setSrmmIcon(hContact);
setClistIcon(hContact);
- globals.debuglog << std::string(time_str() + "info: failed to create temporary file for decryption, disabling gpg for contact to avoid deadlock");
+ globals.debuglog << "info: failed to create temporary file for decryption, disabling gpg for contact to avoid deadlock";
delete param;
return;
}
@@ -118,12 +118,12 @@ static void RecvMsgSvc_func(RecvParams *param)
dbsetting += "_Password";
pass = g_plugin.getMStringW(dbsetting.c_str());
if (!pass.IsEmpty() && globals.bDebugLog)
- globals.debuglog << std::string(time_str() + ": info: found password in database for key ID: " + inkeyid.c_str() + ", trying to decrypt message from " + toUTF8(Clist_GetContactDisplayName(hContact)) + " with password");
+ globals.debuglog << "info: found password in database for key ID: " + string(inkeyid.c_str()) + ", trying to decrypt message from " + toUTF8(Clist_GetContactDisplayName(hContact)) + " with password";
}
else {
pass = g_plugin.getMStringW("szKeyPassword");
if (!pass.IsEmpty() && globals.bDebugLog)
- globals.debuglog << std::string(time_str() + ": info: found password for all keys in database, trying to decrypt message from " + toUTF8(Clist_GetContactDisplayName(hContact)) + " with password");
+ globals.debuglog << "info: found password for all keys in database, trying to decrypt message from " + toUTF8(Clist_GetContactDisplayName(hContact)) + " with password";
}
if (!pass.IsEmpty()) {
params.addParam(L"--passphrase");
@@ -131,12 +131,12 @@ static void RecvMsgSvc_func(RecvParams *param)
}
else if (!globals.wszPassword.IsEmpty()) {
if (globals.bDebugLog)
- globals.debuglog << std::string(time_str() + ": info: found password in memory, trying to decrypt message from " + toUTF8(Clist_GetContactDisplayName(hContact)) + " with password");
+ globals.debuglog << "info: found password in memory, trying to decrypt message from " + toUTF8(Clist_GetContactDisplayName(hContact)) + " with password";
params.addParam(L"--passphrase");
params.addParam(globals.wszPassword.c_str());
}
else if (globals.bDebugLog)
- globals.debuglog << std::string(time_str() + ": info: passwords not found in database or memory, trying to decrypt message from " + toUTF8(Clist_GetContactDisplayName(hContact)) + " with out password");
+ globals.debuglog << "info: passwords not found in database or memory, trying to decrypt message from " + toUTF8(Clist_GetContactDisplayName(hContact)) + " with out password";
}
if (!globals.bDebugLog) {
@@ -181,7 +181,7 @@ static void RecvMsgSvc_func(RecvParams *param)
string out(params.out);
while (out.find("public key decryption failed: bad passphrase") != string::npos) {
if (globals.bDebugLog)
- globals.debuglog << std::string(time_str() + ": info: failed to decrypt messaage from " + toUTF8(Clist_GetContactDisplayName(hContact)) + " password needed, trying to get one");
+ globals.debuglog << "info: failed to decrypt messaage from " + toUTF8(Clist_GetContactDisplayName(hContact)) + " password needed, trying to get one";
if (globals._terminate) {
BYTE enc = g_plugin.getByte(hContact, "GPGEncryption", 0);
g_plugin.setByte(hContact, "GPGEncryption", 0);
@@ -204,7 +204,7 @@ static void RecvMsgSvc_func(RecvParams *param)
params2.aargv = params.aargv;
if (!globals.wszPassword.IsEmpty()) {
if (globals.bDebugLog)
- globals.debuglog << std::string(time_str() + ": info: found password in memory, trying to decrypt message from " + toUTF8(Clist_GetContactDisplayName(hContact)));
+ globals.debuglog << "info: found password in memory, trying to decrypt message from " + toUTF8(Clist_GetContactDisplayName(hContact));
params2.addParam(L"--passphrase");
params2.addParam(globals.wszPassword.c_str());
@@ -271,7 +271,7 @@ static void RecvMsgSvc_func(RecvParams *param)
string str1 = param->msg;
str1.insert(0, "Received unencrypted message:\n");
if (globals.bDebugLog)
- globals.debuglog << std::string(time_str() + ": info: Failed to decrypt GPG encrypted message.");
+ globals.debuglog << "info: Failed to decrypt GPG encrypted message.";
ptrA tmp4((char*)mir_alloc(sizeof(char)*(str1.length() + 1)));
mir_strcpy(tmp4, str1.c_str());
@@ -313,7 +313,7 @@ static void RecvMsgSvc_func(RecvParams *param)
string szMsg = param->msg;
szMsg.insert(0, "Failed to decrypt GPG encrypted message.\nMessage body for manual decryption:\n");
if (globals.bDebugLog)
- globals.debuglog << std::string(time_str() + ": info: Failed to decrypt GPG encrypted message.");
+ globals.debuglog << "info: Failed to decrypt GPG encrypted message.";
HistoryLog(hContact, db_event(param->msg, param->timestamp, 0, dbflags));
BYTE enc = g_plugin.getByte(hContact, "GPGEncryption", 0);
@@ -366,7 +366,7 @@ INT_PTR RecvMsgSvc(WPARAM w, LPARAM l)
return Proto_ChainRecv(w, ccs);
else {
if (globals.bDebugLog)
- globals.debuglog << std::string(time_str() + ": info: blocked pgp message to metacontact:" + toUTF8(Clist_GetContactDisplayName(ccs->hContact)));
+ globals.debuglog << "info: blocked pgp message to metacontact:" + toUTF8(Clist_GetContactDisplayName(ccs->hContact));
return 0;
}
}
@@ -374,12 +374,12 @@ INT_PTR RecvMsgSvc(WPARAM w, LPARAM l)
size_t s1, s2;
if (globals.bAutoExchange && (str.find(L"-----PGP KEY RESPONSE-----") != wstring::npos)) {
if (globals.bDebugLog)
- globals.debuglog << std::string(time_str() + ": info(autoexchange): parsing key response:" + toUTF8(Clist_GetContactDisplayName(ccs->hContact)));
+ globals.debuglog << "info(autoexchange): parsing key response:" + toUTF8(Clist_GetContactDisplayName(ccs->hContact));
s2 = str.find(L"-----END PGP PUBLIC KEY BLOCK-----");
s1 = str.find(L"-----BEGIN PGP PUBLIC KEY BLOCK-----");
if (s1 != wstring::npos && s2 != wstring::npos) {
if (globals.bDebugLog)
- globals.debuglog << std::string(time_str() + ": info(autoexchange): found pubkey block:" + toUTF8(Clist_GetContactDisplayName(ccs->hContact)));
+ globals.debuglog << "info(autoexchange): found pubkey block:" + toUTF8(Clist_GetContactDisplayName(ccs->hContact));
s2 += mir_wstrlen(L"-----END PGP PUBLIC KEY BLOCK-----");
g_plugin.setWString(ccs->hContact, "GPGPubKey", str.substr(s1, s2 - s1).c_str());
{
@@ -404,7 +404,7 @@ INT_PTR RecvMsgSvc(WPARAM w, LPARAM l)
g_plugin.setByte(ccs->hContact, "GPGEncryption", 0);
setSrmmIcon(ccs->hContact);
setClistIcon(ccs->hContact);
- globals.debuglog << std::string(time_str() + "info: failed to create temporary file for decryption, disabling gpg for contact to avoid deadlock");
+ globals.debuglog << "info: failed to create temporary file for decryption, disabling gpg for contact to avoid deadlock";
return 1;
}
f.open(tmp2, std::ios::out);
@@ -494,7 +494,7 @@ INT_PTR RecvMsgSvc(WPARAM w, LPARAM l)
}
if ((s2 != wstring::npos) && (s1 != wstring::npos)) { //this is public key
if (globals.bDebugLog)
- globals.debuglog << std::string(time_str() + ": info: received key from: " + toUTF8(Clist_GetContactDisplayName(ccs->hContact)));
+ globals.debuglog << "info: received key from: " + toUTF8(Clist_GetContactDisplayName(ccs->hContact));
s1 = 0;
while ((s1 = str.find(L"\r", s1)) != wstring::npos)
str.erase(s1, 1);
@@ -509,7 +509,7 @@ INT_PTR RecvMsgSvc(WPARAM w, LPARAM l)
}
if (globals.bAutoExchange && strstr(msg, "-----PGP KEY REQUEST-----") && globals.gpg_valid && globals.gpg_keyexist) {
if (globals.bDebugLog)
- globals.debuglog << std::string(time_str() + ": info(autoexchange): received key request from: " + toUTF8(Clist_GetContactDisplayName(ccs->hContact)));
+ globals.debuglog << "info(autoexchange): received key request from: " + toUTF8(Clist_GetContactDisplayName(ccs->hContact));
CMStringA tmp(g_plugin.getMStringA("GPGPubKey"));
if (!tmp.IsEmpty()) {
@@ -561,7 +561,7 @@ void SendMsgSvc_func(MCONTACT hContact, char *msg, DWORD flags)
wstring str = toUTF16(msg);
if (globals.bStripTags && globals.bAppendTags) {
if (globals.bDebugLog)
- globals.debuglog << std::string(time_str() + ": info: stripping tags in outgoing message, name: " + toUTF8(Clist_GetContactDisplayName(hContact)));
+ globals.debuglog << "info: stripping tags in outgoing message, name: " + toUTF8(Clist_GetContactDisplayName(hContact));
strip_tags(str);
}
@@ -609,7 +609,7 @@ void SendMsgSvc_func(MCONTACT hContact, char *msg, DWORD flags)
g_plugin.setByte(hContact, "GPGEncryption", 0); //disable encryption
setSrmmIcon(hContact);
setClistIcon(hContact);
- globals.debuglog << std::string(time_str() + ": info: failed to create temporary file for encryption, disabling encryption to avoid deadlock");
+ globals.debuglog << "info: failed to create temporary file for encryption, disabling encryption to avoid deadlock";
break;
}
f.open(path.c_str(), std::ios::out);
@@ -677,7 +677,7 @@ void SendMsgSvc_func(MCONTACT hContact, char *msg, DWORD flags)
g_plugin.setByte(hContact, "GPGEncryption", 0); //disable encryption
setSrmmIcon(hContact);
setClistIcon(hContact);
- globals.debuglog << std::string(time_str() + ": info: gpg failed to encrypt message, disabling encryption to avoid deadlock");
+ globals.debuglog << "info: gpg failed to encrypt message, disabling encryption to avoid deadlock";
break;
}
}
@@ -701,7 +701,7 @@ void SendMsgSvc_func(MCONTACT hContact, char *msg, DWORD flags)
if (str.empty()) {
HistoryLog(hContact, db_event("Failed to encrypt message with GPG", 0, 0, DBEF_SENT));
if (globals.bDebugLog)
- globals.debuglog << std::string(time_str() + ": info: Failed to encrypt message with GPG");
+ globals.debuglog << "info: Failed to encrypt message with GPG";
ProtoChainSend(hContact, PSS_MESSAGE, flags, (LPARAM)msg);
return;
}
@@ -713,7 +713,7 @@ void SendMsgSvc_func(MCONTACT hContact, char *msg, DWORD flags)
}
if (globals.bDebugLog)
- globals.debuglog << std::string(time_str() + ": adding event to contact: " + toUTF8(Clist_GetContactDisplayName(hContact)) + " on send message.");
+ globals.debuglog << "adding event to contact: " + toUTF8(Clist_GetContactDisplayName(hContact)) + " on send message.";
fix_line_term(str);
sent_msgs.push_back((HANDLE)ProtoChainSend(hContact, PSS_MESSAGE, flags, (LPARAM)toUTF8(str).c_str()));
@@ -731,25 +731,25 @@ INT_PTR SendMsgSvc(WPARAM w, LPARAM l)
char *msg = (char*)ccs->lParam;
if (!msg) {
if (globals.bDebugLog)
- globals.debuglog << std::string(time_str() + ": info: failed to get message data, name: " + toUTF8(Clist_GetContactDisplayName(ccs->hContact)));
+ globals.debuglog << "info: failed to get message data, name: " + toUTF8(Clist_GetContactDisplayName(ccs->hContact));
return Proto_ChainSend(w, ccs);
}
if (strstr(msg, "-----BEGIN PGP MESSAGE-----")) {
if (globals.bDebugLog)
- globals.debuglog << std::string(time_str() + ": info: encrypted message, let it go, name: " + toUTF8(Clist_GetContactDisplayName(ccs->hContact)));
+ globals.debuglog << "info: encrypted message, let it go, name: " + toUTF8(Clist_GetContactDisplayName(ccs->hContact));
return Proto_ChainSend(w, ccs);
}
if (globals.bDebugLog)
- globals.debuglog << std::string(time_str() + ": info: contact have key, name: " + toUTF8(Clist_GetContactDisplayName(ccs->hContact)));
+ globals.debuglog << "info: contact have key, name: " + toUTF8(Clist_GetContactDisplayName(ccs->hContact));
if (globals.bDebugLog && db_mc_isMeta(ccs->hContact))
- globals.debuglog << std::string(time_str() + ": info: protocol is metacontacts, name: " + toUTF8(Clist_GetContactDisplayName(ccs->hContact)));
+ globals.debuglog << "info: protocol is metacontacts, name: " + toUTF8(Clist_GetContactDisplayName(ccs->hContact));
if (!isContactSecured(ccs->hContact) || db_mc_isMeta(ccs->hContact)) {
if (globals.bDebugLog)
- globals.debuglog << std::string(time_str() + ": info: contact not secured, name: " + toUTF8(Clist_GetContactDisplayName(ccs->hContact)));
+ globals.debuglog << "info: contact not secured, name: " + toUTF8(Clist_GetContactDisplayName(ccs->hContact));
return Proto_ChainSend(w, ccs);
}
@@ -770,13 +770,13 @@ int HookSendMsg(WPARAM w, LPARAM l)
if (isContactSecured(hContact) && strstr((char*)dbei->pBlob, "-----BEGIN PGP MESSAGE-----")) //our service data, can be double added by metacontacts e.w.c.
{
if (globals.bDebugLog)
- globals.debuglog << std::string(time_str() + ": info(send handler): block pgp message event, name: " + toUTF8(Clist_GetContactDisplayName(hContact)));
+ globals.debuglog << "info(send handler): block pgp message event, name: " + toUTF8(Clist_GetContactDisplayName(hContact));
return 1;
}
if (globals.bAutoExchange && (strstr((char*)dbei->pBlob, "-----PGP KEY RESPONSE-----") || strstr((char*)dbei->pBlob, "-----PGP KEY REQUEST-----"))) ///do not show service data in history
{
if (globals.bDebugLog)
- globals.debuglog << std::string(time_str() + ": info(send handler): block pgp key request/response event, name: " + toUTF8(Clist_GetContactDisplayName(hContact)));
+ globals.debuglog << "info(send handler): block pgp key request/response event, name: " + toUTF8(Clist_GetContactDisplayName(hContact));
return 1;
}
}
@@ -786,16 +786,16 @@ int HookSendMsg(WPARAM w, LPARAM l)
if (!isContactHaveKey(hContact)) {
if (globals.bDebugLog)
- globals.debuglog << std::string(time_str() + ": info: contact have not key, name: " + toUTF8(Clist_GetContactDisplayName(hContact)));
+ globals.debuglog << "info: contact have not key, name: " + toUTF8(Clist_GetContactDisplayName(hContact));
if (globals.bAutoExchange && !strstr((char*)dbei->pBlob, "-----PGP KEY REQUEST-----") && !strstr((char*)dbei->pBlob, "-----BEGIN PGP PUBLIC KEY BLOCK-----") && globals.gpg_valid) {
if (globals.bDebugLog)
- globals.debuglog << std::string(time_str() + ": info: checking for autoexchange possibility, name: " + toUTF8(Clist_GetContactDisplayName(hContact)));
+ globals.debuglog << "info: checking for autoexchange possibility, name: " + toUTF8(Clist_GetContactDisplayName(hContact));
LPSTR proto = Proto_GetBaseAccountName(hContact);
ptrA jid(db_get_utfa(hContact, proto, "jid", ""));
if (jid[0]) {
if (globals.bDebugLog)
- globals.debuglog << std::string(time_str() + ": info(autoexchange): protocol looks like jabber, name: " + toUTF8(Clist_GetContactDisplayName(hContact)));
+ globals.debuglog << "info(autoexchange): protocol looks like jabber, name: " + toUTF8(Clist_GetContactDisplayName(hContact));
for (auto p : globals.Accounts) {
ptrA caps(p->getJabberInterface()->GetResourceFeatures(jid));
if (caps) {
@@ -809,7 +809,7 @@ int HookSendMsg(WPARAM w, LPARAM l)
if (str.find("GPG_Key_Auto_Exchange:0") != string::npos) {
if (globals.bDebugLog)
- globals.debuglog << std::string(time_str() + ": info(autoexchange, jabber): autoexchange capability found, sending key request, name: " + toUTF8(Clist_GetContactDisplayName(hContact)));
+ globals.debuglog << "info(autoexchange, jabber): autoexchange capability found, sending key request, name: " + toUTF8(Clist_GetContactDisplayName(hContact));
ProtoChainSend(hContact, PSS_MESSAGE, 0, (LPARAM)"-----PGP KEY REQUEST-----");
globals.hcontact_data[hContact].msgs_to_send.push_back((char*)dbei->pBlob);
mir_forkthread(send_encrypted_msgs_thread, (void*)hContact);
@@ -840,7 +840,7 @@ int HookSendMsg(WPARAM w, LPARAM l)
if (!isContactSecured(hContact)) {
if (globals.bDebugLog)
- globals.debuglog << std::string(time_str() + ": event message: \"" + (char*)dbei->pBlob + "\" passed event filter, contact " + toUTF8(Clist_GetContactDisplayName(hContact)) + " is unsecured");
+ globals.debuglog << "event message: \"" + string((char*)dbei->pBlob) + "\" passed event filter, contact " + toUTF8(Clist_GetContactDisplayName(hContact)) + " is unsecured";
return 0;
}
@@ -850,7 +850,7 @@ int HookSendMsg(WPARAM w, LPARAM l)
tmp[28] = '\0';
if (strstr(tmp, "-----BEGIN PGP MESSAGE-----")) {
if (globals.bDebugLog)
- globals.debuglog << std::string(time_str() + ": info(send handler): block pgp message event, name: " + toUTF8(Clist_GetContactDisplayName(hContact)));
+ globals.debuglog << "info(send handler): block pgp message event, name: " + toUTF8(Clist_GetContactDisplayName(hContact));
return 1;
}
}
diff --git a/plugins/New_GPG/src/options.cpp b/plugins/New_GPG/src/options.cpp
index 347c7ecbbc..c936e30c5a 100755
--- a/plugins/New_GPG/src/options.cpp
+++ b/plugins/New_GPG/src/options.cpp
@@ -951,7 +951,7 @@ public:
if (key_buf.empty()) {
key_buf.clear();
if (globals.bDebugLog)
- globals.debuglog << std::string(time_str() + ": info: Failed to read key file");
+ globals.debuglog << "info: Failed to read key file";
return;
}
ws2 = key_buf.find(L"-----END PGP PUBLIC KEY BLOCK-----");
diff --git a/plugins/New_GPG/src/ui.cpp b/plugins/New_GPG/src/ui.cpp
index 05f1675744..f3fcda137d 100755
--- a/plugins/New_GPG/src/ui.cpp
+++ b/plugins/New_GPG/src/ui.cpp
@@ -133,7 +133,7 @@ bool CDlgChangePasswdMsgBox::OnApply()
if (params.child)
params.child->terminate();
if (globals.bDebugLog)
- globals.debuglog << std::string(time_str() + ": GPG execution timed out, aborted");
+ globals.debuglog << "GPG execution timed out, aborted";
return true;
}
@@ -315,7 +315,7 @@ void CDlgFirstRun::onClick_CHANGE_PASSWD(CCtrlButton*)
if (params.child)
params.child->terminate();
if (globals.bDebugLog)
- globals.debuglog << std::string(time_str() + ": GPG execution timed out, aborted");
+ globals.debuglog << "GPG execution timed out, aborted";
this->Close();
}
}
diff --git a/plugins/New_GPG/src/utilities.cpp b/plugins/New_GPG/src/utilities.cpp
index d72e49b27c..63b1abc71c 100755
--- a/plugins/New_GPG/src/utilities.cpp
+++ b/plugins/New_GPG/src/utilities.cpp
@@ -265,12 +265,12 @@ int onProtoAck(WPARAM, LPARAM l)
dbsetting += "_Password";
pass = g_plugin.getMStringW(dbsetting.c_str());
if (!pass.IsEmpty() && globals.bDebugLog)
- globals.debuglog << std::string(time_str() + ": info: found password in database for key ID: " + keyid.c_str() + ", trying to decrypt message from " + toUTF8(Clist_GetContactDisplayName(ack->hContact)) + " with password");
+ globals.debuglog << "info: found password in database for key ID: " + string(keyid.c_str()) + ", trying to decrypt message from " + toUTF8(Clist_GetContactDisplayName(ack->hContact)) + " with password";
}
else {
pass = g_plugin.getMStringW("szKeyPassword");
if (!pass.IsEmpty() && globals.bDebugLog)
- globals.debuglog << std::string(time_str() + ": info: found password for all keys in database, trying to decrypt message from " + toUTF8(Clist_GetContactDisplayName(ack->hContact)) + " with password");
+ globals.debuglog << "info: found password for all keys in database, trying to decrypt message from " + toUTF8(Clist_GetContactDisplayName(ack->hContact)) + " with password";
}
if (!pass.IsEmpty()) {
params.addParam(L"--passphrase");
@@ -278,12 +278,12 @@ int onProtoAck(WPARAM, LPARAM l)
}
else if (!globals.wszPassword.IsEmpty()) {
if (globals.bDebugLog)
- globals.debuglog << std::string(time_str() + ": info: found password in memory, trying to decrypt message from " + toUTF8(Clist_GetContactDisplayName(ack->hContact)) + " with password");
+ globals.debuglog << "info: found password in memory, trying to decrypt message from " + toUTF8(Clist_GetContactDisplayName(ack->hContact)) + " with password";
params.addParam(L"--passphrase");
params.addParam(globals.wszPassword.c_str());
}
else if (globals.bDebugLog)
- globals.debuglog << std::string(time_str() + ": info: passwords not found in database or memory, trying to decrypt message from " + toUTF8(Clist_GetContactDisplayName(ack->hContact)) + " with out password");
+ globals.debuglog << "info: passwords not found in database or memory, trying to decrypt message from " + toUTF8(Clist_GetContactDisplayName(ack->hContact)) + " with out password";
}
params.addParam(L"-d");
params.addParam(filename);
@@ -293,7 +293,7 @@ int onProtoAck(WPARAM, LPARAM l)
string out(params.out);
while (out.find("public key decryption failed: bad passphrase") != string::npos) {
if (globals.bDebugLog)
- globals.debuglog << std::string(time_str() + ": info: failed to decrypt messaage from " + toUTF8(Clist_GetContactDisplayName(ack->hContact)) + " password needed, trying to get one");
+ globals.debuglog << "info: failed to decrypt messaage from " + toUTF8(Clist_GetContactDisplayName(ack->hContact)) + " password needed, trying to get one";
if (globals._terminate)
break;
{ //save inkey id
@@ -311,7 +311,7 @@ int onProtoAck(WPARAM, LPARAM l)
if (!globals.wszPassword.IsEmpty()) {
if (globals.bDebugLog)
- globals.debuglog << std::string(time_str() + ": info: found password in memory, trying to decrypt message from " + toUTF8(Clist_GetContactDisplayName(ack->hContact)));
+ globals.debuglog << "info: found password in memory, trying to decrypt message from " + toUTF8(Clist_GetContactDisplayName(ack->hContact));
params.addParam(L"--passphrase");
params.addParam(globals.wszPassword.c_str());
@@ -579,7 +579,7 @@ static JABBER_HANDLER_FUNC SendHandler(IJabberInterface *ji, TiXmlElement *node,
string data2 = data.substr(p1, p2 - p1 - 2);
strip_line_term(data2);
if (globals.bDebugLog)
- globals.debuglog << std::string(time_str() + ": jabber_api: attaching:\r\n\r\n" + data2 + "\n\n\t to outgoing xml");
+ globals.debuglog << "jabber_api: attaching:\r\n\r\n" + data2 + "\n\n\t to outgoing xml";
TiXmlElement *encrypted_data = pDoc->NewElement("x"); node->InsertEndChild(encrypted_data);
encrypted_data->SetText(data2.c_str());
@@ -598,7 +598,7 @@ static JABBER_HANDLER_FUNC SendHandler(IJabberInterface *ji, TiXmlElement *node,
f.close();
if (!boost::filesystem::exists(path_out)) {
if (globals.bDebugLog)
- globals.debuglog << std::string(time_str() + ": info: Failed to write prescense in file");
+ globals.debuglog << "info: Failed to write prescense in file";
break;
}
@@ -617,12 +617,12 @@ static JABBER_HANDLER_FUNC SendHandler(IJabberInterface *ji, TiXmlElement *node,
dbsetting += "_Password";
pass = g_plugin.getMStringW(dbsetting.c_str());
if (!pass.IsEmpty() && globals.bDebugLog)
- globals.debuglog << std::string(time_str() + ": info: found password in database for key ID: " + inkeyid.c_str() + ", trying to encrypt message from self with password");
+ globals.debuglog << "info: found password in database for key ID: " + string(inkeyid.c_str()) + ", trying to encrypt message from self with password";
}
else {
pass = g_plugin.getMStringW("szKeyPassword");
if (!pass.IsEmpty() && globals.bDebugLog)
- globals.debuglog << std::string(time_str() + ": info: found password for all keys in database, trying to encrypt message from self with password");
+ globals.debuglog << "info: found password for all keys in database, trying to encrypt message from self with password";
}
if (pass[0]) {
params.addParam(L"--passphrase");
@@ -630,12 +630,12 @@ static JABBER_HANDLER_FUNC SendHandler(IJabberInterface *ji, TiXmlElement *node,
}
else if (!globals.wszPassword.IsEmpty()) {
if (globals.bDebugLog)
- globals.debuglog << std::string(time_str() + ": info: found password in memory, trying to encrypt message from self with password");
+ globals.debuglog << "info: found password in memory, trying to encrypt message from self with password";
params.addParam(L"--passphrase");
params.addParam(globals.wszPassword.c_str());
}
else if (globals.bDebugLog)
- globals.debuglog << std::string(time_str() + ": info: passwords not found in database or memory, trying to encrypt message from self with out password");
+ globals.debuglog << "info: passwords not found in database or memory, trying to encrypt message from self with out password";
}
params.addParam(L"--local-user");
@@ -665,7 +665,7 @@ static JABBER_HANDLER_FUNC SendHandler(IJabberInterface *ji, TiXmlElement *node,
}
if (data.empty()) {
if (globals.bDebugLog)
- globals.debuglog << std::string(time_str() + ": info: Failed to read prescense sign from file");
+ globals.debuglog << "info: Failed to read prescense sign from file";
break;
}
if (data.find(L"-----BEGIN PGP SIGNATURE-----") != wstring::npos && data.find(L"-----END PGP SIGNATURE-----") != wstring::npos) {
@@ -760,7 +760,7 @@ static JABBER_HANDLER_FUNC PresenceHandler(IJabberInterface *ji, TiXmlElement* n
f.close();
if (!boost::filesystem::exists(path_out.c_str())) {
if (globals.bDebugLog)
- globals.debuglog << std::string(time_str() + ": info: Failed to write sign in file");
+ globals.debuglog << "info: Failed to write sign in file";
return FALSE;
}
{
@@ -829,19 +829,19 @@ bool isContactSecured(MCONTACT hContact)
BYTE gpg_enc = g_plugin.getByte(hContact, "GPGEncryption", 0);
if (!gpg_enc) {
if (globals.bDebugLog)
- globals.debuglog << std::string(time_str() + ": encryption is turned off for " + toUTF8(Clist_GetContactDisplayName(hContact)));
+ globals.debuglog << "encryption is turned off for " + toUTF8(Clist_GetContactDisplayName(hContact));
return false;
}
if (!db_mc_isMeta(hContact)) {
CMStringW key = g_plugin.getMStringW(hContact, "GPGPubKey");
if (key.IsEmpty()) {
if (globals.bDebugLog)
- globals.debuglog << std::string(time_str() + ": encryption is turned off for " + toUTF8(Clist_GetContactDisplayName(hContact)));
+ globals.debuglog << "encryption is turned off for " + toUTF8(Clist_GetContactDisplayName(hContact));
return false;
}
}
if (globals.bDebugLog)
- globals.debuglog << std::string(time_str() + ": encryption is turned on for " + toUTF8(Clist_GetContactDisplayName(hContact)));
+ globals.debuglog << "encryption is turned on for " + toUTF8(Clist_GetContactDisplayName(hContact));
return true;
}
@@ -1049,12 +1049,6 @@ void send_encrypted_msgs_thread(void *param)
}
}
-string time_str()
-{
- boost::posix_time::ptime now = boost::posix_time::second_clock::local_time();
- return (string)boost::posix_time::to_simple_string(now);
-}
-
int handleEnum(const char *szSetting, void *lParam)
{
if (!*(bool*)lParam && szSetting[0] && StriStr(szSetting, "tabsrmm")) {
diff --git a/plugins/New_GPG/src/utilities.h b/plugins/New_GPG/src/utilities.h
index 3cb8f20314..e2737b3da3 100755
--- a/plugins/New_GPG/src/utilities.h
+++ b/plugins/New_GPG/src/utilities.h
@@ -37,7 +37,6 @@ const bool StriStr(const char *str, const char *substr);
string toUTF8(wstring str);
wstring toUTF16(string str);
string get_random(int length);
-string time_str();
struct db_event : public DBEVENTINFO
{