diff options
Diffstat (limited to 'messages.cpp')
-rw-r--r-- | messages.cpp | 49 |
1 files changed, 20 insertions, 29 deletions
diff --git a/messages.cpp b/messages.cpp index d1ee06d..92bdb78 100644 --- a/messages.cpp +++ b/messages.cpp @@ -85,14 +85,11 @@ int RecvMsgSvc(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<<time_str()<<": GPG execution timed out, aborted\n";
return 1;
}
if(result == pxNotFound)
- {
- MessageBox(0, _T("Set path to gpg.exe first!"), _T("Warning"), MB_OK);
return 1;
- } {
char *tmp = NULL;
string::size_type s = output.find("gpg: key ") + strlen("gpg: key ");
@@ -165,7 +162,7 @@ int RecvMsgSvc(WPARAM w, LPARAM l) { //this is public key if(metaIsSubcontact(hContact)) return CallService(MS_PROTO_CHAINRECV, w, l); //yet another metacontacts problem - debuglog<<"info: "<<"received key from: "<<(TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR)<<"\n"; + debuglog<<time_str()<<": info: "<<"received key from: "<<(TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR)<<"\n"; s1 = 0; while((s1 = str.find(_T("\r"), s1)) != wstring::npos) { @@ -255,7 +252,7 @@ int RecvMsgSvc(WPARAM w, LPARAM l) bool isContactHaveKey(HANDLE hContact); if(!DBGetContactSettingByte(metaGetCurrent(hContact), szGPGModuleName, "GPGEncryption", 0)) { - debuglog<<"info: "<<"received message from: "<<(TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR)<<" whith tyrned off encryption\n"; + debuglog<<time_str()<<": info: "<<"received message from: "<<(TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR)<<" whith tyrned off encryption\n"; if(MessageBox(0, _T("We received encrypted message from contact with encryption turned off.\nDo you want turn on encryption for this contact ?"), _T("Warning"), MB_YESNO) == IDYES) { if(!isContactHaveKey(hContact)) @@ -314,13 +311,13 @@ int RecvMsgSvc(WPARAM w, LPARAM l) dbsetting += "_Password"; pass = UniGetContactSettingUtf(NULL, szGPGModuleName, dbsetting.c_str(), _T("")); if(_tcslen(pass) > 0) - debuglog<<"info: found password in database for key id: "<<inkeyid<<", trying to decrypt message from "<<(TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR)<<" with password\n"; + debuglog<<time_str()<<": info: found password in database for key id: "<<inkeyid<<", trying to decrypt message from "<<(TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR)<<" with password\n"; } else { pass = UniGetContactSettingUtf(NULL, szGPGModuleName, "szKeyPassword", _T("")); if(_tcslen(pass) > 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<<time_str()<<": 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"; } if(_tcslen(pass) > 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<<time_str()<<": info: found password in memory, trying to decrypt message from "<<(TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR)<<" with password\n"; cmd += _T("--passphrase \""); cmd += password; cmd += _T("\" "); } else - debuglog<<"info: passwords not found in database or memory, trying to decrypt message from "<<(TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR)<<" with out password\n"; + debuglog<<time_str()<<": info: passwords not found in database or memory, trying to decrypt message from "<<(TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR)<<" with out password\n"; mir_free(pass); mir_free(inkeyid); } @@ -362,19 +359,19 @@ int RecvMsgSvc(WPARAM w, LPARAM l) if(!gpg_thread->timed_join(boost::posix_time::seconds(10))) { delete gpg_thread; - MessageBox(0, _T("GPG execution timed out, aborted"), _T(""), MB_OK); + debuglog<<time_str()<<": GPG execution timed out, aborted\n"; + DeleteFile(path.c_str()); return CallService(MS_PROTO_CHAINRECV, w, l); } if(result == pxNotFound) { - MessageBox(0, _T("Set path to gpg.exe first!"), _T("Warning"), MB_OK); DeleteFile(path.c_str()); return CallService(MS_PROTO_CHAINRECV, w, l); } _terminate = false; while(out.find("public key decryption failed: bad passphrase") != string::npos) { - debuglog<<"info: failed to decrypt messaage from "<<(TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR)<<" password needed, trying to get one\n"; + debuglog<<time_str()<<": info: failed to decrypt messaage from "<<(TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR)<<" password needed, trying to get one\n"; if(_terminate) break; { //save inkey id @@ -391,7 +388,7 @@ int RecvMsgSvc(WPARAM w, LPARAM l) wstring cmd2 = cmd; if(password) { - debuglog<<"info: found password in memory, trying to decrypt message from "<<(TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR)<<"\n"; + debuglog<<time_str()<<": info: found password in memory, trying to decrypt message from "<<(TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR)<<"\n"; wstring tmp = _T("--passphrase \""); tmp += password; tmp += _T("\" "); @@ -409,12 +406,12 @@ int RecvMsgSvc(WPARAM w, LPARAM l) if(!gpg_thread->timed_join(boost::posix_time::seconds(10))) { delete gpg_thread; - MessageBox(0, _T("GPG execution timed out, aborted"), _T(""), MB_OK); + debuglog<<time_str()<<": GPG execution timed out, aborted\n"; + DeleteFile(path.c_str()); return CallService(MS_PROTO_CHAINRECV, w, l); } if(result == pxNotFound) { - MessageBox(0, _T("Set path to gpg.exe first!"), _T("Warning"), MB_OK); DeleteFile(path.c_str()); return CallService(MS_PROTO_CHAINRECV, w, l); } @@ -424,12 +421,12 @@ int RecvMsgSvc(WPARAM w, LPARAM l) if(!gpg_thread->timed_join(boost::posix_time::seconds(10))) { delete gpg_thread; - MessageBox(0, _T("GPG execution timed out, aborted"), _T(""), MB_OK); + debuglog<<time_str()<<": GPG execution timed out, aborted\n"; + DeleteFile(path.c_str()); return CallService(MS_PROTO_CHAINRECV, w, l); } if(result == pxNotFound) { - MessageBox(0, _T("Set path to gpg.exe first!"), _T("Warning"), MB_OK); DeleteFile(path.c_str()); return CallService(MS_PROTO_CHAINRECV, w, l); } @@ -448,7 +445,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<<time_str()<<": info: Failed to decrypt GPG encrypted message.\n"; char *tmp = new char [str.length()+1]; strcpy(tmp, str.c_str()); pre->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<<time_str()<<": info: Failed to decrypt GPG encrypted message.\n"; pre->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<<time_str()<<": GPG execution timed out, aborted\n"; return CallService(MS_PROTO_CHAINSEND, w, l); } if(result == pxNotFound) - { - MessageBox(0, _T("Set path to gpg.exe first!"), _T("Warning"), MB_OK); return CallService(MS_PROTO_CHAINSEND, w, l); - } if(out.find("There is no assurance this key belongs to the named user") != string::npos) { out.clear(); @@ -679,14 +673,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<<time_str()<<": GPG execution timed out, aborted\n"; return CallService(MS_PROTO_CHAINSEND, w, l); } if(result == pxNotFound) - { - MessageBox(0, _T("Set path to gpg.exe first!"), _T("Warning"), MB_OK); return CallService(MS_PROTO_CHAINSEND, w, l); - } } else return 0; @@ -716,7 +707,7 @@ int SendMsgSvc(WPARAM w, LPARAM l) if(str.empty()) { HistoryLog(hContact, "Failed to encrypt message with GPG", EVENTTYPE_MESSAGE, DBEF_SENT); - debuglog<<"info: Failed to encrypt message with GPG"; + debuglog<<time_str()<<": info: Failed to encrypt message with GPG"; return CallService(MS_PROTO_CHAINRECV, w, (LPARAM)ccs); } if(metaIsSubcontact(hContact)) |