diff options
Diffstat (limited to 'plugins/New_GPG/src')
-rwxr-xr-x | plugins/New_GPG/src/globals.h | 2 | ||||
-rwxr-xr-x | plugins/New_GPG/src/gpg_wrapper.cpp | 15 | ||||
-rwxr-xr-x | plugins/New_GPG/src/log.cpp | 78 | ||||
-rwxr-xr-x | plugins/New_GPG/src/log.h | 1 | ||||
-rwxr-xr-x | plugins/New_GPG/src/main.cpp | 142 | ||||
-rwxr-xr-x | plugins/New_GPG/src/messages.cpp | 183 | ||||
-rwxr-xr-x | plugins/New_GPG/src/options.cpp | 17 | ||||
-rwxr-xr-x | plugins/New_GPG/src/utilities.cpp | 97 |
8 files changed, 341 insertions, 194 deletions
diff --git a/plugins/New_GPG/src/globals.h b/plugins/New_GPG/src/globals.h index 4e561d8358..9942e16e96 100755 --- a/plugins/New_GPG/src/globals.h +++ b/plugins/New_GPG/src/globals.h @@ -16,7 +16,7 @@ #ifndef GLOBALS_H
#define GLOBALS_H
-extern bool bAppendTags, bPresenceSigning, bStripTags, gpg_valid, gpg_keyexist, tabsrmm_used, bSameAction, bFileTransfers;
+extern bool bAppendTags, bPresenceSigning, bStripTags, gpg_valid, gpg_keyexist, tabsrmm_used, bSameAction, bFileTransfers, bDebugLog;
extern TCHAR *inopentag, *inclosetag, *outopentag, *outclosetag;
extern logtofile debuglog;
#endif
diff --git a/plugins/New_GPG/src/gpg_wrapper.cpp b/plugins/New_GPG/src/gpg_wrapper.cpp index b2c65854cf..f253b2571e 100755 --- a/plugins/New_GPG/src/gpg_wrapper.cpp +++ b/plugins/New_GPG/src/gpg_wrapper.cpp @@ -80,7 +80,8 @@ pxResult pxExecute(wstring *acommandline, char *ainput, string *aoutput, LPDWORD if(errno == ENOENT) { mir_free(bin_path); - debuglog<<std::string(time_str()+": GPG executable not found"); + if(bDebugLog) + debuglog<<std::string(time_str()+": GPG executable not found"); *result = pxNotFound; return pxNotFound; } @@ -100,7 +101,8 @@ pxResult pxExecute(wstring *acommandline, char *ainput, string *aoutput, LPDWORD mir_free(home_dir); } - debuglog<<std::string(time_str()+": gpg in: "+toUTF8(commandline)); + if(bDebugLog) + debuglog<<std::string(time_str()+": gpg in: "+toUTF8(commandline)); success = CreateProcess(NULL, (TCHAR*)commandline.c_str(), NULL, NULL, TRUE, CREATE_NEW_CONSOLE | CREATE_UNICODE_ENVIRONMENT, (void*)_T("LANGUAGE=en@quot\0LC_ALL=English\0"), NULL, &sinfo, &pri); @@ -110,7 +112,8 @@ pxResult pxExecute(wstring *acommandline, char *ainput, string *aoutput, LPDWORD CloseHandle(writestdin); CloseHandle(newstdout); CloseHandle(readstdout); - debuglog<<time_str()<<": Failed to create process\n"; + if(bDebugLog) + debuglog<<time_str()<<": Failed to create process\n"; // gpg_mutex.unlock(); *result = pxCreateProcessFailed; return pxCreateProcessFailed; @@ -142,7 +145,8 @@ pxResult pxExecute(wstring *acommandline, char *ainput, string *aoutput, LPDWORD fix_line_term(*aoutput); - debuglog<<std::string(time_str()+": gpg out: "+*aoutput); + if(bDebugLog) + debuglog<<std::string(time_str()+": gpg out: "+*aoutput); WaitForSingleObject(pri.hProcess,INFINITE); @@ -157,7 +161,8 @@ pxResult pxExecute(wstring *acommandline, char *ainput, string *aoutput, LPDWORD // gpg_mutex.unlock(); if(*aexitcode) { - debuglog<<std::string(time_str()+": warning: wrong gpg exit status, gpg output: "+*aoutput); + if(bDebugLog) + debuglog<<std::string(time_str()+": warning: wrong gpg exit status, gpg output: "+*aoutput); return pxSuccessExitCodeInvalid; } return pxSuccess; diff --git a/plugins/New_GPG/src/log.cpp b/plugins/New_GPG/src/log.cpp index 273d37060d..29f80a1d5e 100755 --- a/plugins/New_GPG/src/log.cpp +++ b/plugins/New_GPG/src/log.cpp @@ -19,71 +19,63 @@ logtofile& logtofile::operator<<(TCHAR *buf)
{
- extern bool bDebugLog;
- if(bDebugLog)
- {
- log_mutex.lock();
- log.open(toUTF8(path).c_str(), std::ios::app |std::ios::ate);
- log<<toUTF8(buf);
- log<<"\n";
- log.close();
- log_mutex.unlock();
- }
+ if(_bDebugLog != bDebugLog)
+ init();
+ log_mutex.lock();
+ log.open(toUTF8(path).c_str(), std::ios::app |std::ios::ate);
+ log<<toUTF8(buf);
+ log<<"\n";
+ log.close();
+ log_mutex.unlock();
return *this;
}
logtofile& logtofile::operator<<(char *buf)
{
- extern bool bDebugLog;
- if(bDebugLog)
- {
- log_mutex.lock();
- log.open(toUTF8(path).c_str(), std::ios::app |std::ios::ate);
- log<<buf;
- log<<"\n";
- log.close();
- log_mutex.unlock();
- }
+ if(_bDebugLog != bDebugLog)
+ init();
+ log_mutex.lock();
+ log.open(toUTF8(path).c_str(), std::ios::app |std::ios::ate);
+ log<<buf;
+ log<<"\n";
+ log.close();
+ log_mutex.unlock();
return *this;
}
logtofile& logtofile::operator<<(string buf)
{
- extern bool bDebugLog;
- if(bDebugLog)
- {
- log_mutex.lock();
- char *tmp = mir_utf8encode(buf.c_str());
- log.open(toUTF8(path).c_str(), std::ios::app |std::ios::ate);
- log<<tmp;
- log<<"\n";
- log.close();
- log_mutex.unlock();
- mir_free(tmp);
- }
+ if(_bDebugLog != bDebugLog)
+ init();
+ log_mutex.lock();
+ char *tmp = mir_utf8encode(buf.c_str());
+ log.open(toUTF8(path).c_str(), std::ios::app |std::ios::ate);
+ log<<tmp;
+ log<<"\n";
+ log.close();
+ log_mutex.unlock();
+ mir_free(tmp);
return *this;
}
logtofile& logtofile::operator<<(wstring buf)
{
- extern bool bDebugLog;
- if(bDebugLog)
- {
- log_mutex.lock();
- log.open(toUTF8(path).c_str(), std::ios::app |std::ios::ate);
- log<<toUTF8(buf);
- log<<"\n";
- log.close();
- log_mutex.unlock();
- }
+ if(_bDebugLog != bDebugLog)
+ init();
+ log_mutex.lock();
+ log.open(toUTF8(path).c_str(), std::ios::app |std::ios::ate);
+ log<<toUTF8(buf);
+ log<<"\n";
+ log.close();
+ log_mutex.unlock();
return *this;
}
void logtofile::init()
{
- extern bool bDebugLog;
if(bDebugLog)
{
if(path)
mir_free(path);
path = UniGetContactSettingUtf(NULL, szGPGModuleName, "szLogFilePath", _T("C:\\GPGdebug.log"));
}
+ _bDebugLog = bDebugLog;
}
logtofile::logtofile()
{
diff --git a/plugins/New_GPG/src/log.h b/plugins/New_GPG/src/log.h index ed1950947c..9d1dcb39e6 100755 --- a/plugins/New_GPG/src/log.h +++ b/plugins/New_GPG/src/log.h @@ -30,6 +30,7 @@ private: fstream log; TCHAR *path; boost::mutex log_mutex; + bool _bDebugLog; }; #endif diff --git a/plugins/New_GPG/src/main.cpp b/plugins/New_GPG/src/main.cpp index f62c301de2..e4cb4aa3c9 100755 --- a/plugins/New_GPG/src/main.cpp +++ b/plugins/New_GPG/src/main.cpp @@ -109,7 +109,8 @@ static INT_PTR CALLBACK DlgProcFirstRun(HWND hwndDlg,UINT msg,WPARAM wParam,LPAR gpg_thread.~thread();
TerminateProcess(params.hProcess, 1);
params.hProcess = NULL;
- debuglog<<std::string(time_str()+": GPG execution timed out, aborted");
+ if(bDebugLog)
+ debuglog<<std::string(time_str()+": GPG execution timed out, aborted");
break;
}
if(result == pxNotFound)
@@ -313,7 +314,8 @@ static INT_PTR CALLBACK DlgProcFirstRun(HWND hwndDlg,UINT msg,WPARAM wParam,LPAR gpg_thread.~thread();
TerminateProcess(params.hProcess, 1);
params.hProcess = NULL;
- debuglog<<std::string(time_str()+": GPG execution timed out, aborted");
+ if(bDebugLog)
+ debuglog<<std::string(time_str()+": GPG execution timed out, aborted");
break;
}
if(result == pxNotFound)
@@ -405,7 +407,8 @@ static INT_PTR CALLBACK DlgProcFirstRun(HWND hwndDlg,UINT msg,WPARAM wParam,LPAR gpg_thread.~thread();
TerminateProcess(params.hProcess, 1);
params.hProcess = NULL;
- debuglog<<std::string(time_str()+": GPG execution timed out, aborted");
+ if(bDebugLog)
+ debuglog<<std::string(time_str()+": GPG execution timed out, aborted");
break;
}
if(result == pxNotFound)
@@ -478,7 +481,8 @@ static INT_PTR CALLBACK DlgProcFirstRun(HWND hwndDlg,UINT msg,WPARAM wParam,LPAR delete gpg_thread;
TerminateProcess(params.hProcess, 1);
params.hProcess = NULL;
- debuglog<<std::string(time_str()+": GPG execution timed out, aborted");
+ if(bDebugLog)
+ debuglog<<std::string(time_str()+": GPG execution timed out, aborted");
break;
}
if(result == pxNotFound)
@@ -507,7 +511,8 @@ static INT_PTR CALLBACK DlgProcFirstRun(HWND hwndDlg,UINT msg,WPARAM wParam,LPAR delete gpg_thread;
TerminateProcess(params.hProcess, 1);
params.hProcess = NULL;
- debuglog<<std::string(time_str()+": GPG execution timed out, aborted");
+ if(bDebugLog)
+ debuglog<<std::string(time_str()+": GPG execution timed out, aborted");
break;
}
if(result == pxNotFound)
@@ -609,7 +614,8 @@ static INT_PTR CALLBACK DlgProcFirstRun(HWND hwndDlg,UINT msg,WPARAM wParam,LPAR gpg_thread.~thread();
TerminateProcess(params.hProcess, 1);
params.hProcess = NULL;
- debuglog<<std::string(time_str()+": GPG execution timed out, aborted");
+ if(bDebugLog)
+ debuglog<<std::string(time_str()+": GPG execution timed out, aborted");
break;
}
if(result == pxNotFound)
@@ -641,7 +647,8 @@ static INT_PTR CALLBACK DlgProcFirstRun(HWND hwndDlg,UINT msg,WPARAM wParam,LPAR gpg_thread.~thread();
TerminateProcess(params.hProcess, 1);
params.hProcess = NULL;
- debuglog<<std::string(time_str()+"GPG execution timed out, aborted");
+ if(bDebugLog)
+ debuglog<<std::string(time_str()+"GPG execution timed out, aborted");
break;
}
if(result == pxNotFound)
@@ -824,7 +831,8 @@ static INT_PTR CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, gpg_thread.~thread();
TerminateProcess(params.hProcess, 1);
params.hProcess = NULL;
- debuglog<<std::string(time_str()+": GPG execution timed out, aborted");
+ if(bDebugLog)
+ debuglog<<std::string(time_str()+": GPG execution timed out, aborted");
}
gpg_valid = false;
DBDeleteContactSetting(NULL, szGPGModuleName, "szGpgBinPath");
@@ -944,7 +952,8 @@ static INT_PTR CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, TerminateProcess(params.hProcess, 1);
params.hProcess = NULL;
gpg_thread.~thread();
- debuglog<<std::string(time_str()+": GPG execution timed out, aborted");
+ if(bDebugLog)
+ debuglog<<std::string(time_str()+": GPG execution timed out, aborted");
}
gpg_valid = false;
DBDeleteContactSetting(NULL, szGPGModuleName, "szGpgBinPath");
@@ -1033,7 +1042,8 @@ static INT_PTR CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, TerminateProcess(params.hProcess, 1);
params.hProcess = NULL;
gpg_thread.~thread();
- debuglog<<std::string(time_str()+": GPG execution timed out, aborted");
+ if(bDebugLog)
+ debuglog<<std::string(time_str()+": GPG execution timed out, aborted");
}
gpg_valid = false;
DBDeleteContactSetting(NULL, szGPGModuleName, "szGpgBinPath");
@@ -1125,7 +1135,8 @@ static INT_PTR CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, gpg_thread.~thread();
TerminateProcess(params.hProcess, 1);
params.hProcess = NULL;
- debuglog<<std::string(time_str()+": GPG execution timed out, aborted");
+ if(bDebugLog)
+ debuglog<<std::string(time_str()+": GPG execution timed out, aborted");
gpg_valid = false;
break;
}
@@ -1159,7 +1170,8 @@ static INT_PTR CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, gpg_thread.~thread();
TerminateProcess(params.hProcess, 1);
params.hProcess = NULL;
- debuglog<<std::string(time_str()+"GPG execution timed out, aborted");
+ if(bDebugLog)
+ debuglog<<std::string(time_str()+"GPG execution timed out, aborted");
gpg_valid = false;
break;
}
@@ -1493,7 +1505,8 @@ static INT_PTR CALLBACK DlgProcKeyGenDialog(HWND hwndDlg, UINT msg, WPARAM wPara gpg_thread.~thread();
TerminateProcess(params.hProcess, 1);
params.hProcess = NULL;
- debuglog<<std::string(time_str()+": GPG execution timed out, aborted");
+ if(bDebugLog)
+ debuglog<<std::string(time_str()+": GPG execution timed out, aborted");
break;
}
if(result == pxNotFound)
@@ -1526,7 +1539,8 @@ static INT_PTR CALLBACK DlgProcKeyGenDialog(HWND hwndDlg, UINT msg, WPARAM wPara gpg_thread.~thread();
TerminateProcess(params.hProcess, 1);
params.hProcess = NULL;
- debuglog<<std::string(time_str()+": GPG execution timed out, aborted");
+ if(bDebugLog)
+ debuglog<<std::string(time_str()+": GPG execution timed out, aborted");
break;
}
if(result == pxNotFound)
@@ -1688,7 +1702,8 @@ static INT_PTR CALLBACK DlgProcLoadExistingKey(HWND hwndDlg,UINT msg,WPARAM wPar gpg_thread.~thread();
TerminateProcess(params.hProcess, 1);
params.hProcess = NULL;
- debuglog<<std::string(time_str()+": GPG execution timed out, aborted");
+ if(bDebugLog)
+ debuglog<<std::string(time_str()+": GPG execution timed out, aborted");
break;
}
if(result == pxNotFound)
@@ -1797,7 +1812,8 @@ static INT_PTR CALLBACK DlgProcLoadExistingKey(HWND hwndDlg,UINT msg,WPARAM wPar gpg_thread.~thread();
TerminateProcess(params.hProcess, 1);
params.hProcess = NULL;
- debuglog<<std::string(time_str()+": GPG execution timed out, aborted");
+ if(bDebugLog)
+ debuglog<<std::string(time_str()+": GPG execution timed out, aborted");
break;
}
if(result == pxNotFound)
@@ -1924,7 +1940,8 @@ static INT_PTR CALLBACK DlgProcImportKeyDialog(HWND hwndDlg, UINT msg, WPARAM wP gpg_thread.~thread();
TerminateProcess(params.hProcess, 1);
params.hProcess = NULL;
- debuglog<<std::string(time_str()+": GPG execution timed out, aborted");
+ if(bDebugLog)
+ debuglog<<std::string(time_str()+": GPG execution timed out, aborted");
}
MessageBoxA(0, out.c_str(), "GPG output", MB_OK);
}
@@ -2086,7 +2103,8 @@ void InitCheck() gpg_thread.~thread();
TerminateProcess(params.hProcess, 1);
params.hProcess = NULL;
- debuglog<<std::string(time_str()+": GPG execution timed out, aborted");
+ if(bDebugLog)
+ debuglog<<std::string(time_str()+": GPG execution timed out, aborted");
return;
}
if(result == pxNotFound)
@@ -2097,9 +2115,88 @@ void InitCheck() mir_free(home_dir);
tmp_dir += _T("\\tmp");
_wmkdir(tmp_dir.c_str());
- string question = Translate("Your secret key whith id: ");
- char *keyid = UniGetContactSettingUtf(NULL, szGPGModuleName, "KeyID", "");
- char *key = UniGetContactSettingUtf(NULL, szGPGModuleName, "GPGPubKey", "");
+ int count = 0;
+ PROTOACCOUNT **accounts;
+ ProtoEnumAccounts(&count, &accounts);
+ string question;
+ char *keyid, *key;
+ for(int i = 0; i < count; i++)
+ {
+ if(StriStr(accounts[i]->szModuleName, "metacontacts"))
+ continue;
+ if(StriStr(accounts[i]->szModuleName, "weather"))
+ continue;
+ std::string acc = toUTF8(accounts[i]->tszAccountName);
+ acc += "(";
+ acc += accounts[i]->szModuleName;
+ acc += ")";
+ acc += "_KeyID";
+ keyid = UniGetContactSettingUtf(NULL, szGPGModuleName, acc.c_str(), "");
+ if(keyid[0])
+ {
+ question = Translate("Your secret key whith id: ");
+ keyid = UniGetContactSettingUtf(NULL, szGPGModuleName, "KeyID", "");
+ key = UniGetContactSettingUtf(NULL, szGPGModuleName, "GPGPubKey", "");
+ void ShowFirstRunDialog();
+ if((p = out.find(keyid)) == string::npos)
+ {
+ question += keyid;
+ question += Translate(" for account ");
+ question += toUTF8(accounts[i]->tszAccountName);
+ question += Translate(" deleted from gpg secret keyring\nDo you want to set another key ?");
+ if(MessageBoxA(0, question.c_str(), Translate("Own secret key warning"), MB_YESNO) == IDYES)
+ ShowFirstRunDialog();
+ }
+ p2 = p;
+ p = out.find("[", p);
+ p2 = out.find("\n", p2);
+ if((p != std::string::npos) && (p < p2))
+ {
+ p = out.find("expires:", p);
+ p += strlen("expires:");
+ p++;
+ p2 = out.find("]", p);
+ TCHAR *expire_date = mir_wstrdup(toUTF16(out.substr(p,p2-p)).c_str());
+ bool expired = false;
+ {
+ boost::posix_time::ptime now = boost::posix_time::second_clock::local_time();
+ TCHAR buf[5];
+ mir_sntprintf(buf, 5, _T("%s"), expire_date);
+ int year = _ttoi(buf);
+ if(year < now.date().year())
+ expired = true;
+ else if(year == now.date().year())
+ {
+ mir_sntprintf(buf, 3, _T("%s"), expire_date+5);
+ int month = _ttoi(buf);
+ if(month < now.date().month())
+ expired = true;
+ else if(month == now.date().month())
+ {
+ mir_sntprintf(buf, 3, _T("%s"), expire_date+8);
+ int day = _ttoi(buf);
+ if(day <= now.date().day_number())
+ expired = true;
+ }
+ }
+ }
+ if(expired)
+ {
+ question += keyid;
+ question += Translate(" for account ");
+ question += toUTF8(accounts[i]->tszAccountName);
+ question += Translate(" expired and will not work\nDo you want to set another key ?");
+ if(MessageBoxA(0, question.c_str(), Translate("Own secret key warning"), MB_YESNO) == IDYES)
+ ShowFirstRunDialog();
+ }
+ mir_free(expire_date);
+ }
+ }
+ mir_free(keyid);
+ }
+ question = Translate("Your secret key whith id: ");
+ keyid = UniGetContactSettingUtf(NULL, szGPGModuleName, "KeyID", "");
+ key = UniGetContactSettingUtf(NULL, szGPGModuleName, "GPGPubKey", "");
void ShowFirstRunDialog();
if(!DBGetContactSettingByte(NULL, szGPGModuleName, "FirstRun", 1) && (!keyid[0] || !key[0]))
{
@@ -2263,7 +2360,8 @@ void ImportKey() gpg_thread.~thread();
TerminateProcess(params.hProcess, 1);
params.hProcess = NULL;
- debuglog<<std::string(time_str()+": GPG execution timed out, aborted");
+ if(bDebugLog)
+ debuglog<<std::string(time_str()+": GPG execution timed out, aborted");
return;
}
if(result == pxNotFound)
diff --git a/plugins/New_GPG/src/messages.cpp b/plugins/New_GPG/src/messages.cpp index 29fc06e816..d3525d2a3f 100755 --- a/plugins/New_GPG/src/messages.cpp +++ b/plugins/New_GPG/src/messages.cpp @@ -40,7 +40,8 @@ void RecvMsgSvc_func(HANDLE hContact, std::wstring str, char *msg, DWORD flags, bool isContactHaveKey(HANDLE hContact); if(!isContactSecured(hContact)) { - debuglog<<std::string(time_str()+": info: received encrypted message from: "+toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR))+" with turned off encryption"); + if(bDebugLog) + debuglog<<std::string(time_str()+": info: received encrypted message from: "+toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR))+" with turned off encryption"); if(MessageBox(0, TranslateT("We received encrypted message from contact with encryption turned off.\nDo you want turn on encryption for this contact ?"), TranslateT("Warning"), MB_YESNO) == IDYES) { if(!isContactHaveKey(hContact)) @@ -72,15 +73,11 @@ void RecvMsgSvc_func(HANDLE hContact, std::wstring str, char *msg, DWORD flags, return; } } - else + else if(bDebugLog) { debuglog<<std::string(time_str()+": info: received encrypted message from: "+toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR))); } - { - wstring::size_type p = 0; - while((p = str.find(_T("\r"), p)) != wstring::npos) - str.erase(p, 1); - } + boost::algorithm::erase_all(str, "\r"); s2 += _tcslen(_T("-----END PGP MESSAGE-----")); char *tmp = mir_t2a(str.substr(s1,s2-s1).c_str()); TCHAR *tmp2 = UniGetContactSettingUtf(NULL, szGPGModuleName, "szHomePath", _T("")); @@ -111,13 +108,13 @@ void RecvMsgSvc_func(HANDLE hContact, std::wstring str, char *msg, DWORD flags, dbsetting += inkeyid; dbsetting += "_Password"; pass = UniGetContactSettingUtf(NULL, szGPGModuleName, dbsetting.c_str(), _T("")); - if(pass[0]) + if(pass[0] && bDebugLog) debuglog<<std::string(time_str()+": info: found password in database for key id: "+inkeyid+", trying to decrypt message from "+toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR))+" with password"); } else { pass = UniGetContactSettingUtf(NULL, szGPGModuleName, "szKeyPassword", _T("")); - if(pass[0]) + if(pass[0] && bDebugLog) debuglog<<std::string(time_str()+": info: found password for all keys in database, trying to decrypt message from "+toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR))+" with password"); } if(pass && pass[0]) @@ -128,12 +125,13 @@ void RecvMsgSvc_func(HANDLE hContact, std::wstring str, char *msg, DWORD flags, } else if(password && password[0]) { - debuglog<<std::string(time_str()+": info: found password in memory, trying to decrypt message from "+toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR))+" with password"); + if(bDebugLog) + debuglog<<std::string(time_str()+": info: found password in memory, trying to decrypt message from "+toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR))+" with password"); cmd += _T("--passphrase \""); cmd += password; cmd += _T("\" "); } - else + else if (bDebugLog) debuglog<<std::string(time_str()+": info: passwords not found in database or memory, trying to decrypt message from "+toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR))+" with out password"); mir_free(pass); mir_free(inkeyid); @@ -165,7 +163,8 @@ void RecvMsgSvc_func(HANDLE hContact, std::wstring str, char *msg, DWORD flags, delete gpg_thread; TerminateProcess(params.hProcess, 1); params.hProcess = NULL; - debuglog<<std::string(time_str()+": GPG execution timed out, aborted"); + if(bDebugLog) + debuglog<<std::string(time_str()+": GPG execution timed out, aborted"); DeleteFile(path.c_str()); HistoryLog(hContact, db_event(msg, timestamp, 0, dbflags)); BYTE enc = DBGetContactSettingByte(hContact, szGPGModuleName, "GPGEncryption", 0); @@ -181,11 +180,20 @@ void RecvMsgSvc_func(HANDLE hContact, std::wstring str, char *msg, DWORD flags, HistoryLog(hContact, db_event(msg, timestamp, 0, dbflags)); return; } + if(result == pxSuccessExitCodeInvalid) + { + DeleteFile(path.c_str()); + HistoryLog(hContact, db_event(msg, timestamp, 0, dbflags)); + HistoryLog(hContact, db_event(Translate("failed to decrypt message, GPG returned error, turn on debug log for more details"), timestamp, 0, 0)); + return; + } + //TODO: check gpg output for errors _terminate = false; while(out.find("public key decryption failed: bad passphrase") != string::npos) { - debuglog<<std::string(time_str()+": info: failed to decrypt messaage from "+toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR))+" password needed, trying to get one"); + if(bDebugLog) + debuglog<<std::string(time_str()+": info: failed to decrypt messaage from "+toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR))+" password needed, trying to get one"); if(_terminate) { BYTE enc = DBGetContactSettingByte(hContact, szGPGModuleName, "GPGEncryption", 0); @@ -209,7 +217,8 @@ void RecvMsgSvc_func(HANDLE hContact, std::wstring str, char *msg, DWORD flags, wstring cmd2 = cmd; if(password) { - debuglog<<std::string(time_str()+": info: found password in memory, trying to decrypt message from "+toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR))); + if(bDebugLog) + debuglog<<std::string(time_str()+": info: found password in memory, trying to decrypt message from "+toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR))); wstring tmp = _T("--passphrase \""); tmp += password; tmp += _T("\" "); @@ -229,7 +238,8 @@ void RecvMsgSvc_func(HANDLE hContact, std::wstring str, char *msg, DWORD flags, delete gpg_thread; TerminateProcess(params.hProcess, 1); params.hProcess = NULL; - debuglog<<std::string(time_str()+": GPG execution timed out, aborted"); + if(bDebugLog) + debuglog<<std::string(time_str()+": GPG execution timed out, aborted"); DeleteFile(path.c_str()); HistoryLog(hContact, db_event(msg, timestamp, 0, dbflags)); BYTE enc = DBGetContactSettingByte(hContact, szGPGModuleName, "GPGEncryption", 0); @@ -253,7 +263,8 @@ void RecvMsgSvc_func(HANDLE hContact, std::wstring str, char *msg, DWORD flags, delete gpg_thread; TerminateProcess(params.hProcess, 1); params.hProcess = NULL; - debuglog<<std::string(time_str()+": GPG execution timed out, aborted"); + if(bDebugLog) + debuglog<<std::string(time_str()+": GPG execution timed out, aborted"); DeleteFile(path.c_str()); HistoryLog(hContact, db_event(msg, timestamp, 0, dbflags)); BYTE enc = DBGetContactSettingByte(hContact, szGPGModuleName, "GPGEncryption", 0); @@ -284,7 +295,8 @@ void RecvMsgSvc_func(HANDLE hContact, std::wstring str, char *msg, DWORD flags, { string str = msg; str.insert(0, "Received unencrypted message:\n"); - debuglog<<std::string(time_str()+": info: Failed to decrypt GPG encrypted message."); + if(bDebugLog) + debuglog<<std::string(time_str()+": info: Failed to decrypt GPG encrypted message."); char *tmp = new char [str.length()+1]; strcpy(tmp, str.c_str()); HistoryLog(hContact, db_event(msg, timestamp, 0, dbflags)); @@ -322,7 +334,8 @@ void RecvMsgSvc_func(HANDLE hContact, std::wstring str, char *msg, DWORD flags, { string str = msg; str.insert(0, "Failed to decrypt GPG encrypted message.\nMessage body for manual decryption:\n"); - debuglog<<std::string(time_str()+": info: Failed to decrypt GPG encrypted message."); + if(bDebugLog) + debuglog<<std::string(time_str()+": info: Failed to decrypt GPG encrypted message."); char *tmp = mir_strdup(str.c_str()); HistoryLog(hContact, db_event(msg, timestamp, 0, dbflags)); BYTE enc = DBGetContactSettingByte(hContact, szGPGModuleName, "GPGEncryption", 0); @@ -391,7 +404,8 @@ int RecvMsgSvc(WPARAM w, LPARAM l) return CallService(MS_PROTO_CHAINRECV, w, l); else { - debuglog<<std::string(time_str()+": info: blocked pgp message to metacontact:"+toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)ccs->hContact, GCDNF_TCHAR))); + if(bDebugLog) + debuglog<<std::string(time_str()+": info: blocked pgp message to metacontact:"+toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)ccs->hContact, GCDNF_TCHAR))); return 0; } } @@ -399,12 +413,14 @@ int RecvMsgSvc(WPARAM w, LPARAM l) wstring::size_type s1 = wstring::npos, s2 = wstring::npos; if(bAutoExchange && (str.find(_T("-----PGP KEY RESPONSE-----")) != wstring::npos)) { - debuglog<<std::string(time_str()+": info(autoexchange): parsing key response:"+toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)ccs->hContact, GCDNF_TCHAR))); + if(bDebugLog) + debuglog<<std::string(time_str()+": info(autoexchange): parsing key response:"+toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)ccs->hContact, GCDNF_TCHAR))); s2 = str.find(_T("-----END PGP PUBLIC KEY BLOCK-----")); s1 = str.find(_T("-----BEGIN PGP PUBLIC KEY BLOCK-----")); if(s1 != wstring::npos && s2 != wstring::npos) { - debuglog<<std::string(time_str()+": info(autoexchange): found pubkey block:"+toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)ccs->hContact, GCDNF_TCHAR))); + if(bDebugLog) + debuglog<<std::string(time_str()+": info(autoexchange): found pubkey block:"+toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)ccs->hContact, GCDNF_TCHAR))); s2 += _tcslen(_T("-----END PGP PUBLIC KEY BLOCK-----")); DBWriteContactSettingTString(ccs->hContact, szGPGModuleName, "GPGPubKey", str.substr(s1,s2-s1).c_str()); { //gpg execute block @@ -450,12 +466,18 @@ int RecvMsgSvc(WPARAM w, LPARAM l) gpg_thread.~thread(); TerminateProcess(params.hProcess, 1); params.hProcess = NULL; - debuglog<<std::string(time_str()+": GPG execution timed out, aborted"); + if(bDebugLog) + debuglog<<std::string(time_str()+": GPG execution timed out, aborted"); return 1; } + DeleteFile(tmp2); if(result == pxNotFound) return 1; - DeleteFile(tmp2); + if(result == pxSuccessExitCodeInvalid) + { + HistoryLog(ccs->hContact, db_event(Translate("failed to decrypt message, GPG returned error, turn on debug log for more details"))); + return 1; + } { char *tmp = NULL; string::size_type s = output.find("gpg: key ") + strlen("gpg: key "); @@ -532,7 +554,8 @@ int RecvMsgSvc(WPARAM w, LPARAM l) } if((s2 != wstring::npos) && (s1 != wstring::npos)) { //this is public key - debuglog<<std::string(time_str()+": info: received key from: "+toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)ccs->hContact, GCDNF_TCHAR))); + if(bDebugLog) + debuglog<<std::string(time_str()+": info: received key from: "+toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)ccs->hContact, GCDNF_TCHAR))); s1 = 0; while((s1 = str.find(_T("\r"), s1)) != wstring::npos) str.erase(s1, 1); @@ -554,7 +577,8 @@ int RecvMsgSvc(WPARAM w, LPARAM l) } if(bAutoExchange && strstr(msg, "-----PGP KEY REQUEST-----") && gpg_valid && gpg_keyexist) { - debuglog<<std::string(time_str()+": info(autoexchange): received key request from: "+toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)ccs->hContact, GCDNF_TCHAR))); + if(bDebugLog) + debuglog<<std::string(time_str()+": info(autoexchange): received key request from: "+toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)ccs->hContact, GCDNF_TCHAR))); char *tmp = UniGetContactSettingUtf(NULL, szGPGModuleName, "GPGPubKey", ""); if(tmp[0]) { @@ -631,25 +655,13 @@ void SendMsgSvc_func(HANDLE hContact, char *msg, DWORD flags) wstring str; bool isansi = false; DWORD dbflags = 0; - if(flags & PREF_UTF) + if((flags & PREF_UTF) == PREF_UTF) dbflags |= DBEF_UTF; - if(!metaIsSubcontact(hContact)) - str = toUTF16(msg); - else - {//workaround ... - debuglog<<std::string(time_str()+": info: using workaround for codepage with metacontacts, name: "+ toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR))); - wchar_t *tmp = mir_utf8decodeW(msg); - if(!tmp) - { - tmp = mir_a2t(msg); - isansi = true; - } - str.append(tmp); - mir_free(tmp); - } + str = toUTF16(msg); if(bStripTags && bAppendTags) { - debuglog<<std::string(time_str()+": info: stripping tags in outgoing message, name: "+toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR))); + if(bDebugLog) + debuglog<<std::string(time_str()+": info: stripping tags in outgoing message, name: "+toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR))); strip_tags(str); } /* for(std::wstring::size_type i = str.find(_T("\r\n")); i != std::wstring::npos; i = str.find(_T("\r\n"), i+1)) @@ -713,7 +725,8 @@ void SendMsgSvc_func(HANDLE hContact, char *msg, DWORD flags) gpg_thread.~thread(); TerminateProcess(params.hProcess, 1); params.hProcess = NULL; - debuglog<<std::string(time_str()+": GPG execution timed out, aborted"); + if(bDebugLog) + debuglog<<std::string(time_str()+": GPG execution timed out, aborted"); mir_free(msg); CallContactService(hContact, PSS_MESSAGE, (WPARAM)flags, (LPARAM)msg); return; @@ -724,7 +737,6 @@ void SendMsgSvc_func(HANDLE hContact, char *msg, DWORD flags) CallContactService(hContact, PSS_MESSAGE, (WPARAM)flags, (LPARAM)msg); return; } - //TODO: check gpg output for errors if(out.find("There is no assurance this key belongs to the named user") != string::npos) { out.clear(); @@ -745,7 +757,8 @@ void SendMsgSvc_func(HANDLE hContact, char *msg, DWORD flags) gpg_thread.~thread(); TerminateProcess(params.hProcess, 1); params.hProcess = NULL; - debuglog<<std::string(time_str()+": GPG execution timed out, aborted"); + if(bDebugLog) + debuglog<<std::string(time_str()+": GPG execution timed out, aborted"); mir_free(msg); CallContactService(hContact, PSS_MESSAGE, (WPARAM)flags, (LPARAM)msg); return; @@ -764,15 +777,21 @@ void SendMsgSvc_func(HANDLE hContact, char *msg, DWORD flags) return; } } + if(result == pxSuccessExitCodeInvalid) + { + mir_free(msg); + HistoryLog(hContact, db_event(Translate("failed o encrypt message, GPG returned error, turn on debug log for more details"), 0,0, DBEF_SENT)); + DeleteFile(path.c_str()); + return; + } if(out.find("usage: ") != string::npos) { MessageBox(0, TranslateT("Something wrong, gpg does not understand us, aborting encryption."), TranslateT("Warning"), MB_OK); - DeleteFile(path.c_str()); mir_free(msg); CallContactService(hContact, PSS_MESSAGE, (WPARAM)flags, (LPARAM)msg); + DeleteFile(path.c_str()); return; } - DeleteFile(path.c_str()); path.append(_T(".asc")); wfstream f(path.c_str(), std::ios::in | std::ios::ate | std::ios::binary); while(!f.is_open()) @@ -797,7 +816,8 @@ void SendMsgSvc_func(HANDLE hContact, char *msg, DWORD flags) { HistoryLog(hContact, db_event("Failed to encrypt message with GPG", 0,0, DBEF_SENT)); hcontact_data[hContact].msgs_to_pass.push_back("Failed to encrypt message with GPG"); - debuglog<<std::string(time_str()+": info: Failed to encrypt message with GPG"); + if(bDebugLog) + debuglog<<std::string(time_str()+": info: Failed to encrypt message with GPG"); mir_free(msg); CallContactService(hContact, PSS_MESSAGE, (WPARAM)flags, (LPARAM)msg); return; @@ -808,15 +828,19 @@ void SendMsgSvc_func(HANDLE hContact, char *msg, DWORD flags) str_event.insert(0, toUTF8(outopentag)); str_event.append(toUTF8(outclosetag)); } -/* if(metaIsSubcontact(hContact)) + /*if(metaIsSubcontact(hContact)) { hcontact_data[metaGetContact(hContact)].msgs_to_pass.push_back(str_event); - debuglog<<(TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR)<<"is subcontact of"<<(TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)metaGetContact(hContact), GCDNF_TCHAR)<<"\n"; - debuglog<<time_str()<<": adding event to metacontact: "<<(TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)metaGetContact(hContact), GCDNF_TCHAR)<<" on send message.\n"; + if(bDebugLog) + { + debuglog<<std::string(time_str() + toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR)) +"is subcontact of" + toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)metaGetContact(hContact), GCDNF_TCHAR))); + debuglog<<std::string(time_str()+": adding event to metacontact: "+toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)metaGetContact(hContact), GCDNF_TCHAR))+" on send message."); + } HistoryLog(metaGetContact(hContact), db_event((char*)str_event.c_str(), 0,0, DBEF_SENT|dbflags)); - } */ //unneeded ? + }*/ //unneeded ? hcontact_data[hContact].msgs_to_pass.push_back(str_event); - debuglog<<std::string(time_str()+": adding event to contact: "+toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR))+" on send message."); + if(bDebugLog) + debuglog<<std::string(time_str()+": adding event to contact: "+toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR))+" on send message."); HistoryLog(hContact, db_event((char*)str_event.c_str(), 0,0, dbflags|DBEF_SENT)); if(!(flags & PREF_UTF)) flags |= PREF_UTF; @@ -831,30 +855,39 @@ int SendMsgSvc(WPARAM w, LPARAM l) CCSDATA *ccs = (CCSDATA*)l; if (!ccs) return CallService(MS_PROTO_CHAINSEND, w, l); - char *msg = mir_strdup((char*)(ccs->lParam)); + char *msg = nullptr; + if((ccs->wParam & PREF_UTF) == PREF_UTF) + msg = mir_strdup((char*)(ccs->lParam)); + else + msg = mir_utf8encode((char*)(ccs->lParam)); if (!msg) { - debuglog<<std::string(time_str()+": info: failed to get message data, name: "+toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)ccs->hContact, GCDNF_TCHAR))); + if(bDebugLog) + debuglog<<std::string(time_str()+": info: failed to get message data, name: "+toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)ccs->hContact, GCDNF_TCHAR))); mir_free(msg); return CallService(MS_PROTO_CHAINSEND, w, l); } if(strstr(msg,"-----BEGIN PGP MESSAGE-----")) { - debuglog<<std::string(time_str()+": info: encrypted messge, let it go, name: "+toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)ccs->hContact, GCDNF_TCHAR))); + if(bDebugLog) + debuglog<<std::string(time_str()+": info: encrypted messge, let it go, name: "+toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)ccs->hContact, GCDNF_TCHAR))); return CallService(MS_PROTO_CHAINSEND, w, l); } if(!isContactHaveKey(ccs->hContact)) { - debuglog<<std::string(time_str()+": info: contact have not key, name: "+toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)ccs->hContact, GCDNF_TCHAR))); + if(bDebugLog) + debuglog<<std::string(time_str()+": info: contact have not key, name: "+toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)ccs->hContact, GCDNF_TCHAR))); if(bAutoExchange && !strstr(msg, "-----PGP KEY REQUEST-----") && !strstr(msg, "-----BEGIN PGP PUBLIC KEY BLOCK-----") && gpg_valid) { - debuglog<<std::string(time_str()+": info: checking for autoexchange possibility, name: "+toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)ccs->hContact, GCDNF_TCHAR))); + if(bDebugLog) + debuglog<<std::string(time_str()+": info: checking for autoexchange possibility, name: "+toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)ccs->hContact, GCDNF_TCHAR))); void send_encrypted_msgs_thread(HANDLE hContact); LPSTR proto = GetContactProto(ccs->hContact); DWORD uin = DBGetContactSettingDword(ccs->hContact, proto, "UIN", 0); if(uin) { - debuglog<<std::string(time_str()+": info(autoexchange): protocol looks like icq, name: "+toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)ccs->hContact, GCDNF_TCHAR))); + if(bDebugLog) + debuglog<<std::string(time_str()+": info(autoexchange): protocol looks like icq, name: "+toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)ccs->hContact, GCDNF_TCHAR))); char *proto = GetContactProto(ccs->hContact); char svc[64]; strcpy(svc, proto); @@ -862,12 +895,14 @@ int SendMsgSvc(WPARAM w, LPARAM l) if(ServiceExists(svc)) { - debuglog<<std::string(time_str()+": info(autoexchange, icq): checking for autoexchange icq capability, name: "+toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)ccs->hContact, GCDNF_TCHAR))); + if(bDebugLog) + debuglog<<std::string(time_str()+": info(autoexchange, icq): checking for autoexchange icq capability, name: "+toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)ccs->hContact, GCDNF_TCHAR))); ICQ_CUSTOMCAP cap = {0}; strcpy(cap.caps, "GPG AutoExchange"); if(CallService(svc, (WPARAM)ccs->hContact, (LPARAM)&cap)) { - debuglog<<std::string(time_str()+": info(autoexchange, icq): sending key requiest, name: "+toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)ccs->hContact, GCDNF_TCHAR))); + if(bDebugLog) + debuglog<<std::string(time_str()+": info(autoexchange, icq): sending key requiest, name: "+toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)ccs->hContact, GCDNF_TCHAR))); CallContactService(ccs->hContact, PSS_MESSAGE, (WPARAM)ccs->wParam, (LPARAM)"-----PGP KEY REQUEST-----"); hcontact_data[ccs->hContact].msgs_to_send.push_back(msg); boost::thread *thr = new boost::thread(boost::bind(send_encrypted_msgs_thread, ccs->hContact)); @@ -881,7 +916,8 @@ int SendMsgSvc(WPARAM w, LPARAM l) TCHAR *jid = UniGetContactSettingUtf(ccs->hContact, proto, "jid", _T("")); if(jid[0]) { - debuglog<<std::string(time_str()+": info(autoexchange): protocol looks like jabber, name: "+toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)ccs->hContact, GCDNF_TCHAR))); + if(bDebugLog) + debuglog<<std::string(time_str()+": info(autoexchange): protocol looks like jabber, name: "+toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)ccs->hContact, GCDNF_TCHAR))); extern list <JabberAccount*> Accounts; list<JabberAccount*>::iterator end = Accounts.end(); for(list<JabberAccount*>::iterator p = Accounts.begin(); p != end; p++) @@ -900,7 +936,8 @@ int SendMsgSvc(WPARAM w, LPARAM l) mir_free(caps); if(str.find(_T("GPG_Key_Auto_Exchange:0")) != string::npos) { - debuglog<<std::string(time_str()+": info(autoexchange, jabber): autoexchange capability found, sending key request, name: "+toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)ccs->hContact, GCDNF_TCHAR))); + if(bDebugLog) + debuglog<<std::string(time_str()+": info(autoexchange, jabber): autoexchange capability found, sending key request, name: "+toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)ccs->hContact, GCDNF_TCHAR))); CallContactService(ccs->hContact, PSS_MESSAGE, (WPARAM)ccs->wParam, (LPARAM)"-----PGP KEY REQUEST-----"); hcontact_data[ccs->hContact].msgs_to_send.push_back(msg); boost::thread *thr = new boost::thread(boost::bind(send_encrypted_msgs_thread, ccs->hContact)); @@ -918,13 +955,14 @@ int SendMsgSvc(WPARAM w, LPARAM l) return CallService(MS_PROTO_CHAINSEND, w, l); } } - else + else if(bDebugLog) debuglog<<std::string(time_str()+": info: contact have key, name: "+toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)ccs->hContact, GCDNF_TCHAR))); - if(metaIsProtoMetaContacts(ccs->hContact)) + if(bDebugLog && metaIsProtoMetaContacts(ccs->hContact)) debuglog<<std::string(time_str()+": info: protocol is metacontacts, name: "+toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)ccs->hContact, GCDNF_TCHAR))); if(!isContactSecured(ccs->hContact) || metaIsProtoMetaContacts(ccs->hContact)) { - debuglog<<std::string(time_str()+": info: contact not secured, name: "+toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)ccs->hContact, GCDNF_TCHAR))); + if(bDebugLog) + debuglog<<std::string(time_str()+": info: contact not secured, name: "+toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)ccs->hContact, GCDNF_TCHAR))); mir_free(msg); return CallService(MS_PROTO_CHAINSEND, w, l); } @@ -946,12 +984,14 @@ 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.t.c. { - debuglog<<std::string(time_str()+": info(send handler): block pgp message event, name: "+toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR))); + if(bDebugLog) + debuglog<<std::string(time_str()+": info(send handler): block pgp message event, name: "+toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR))); return 1; } if(bAutoExchange && (strstr((char*)dbei->pBlob, "-----PGP KEY RESPONSE-----") || strstr((char*)dbei->pBlob, "-----PGP KEY REQUEST-----"))) ///do not show service data in history { - debuglog<<std::string(time_str()+": info(send handler): block pgp key request/response event, name: "+toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR))); + if(bDebugLog) + debuglog<<std::string(time_str()+": info(send handler): block pgp key request/response event, name: "+toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR))); return 1; } } @@ -966,7 +1006,8 @@ int HookSendMsg(WPARAM w, LPARAM l) if(!strcmp((*i).c_str(), (char*)dbei->pBlob)) { hcontact_data[hContact].msgs_to_pass.erase(i); - debuglog<<std::string(time_str()+": event message: \""+(char*)dbei->pBlob+"\" passed event filter, contact "+toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR))+", message is in allowed list"); + if(bDebugLog) + debuglog<<std::string(time_str()+": event message: \""+(char*)dbei->pBlob+"\" passed event filter, contact "+toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR))+", message is in allowed list"); event_processing_mutex.unlock(); return 0; } @@ -979,7 +1020,8 @@ int HookSendMsg(WPARAM w, LPARAM l) } if(!isContactSecured(hContact)) { - debuglog<<std::string(time_str()+": event message: \""+(char*)dbei->pBlob+"\" passed event filter, contact "+toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR))+" is unsecured"); + if(bDebugLog) + debuglog<<std::string(time_str()+": event message: \""+(char*)dbei->pBlob+"\" passed event filter, contact "+toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR))+" is unsecured"); return 0; } if(!(dbei->flags & DBEF_SENT) && metaIsProtoMetaContacts((HANDLE)w)) @@ -989,7 +1031,8 @@ int HookSendMsg(WPARAM w, LPARAM l) tmp[28] = '\0'; if(strstr(tmp, "-----BEGIN PGP MESSAGE-----")) { - debuglog<<std::string(time_str()+": info(send handler): block pgp message event, name: "+toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR))); + if(bDebugLog) + debuglog<<std::string(time_str()+": info(send handler): block pgp message event, name: "+toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR))); return 1; } } diff --git a/plugins/New_GPG/src/options.cpp b/plugins/New_GPG/src/options.cpp index 9d4e1da893..6b26457864 100755 --- a/plugins/New_GPG/src/options.cpp +++ b/plugins/New_GPG/src/options.cpp @@ -278,7 +278,8 @@ static INT_PTR CALLBACK DlgProcGpgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP gpg_thread.~thread(); TerminateProcess(params.hProcess, 1); params.hProcess = NULL; - debuglog<<std::string(time_str()+": GPG execution timed out, aborted"); + if(bDebugLog) + debuglog<<std::string(time_str()+": GPG execution timed out, aborted"); mir_free(tmp); break; } @@ -458,7 +459,7 @@ static INT_PTR CALLBACK DlgProcGpgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP case PSN_APPLY: { - extern bool bDebugLog, bJabberAPI, bFileTransfers; + extern bool bJabberAPI, bFileTransfers; bDebugLog = CheckStateStoreDB(hwndDlg, IDC_DEBUG_LOG, "bDebugLog"); if(bDebugLog) debuglog.init(); @@ -843,7 +844,8 @@ static INT_PTR CALLBACK DlgProcLoadPublicKey(HWND hwndDlg,UINT msg,WPARAM wParam gpg_thread.~thread(); TerminateProcess(params.hProcess, 1); params.hProcess = NULL; - debuglog<<std::string(time_str()+": GPG execution timed out, aborted"); + if(bDebugLog) + debuglog<<std::string(time_str()+": GPG execution timed out, aborted"); } if((out.find("-----BEGIN PGP PUBLIC KEY BLOCK-----") != string::npos) && (out.find("-----END PGP PUBLIC KEY BLOCK-----") != string::npos)) { @@ -996,7 +998,8 @@ static INT_PTR CALLBACK DlgProcLoadPublicKey(HWND hwndDlg,UINT msg,WPARAM wParam gpg_thread.~thread(); TerminateProcess(params.hProcess, 1); params.hProcess = NULL; - debuglog<<std::string(time_str()+": GPG execution timed out, aborted"); + if(bDebugLog) + debuglog<<std::string(time_str()+": GPG execution timed out, aborted"); break; } if(result == pxNotFound) @@ -1243,7 +1246,8 @@ static INT_PTR CALLBACK DlgProcLoadPublicKey(HWND hwndDlg,UINT msg,WPARAM wParam gpg_thread.~thread(); TerminateProcess(params.hProcess, 1); params.hProcess = NULL; - debuglog<<std::string(time_str()+": GPG execution timed out, aborted"); + if(bDebugLog) + debuglog<<std::string(time_str()+": GPG execution timed out, aborted"); break; } if(result == pxNotFound) @@ -1330,7 +1334,8 @@ static INT_PTR CALLBACK DlgProcLoadPublicKey(HWND hwndDlg,UINT msg,WPARAM wParam if(key_buf.empty()) { key_buf.clear(); - debuglog<<std::string(time_str()+": info: Failed to read key file"); + if(bDebugLog) + debuglog<<std::string(time_str()+": info: Failed to read key file"); break; } ws2 = key_buf.find(_T("-----END PGP PUBLIC KEY BLOCK-----")); diff --git a/plugins/New_GPG/src/utilities.cpp b/plugins/New_GPG/src/utilities.cpp index 11e53b091f..7a44ad992f 100755 --- a/plugins/New_GPG/src/utilities.cpp +++ b/plugins/New_GPG/src/utilities.cpp @@ -356,13 +356,13 @@ int onProtoAck(WPARAM w, LPARAM l) dbsetting += keyid;
dbsetting += "_Password";
pass = UniGetContactSettingUtf(NULL, szGPGModuleName, dbsetting.c_str(), _T(""));
- if(_tcslen(pass) > 0)
+ if(_tcslen(pass) > 0 && bDebugLog)
debuglog<<std::string(time_str()+": info: found password in database for key id: "+keyid+", trying to decrypt message from "+toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)ack->hContact, GCDNF_TCHAR))+" with password");
}
else
{
pass = UniGetContactSettingUtf(NULL, szGPGModuleName, "szKeyPassword", _T(""));
- if(_tcslen(pass) > 0)
+ if(_tcslen(pass) > 0 && bDebugLog)
debuglog<<std::string(time_str()+": info: found password for all keys in database, trying to decrypt message from "+toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)ack->hContact, GCDNF_TCHAR))+" with password");
}
if(_tcslen(pass) > 0)
@@ -373,12 +373,13 @@ int onProtoAck(WPARAM w, LPARAM l) }
else if(password)
{
- debuglog<<std::string(time_str()+": info: found password in memory, trying to decrypt message from "+toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)ack->hContact, GCDNF_TCHAR))+" with password");
+ if(bDebugLog)
+ debuglog<<std::string(time_str()+": info: found password in memory, trying to decrypt message from "+toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)ack->hContact, GCDNF_TCHAR))+" with password");
cmd += _T("--passphrase \"");
cmd += password;
cmd += _T("\" ");
}
- else
+ else if (bDebugLog)
debuglog<<std::string(time_str()+": info: passwords not found in database or memory, trying to decrypt message from "+toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)ack->hContact, GCDNF_TCHAR))+" with out password");
mir_free(pass);
mir_free(keyid);
@@ -398,7 +399,8 @@ int onProtoAck(WPARAM w, LPARAM l) delete gpg_thread;
TerminateProcess(params.hProcess, 1);
params.hProcess = NULL;
- debuglog<<std::string(time_str()+": GPG execution timed out, aborted");
+ if(bDebugLog)
+ debuglog<<std::string(time_str()+": GPG execution timed out, aborted");
return 0;
}
while(out.find("public key decryption failed: bad passphrase") != string::npos)
@@ -406,7 +408,8 @@ int onProtoAck(WPARAM w, LPARAM l) extern bool _terminate;
extern HANDLE new_key_hcnt;
extern boost::mutex new_key_hcnt_mutex;
- debuglog<<std::string(time_str()+": info: failed to decrypt messaage from "+toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)ack->hContact, GCDNF_TCHAR))+" password needed, trying to get one");
+ if(bDebugLog)
+ debuglog<<std::string(time_str()+": info: failed to decrypt messaage from "+toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)ack->hContact, GCDNF_TCHAR))+" password needed, trying to get one");
if(_terminate)
break;
{ //save inkey id
@@ -426,7 +429,8 @@ int onProtoAck(WPARAM w, LPARAM l) wstring cmd2 = cmd;
if(password)
{
- debuglog<<std::string(time_str()+": info: found password in memory, trying to decrypt message from "+toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)ack->hContact, GCDNF_TCHAR)));
+ if(bDebugLog)
+ debuglog<<std::string(time_str()+": info: found password in memory, trying to decrypt message from "+toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)ack->hContact, GCDNF_TCHAR)));
wstring tmp = _T("--passphrase \"");
tmp += password;
tmp += _T("\" ");
@@ -446,7 +450,8 @@ int onProtoAck(WPARAM w, LPARAM l) delete gpg_thread;
TerminateProcess(params.hProcess, 1);
params.hProcess = NULL;
- debuglog<<std::string(time_str()+": GPG execution timed out, aborted");
+ if(bDebugLog)
+ debuglog<<std::string(time_str()+": GPG execution timed out, aborted");
//DeleteFile(filename);
return 0;
}
@@ -537,7 +542,8 @@ std::wstring encrypt_file(HANDLE hContact, TCHAR *filename) delete gpg_thread;
TerminateProcess(params.hProcess, 1);
params.hProcess = NULL;
- debuglog<<std::string(time_str()+": GPG execution timed out, aborted");
+ if(bDebugLog)
+ debuglog<<std::string(time_str()+": GPG execution timed out, aborted");
return 0;
}
if(out.find("There is no assurance this key belongs to the named user") != string::npos)
@@ -553,7 +559,8 @@ std::wstring encrypt_file(HANDLE hContact, TCHAR *filename) delete gpg_thread;
TerminateProcess(params.hProcess, 1);
params.hProcess = NULL;
- debuglog<<std::string(time_str()+": GPG execution timed out, aborted");
+ if(bDebugLog)
+ debuglog<<std::string(time_str()+": GPG execution timed out, aborted");
return 0;
}
}
@@ -769,7 +776,8 @@ static JABBER_HANDLER_FUNC SendHandler(IJabberInterface *ji, HXML node, void *pU {
if(errno == ENOENT)
{
- debuglog<<std::string(time_str()+": info: Failed to write prescense in file");
+ if(bDebugLog)
+ debuglog<<std::string(time_str()+": info: Failed to write prescense in file");
return FALSE;
}
}
@@ -799,13 +807,13 @@ static JABBER_HANDLER_FUNC SendHandler(IJabberInterface *ji, HXML node, void *pU dbsetting += inkeyid;
dbsetting += "_Password";
pass = UniGetContactSettingUtf(NULL, szGPGModuleName, dbsetting.c_str(), _T(""));
- if(pass[0])
+ if(pass[0] && bDebugLog)
debuglog<<std::string(time_str()+": info: found password in database for key id: "+inkeyid+", trying to encrypt message from self with password");
}
else
{
pass = UniGetContactSettingUtf(NULL, szGPGModuleName, "szKeyPassword", _T(""));
- if(pass[0])
+ if(pass[0] && bDebugLog)
debuglog<<std::string(time_str()+": info: found password for all keys in database, trying to encrypt message from self with password");
}
if(pass[0])
@@ -816,12 +824,13 @@ static JABBER_HANDLER_FUNC SendHandler(IJabberInterface *ji, HXML node, void *pU }
else if(password)
{
- debuglog<<std::string(time_str()+": info: found password in memory, trying to encrypt message from self with password");
+ if(bDebugLog)
+ debuglog<<std::string(time_str()+": info: found password in memory, trying to encrypt message from self with password");
cmd += _T("--passphrase \"");
cmd += password;
cmd += _T("\" ");
}
- else
+ else if (bDebugLog)
debuglog<<std::string(time_str()+": info: passwords not found in database or memory, trying to encrypt message from self with out password");
mir_free(pass);
mir_free(inkeyid);
@@ -848,7 +857,8 @@ static JABBER_HANDLER_FUNC SendHandler(IJabberInterface *ji, HXML node, void *pU gpg_thread.~thread();
TerminateProcess(params.hProcess, 1);
params.hProcess = NULL;
- debuglog<<std::string(time_str()+"GPG execution timed out, aborted");
+ if(bDebugLog)
+ debuglog<<std::string(time_str()+"GPG execution timed out, aborted");
}
DeleteFile(path_out.c_str());
path_out += _T(".asc");
@@ -868,7 +878,8 @@ static JABBER_HANDLER_FUNC SendHandler(IJabberInterface *ji, HXML node, void *pU }
if(data.empty())
{
- debuglog<<std::string(time_str()+": info: Failed to read prescense sign from file");
+ if(bDebugLog)
+ debuglog<<std::string(time_str()+": info: Failed to read prescense sign from file");
return FALSE;
}
if(data.find(_T("-----BEGIN PGP SIGNATURE-----")) != wstring::npos && data.find(_T("-----END PGP SIGNATURE-----")) != wstring::npos)
@@ -983,7 +994,8 @@ static JABBER_HANDLER_FUNC PrescenseHandler(IJabberInterface *ji, HXML node, voi if(errno == ENOENT)
{
// sign_file_mutex.unlock();
- debuglog<<std::string(time_str()+": info: Failed to write sign in file");
+ if(bDebugLog)
+ debuglog<<std::string(time_str()+": info: Failed to write sign in file");
return FALSE;
}
}
@@ -1009,7 +1021,8 @@ static JABBER_HANDLER_FUNC PrescenseHandler(IJabberInterface *ji, HXML node, voi gpg_thread.~thread();
TerminateProcess(params.hProcess, 1);
params.hProcess = NULL;
- debuglog<<std::string(time_str()+": GPG execution timed out, aborted");
+ if(bDebugLog)
+ debuglog<<std::string(time_str()+": GPG execution timed out, aborted");
return FALSE;
}
if(result == pxNotFound)
@@ -1086,7 +1099,8 @@ bool isContactSecured(HANDLE hContact) BYTE gpg_enc = DBGetContactSettingByte(hContact, szGPGModuleName, "GPGEncryption", 0);
if(!gpg_enc)
{
- debuglog<<std::string(time_str()+": encryption is turned off for "+toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR)));
+ if(bDebugLog)
+ debuglog<<std::string(time_str()+": encryption is turned off for "+toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR)));
return false;
}
if(!metaIsProtoMetaContacts(hContact))
@@ -1095,12 +1109,14 @@ bool isContactSecured(HANDLE hContact) if(!key[0])
{
mir_free(key);
- debuglog<<std::string(time_str()+": encryption is turned off for "+toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR)));
+ if(bDebugLog)
+ debuglog<<std::string(time_str()+": encryption is turned off for "+toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR)));
return false;
}
mir_free(key);
}
- debuglog<<std::string(time_str()+": encryption is turned on for "+toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR)));
+ if(bDebugLog)
+ debuglog<<std::string(time_str()+": encryption is turned on for "+toUTF8((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR)));
return true;
}
@@ -1181,7 +1197,8 @@ bool isGPGValid() gpg_thread.~thread();
TerminateProcess(params.hProcess, 1);
params.hProcess = NULL;
- debuglog<<std::string(time_str()+": GPG execution timed out, aborted");
+ if(bDebugLog)
+ debuglog<<std::string(time_str()+": GPG execution timed out, aborted");
}
gpg_valid = false;
string::size_type p1 = out.find("(GnuPG) ");
@@ -1296,7 +1313,8 @@ string toUTF8(wstring str) }
catch(const utf8::exception& e)
{
- debuglog<<std::string("utf8cpp encoding exception: ")+(char*)e.what();
+ if(bDebugLog)
+ debuglog<<std::string("utf8cpp encoding exception: ")+(char*)e.what();
//TODO
}
return ustr;
@@ -1314,7 +1332,8 @@ wstring toUTF16(string str) //convert as much as possible }
catch(const utf8::exception& e)
{
- debuglog<<std::string("utf8cpp decoding exception: ")+(char*)e.what();
+ if(bDebugLog)
+ debuglog<<std::string("utf8cpp decoding exception: ")+(char*)e.what();
//TODO
}
return ustr;
@@ -1780,7 +1799,8 @@ INT_PTR ImportGpGKeys(WPARAM w, LPARAM l) gpg_thread.~thread();
TerminateProcess(params.hProcess, 1);
params.hProcess = NULL;
- debuglog<<std::string(time_str()+": GPG execution timed out, aborted");
+ if(bDebugLog)
+ debuglog<<std::string(time_str()+": GPG execution timed out, aborted");
break;
}
if(result == pxNotFound)
@@ -1899,27 +1919,10 @@ void strip_line_term(std::string &s) void strip_tags(std::wstring &str)
{
- std::wstring::size_type p;
- if(_tcslen(inopentag))
- {
- for(p = str.find(inopentag); p != std::wstring::npos; p = str.find(inopentag))
- str.erase(p, _tcslen(inopentag));
- }
- if(_tcslen(inclosetag))
- {
- for(p = str.find(inclosetag); p != std::wstring::npos; p = str.find(inclosetag))
- str.erase(p, _tcslen(inclosetag));
- }
- if(_tcslen(outopentag))
- {
- for(p = str.find(outopentag); p != std::wstring::npos; p = str.find(outopentag))
- str.erase(p, _tcslen(outopentag));
- }
- if(_tcslen(outclosetag))
- {
- for(p = str.find(outclosetag); p != std::wstring::npos; p = str.find(outclosetag))
- str.erase(p, _tcslen(outclosetag));
- }
+ boost::algorithm::erase_all(str, inopentag);
+ boost::algorithm::erase_all(str, inclosetag);
+ boost::algorithm::erase_all(str, outopentag);
+ boost::algorithm::erase_all(str, outclosetag);
}
|