From 0922841b20da6c15076f1467280a0e67407826d1 Mon Sep 17 00:00:00 2001 From: Gluzskiy Alexandr Date: Sun, 31 Oct 2010 13:02:56 +0200 Subject: log rework better gpg configuration check removed annoying message boxes (info now out to log) --- commonheaders.h | 1 + globals.h | 4 +-- gpg_wrapper.cpp | 8 +++--- gpg_wrapper.h | 3 ++- init.cpp | 1 + jabber_account.h | 2 +- log.cpp | 1 + main.cpp | 76 ++++++++++++++------------------------------------------ messages.cpp | 49 +++++++++++++++--------------------- options.cpp | 21 ++++------------ utilities.cpp | 49 ++++++++++++++++-------------------- utilities.h | 1 + 12 files changed, 78 insertions(+), 138 deletions(-) diff --git a/commonheaders.h b/commonheaders.h index 57ba0af..990497b 100644 --- a/commonheaders.h +++ b/commonheaders.h @@ -47,6 +47,7 @@ using std::fstream; #include #include #include +#include //utf8cpp diff --git a/globals.h b/globals.h index 4b6533c..0aeac02 100644 --- a/globals.h +++ b/globals.h @@ -1,4 +1,4 @@ -// Copyright © 2010 sss, chaos.persei +// Copyright © 2010 sss // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License @@ -16,7 +16,7 @@ #ifndef GLOBALS_H #define GLOBALS_H -extern bool bAppendTags; +extern bool bAppendTags, gpg_configured; extern TCHAR *inopentag, *inclosetag, *outopentag, *outclosetag; extern logtofile debuglog; #endif diff --git a/gpg_wrapper.cpp b/gpg_wrapper.cpp index 04f3512..8ab32a3 100644 --- a/gpg_wrapper.cpp +++ b/gpg_wrapper.cpp @@ -24,6 +24,8 @@ boost::mutex gpg_mutex; pxResult pxExecute(wstring *acommandline, char *ainput, string *aoutput, LPDWORD aexitcode, pxResult *result) { gpg_mutex.lock(); + if(!gpg_configured) + return pxNotConfigured; extern logtofile debuglog; BOOL success; STARTUPINFO sinfo = {0}; @@ -97,7 +99,7 @@ pxResult pxExecute(wstring *acommandline, char *ainput, string *aoutput, LPDWORD delete [] home_dir; } - debuglog<<"gpg in: "<c_str()<<"\n"; + debuglog<c_str(); WaitForSingleObject(pri.hProcess,INFINITE); @@ -155,6 +157,6 @@ void pxEexcute_thread(void *param) pxResult result = pxExecute(params->cmd, params->useless, params->out, params->code, params->result); if(result == pxNotFound) { - MessageBox(0, _T("Set path to gpg.exe first!"), _T("Warning"), MB_OK); + debuglog< hcontact_data; diff --git a/jabber_account.h b/jabber_account.h index 3f2f6a9..490ea63 100644 --- a/jabber_account.h +++ b/jabber_account.h @@ -1,4 +1,4 @@ -// Copyright © 2010 sss, chaos.persei +// Copyright © 2010 sss // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License diff --git a/log.cpp b/log.cpp index d34b869..d2e360d 100644 --- a/log.cpp +++ b/log.cpp @@ -16,6 +16,7 @@ #include "commonheaders.h" + logtofile& logtofile::operator<<(TCHAR *buf) { extern bool bDebugLog; diff --git a/main.cpp b/main.cpp index ab3739d..197623f 100644 --- a/main.cpp +++ b/main.cpp @@ -93,14 +93,11 @@ static BOOL CALLBACK DlgProcFirstRun(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM if(!gpg_thread.timed_join(boost::posix_time::seconds(10))) { gpg_thread.~thread(); - MessageBox(0, _T("GPG execution timed out, aborted"), _T(""), MB_OK); + debuglog<timed_join(boost::posix_time::seconds(10))) { delete gpg_thread; - MessageBox(0, _T("GPG execution timed out, aborted"), _T(""), MB_OK); + debuglog<timed_join(boost::posix_time::seconds(10))) { delete gpg_thread; - MessageBox(0, _T("GPG execution timed out, aborted"), _T(""), MB_OK); + debuglog< 0) - debuglog<<"info: found password in database for key id: "< 0) - debuglog<<"info: found password for all keys in database, trying to decrypt message from "<<(TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR)<<" with password\n"; + debuglog< 0) { @@ -330,13 +327,13 @@ int RecvMsgSvc(WPARAM w, LPARAM l) } else if(password) { - debuglog<<"info: found password in memory, trying to decrypt message from "<<(TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR)<<" with password\n"; + debuglog<timed_join(boost::posix_time::seconds(10))) { delete gpg_thread; - MessageBox(0, _T("GPG execution timed out, aborted"), _T(""), MB_OK); + debuglog<timed_join(boost::posix_time::seconds(10))) { delete gpg_thread; - MessageBox(0, _T("GPG execution timed out, aborted"), _T(""), MB_OK); + debuglog<timed_join(boost::posix_time::seconds(10))) { delete gpg_thread; - MessageBox(0, _T("GPG execution timed out, aborted"), _T(""), MB_OK); + debuglog<szMessage; mir_free((void**)pre->szMessage); str.insert(0, "Received unencrypted message:\n"); - debuglog<<"info: Failed to decrypt GPG encrypted message.\n"; + debuglog<szMessage = tmp; @@ -482,7 +479,7 @@ int RecvMsgSvc(WPARAM w, LPARAM l) string str = pre->szMessage; mir_free((void**)pre->szMessage); str.insert(0, "Received unencrypted message:\n"); - debuglog<<"info: Failed to decrypt GPG encrypted message.\n"; + debuglog<szMessage = mir_strdup(str.c_str()); return CallService(MS_PROTO_CHAINRECV, w, (LPARAM)ccs); } @@ -653,14 +650,11 @@ int SendMsgSvc(WPARAM w, LPARAM l) if(!gpg_thread.timed_join(boost::posix_time::seconds(10))) { gpg_thread.~thread(); - MessageBox(0, _T("GPG execution timed out, aborted"), _T(""), MB_OK); + debuglog<timed_join(boost::posix_time::minutes(10))) { delete gpg_thread; - MessageBox(0, _T("GPG execution timed out, aborted"), _T(""), MB_OK); + debuglog<timed_join(boost::posix_time::minutes(10))) { delete gpg_thread; - MessageBox(0, _T("GPG execution timed out, aborted"), _T(""), MB_OK); - } - if(result == pxNotFound) - { - MessageBox(0, _T("Set path to gpg.exe first!"), _T("Warning"), MB_OK); + debuglog<