diff options
author | Gluzskiy Alexandr <sss123next@list.ru> | 2011-04-05 07:44:13 +0300 |
---|---|---|
committer | Gluzskiy Alexandr <sss123next@list.ru> | 2011-04-05 07:44:13 +0300 |
commit | 01a38512a17fc0f08fca08e9fb8d4edfd0d061df (patch) | |
tree | 764269d8fd116a1415ce9767884cd690b9a5fc19 /messages.cpp | |
parent | 62bf3df560d4e2a271c587b8bea4ce38a9ac1b2f (diff) |
modified: messages.cpp
modified: utilities.cpp
modified: utilities.h
Diffstat (limited to 'messages.cpp')
-rw-r--r-- | messages.cpp | 55 |
1 files changed, 28 insertions, 27 deletions
diff --git a/messages.cpp b/messages.cpp index 51bd113..f73223e 100644 --- a/messages.cpp +++ b/messages.cpp @@ -23,7 +23,7 @@ boost::mutex new_key_hcnt_mutex; bool _terminate = false; int returnNoError(HANDLE hContact); -int RecvMsgSvc_func(HANDLE hContact, std::wstring str, char *msg, DWORD flags) +int RecvMsgSvc_func(HANDLE hContact, std::wstring str, char *msg, DWORD flags, DWORD timestamp) { DWORD dbflags = DBEF_UTF; { //check for gpg related data @@ -38,7 +38,7 @@ int RecvMsgSvc_func(HANDLE hContact, std::wstring str, char *msg, DWORD flags) bool isContactHaveKey(HANDLE hContact); if(!isContactSecured(hContact)) { - debuglog<<time_str()<<": 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)<<" with turned 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)) @@ -65,7 +65,8 @@ int RecvMsgSvc_func(HANDLE hContact, std::wstring str, char *msg, DWORD flags) } else if(MessageBox(0, _T("Do you want try to decrypt encrypted message ?"), _T("Warning"), MB_YESNO) == IDNO) { - HistoryLog(hContact, msg, EVENTTYPE_MESSAGE, dbflags); + + HistoryLog(hContact, db_event(msg, timestamp, 0, dbflags)); return 0; } } @@ -160,13 +161,13 @@ int RecvMsgSvc_func(HANDLE hContact, std::wstring str, char *msg, DWORD flags) params.hProcess = NULL; debuglog<<time_str()<<": GPG execution timed out, aborted\n"; DeleteFile(path.c_str()); - HistoryLog(hContact, msg, EVENTTYPE_MESSAGE, dbflags); + HistoryLog(hContact, db_event(msg, timestamp, 0, dbflags)); return 0; } if(result == pxNotFound) { DeleteFile(path.c_str()); - HistoryLog(hContact, msg, EVENTTYPE_MESSAGE, dbflags); + HistoryLog(hContact, db_event(msg, timestamp, 0, dbflags)); return 0; } _terminate = false; @@ -211,13 +212,13 @@ int RecvMsgSvc_func(HANDLE hContact, std::wstring str, char *msg, DWORD flags) params.hProcess = NULL; debuglog<<time_str()<<": GPG execution timed out, aborted\n"; DeleteFile(path.c_str()); - HistoryLog(hContact, msg, EVENTTYPE_MESSAGE, dbflags); + HistoryLog(hContact, db_event(msg, timestamp, 0, dbflags)); return 0; } if(result == pxNotFound) { DeleteFile(path.c_str()); - HistoryLog(hContact, msg, EVENTTYPE_MESSAGE, dbflags); + HistoryLog(hContact, db_event(msg, timestamp, 0, dbflags)); return 0; } } @@ -230,13 +231,13 @@ int RecvMsgSvc_func(HANDLE hContact, std::wstring str, char *msg, DWORD flags) params.hProcess = NULL; debuglog<<time_str()<<": GPG execution timed out, aborted\n"; DeleteFile(path.c_str()); - HistoryLog(hContact, msg, EVENTTYPE_MESSAGE, dbflags); + HistoryLog(hContact, db_event(msg, timestamp, 0, dbflags)); return 0; } if(result == pxNotFound) { DeleteFile(path.c_str()); - HistoryLog(hContact, msg, EVENTTYPE_MESSAGE, dbflags); + HistoryLog(hContact, db_event(msg, timestamp, 0, dbflags)); } { wstring tmp = tmp2; @@ -257,7 +258,7 @@ int RecvMsgSvc_func(HANDLE hContact, std::wstring str, char *msg, DWORD flags) debuglog<<time_str()<<": info: Failed to decrypt GPG encrypted message.\n"; char *tmp = new char [str.length()+1]; strcpy(tmp, str.c_str()); - HistoryLog(hContact, tmp, EVENTTYPE_MESSAGE, dbflags); + HistoryLog(hContact, db_event(msg, timestamp, 0, dbflags)); mir_free(tmp); return 0; } @@ -289,7 +290,7 @@ int RecvMsgSvc_func(HANDLE hContact, std::wstring str, char *msg, DWORD flags) str.insert(0, "Failed to decrypt GPG encrypted message.\nMessage body for manual decryption:\n"); debuglog<<time_str()<<": info: Failed to decrypt GPG encrypted message.\n"; char *tmp = mir_strdup(str.c_str()); - HistoryLog(hContact, tmp, EVENTTYPE_MESSAGE, dbflags); + HistoryLog(hContact, db_event(msg, timestamp, 0, dbflags)); mir_free(tmp); return 0; } @@ -303,13 +304,13 @@ int RecvMsgSvc_func(HANDLE hContact, std::wstring str, char *msg, DWORD flags) if(metaIsSubcontact(hContact)) { char *msg = mir_strdup(toUTF8(str).c_str()); - HistoryLog(hContact, msg, EVENTTYPE_MESSAGE, dbflags|DBEF_READ); - HistoryLog(metaGetContact(hContact), msg, EVENTTYPE_MESSAGE, dbflags); + HistoryLog(hContact, db_event(msg, timestamp, 0, dbflags|DBEF_READ)); + HistoryLog(metaGetContact(hContact), db_event(msg, timestamp, 0, dbflags)); mir_free(msg); return 0; } char *tmp = mir_strdup(toUTF8(str).c_str()); - HistoryLog(hContact, tmp, EVENTTYPE_MESSAGE, dbflags); + HistoryLog(hContact, db_event(msg, timestamp, 0, dbflags)); mir_free(tmp); return 0; } @@ -321,14 +322,14 @@ int RecvMsgSvc_func(HANDLE hContact, std::wstring str, char *msg, DWORD flags) { if(metaIsSubcontact(hContact)) { - HistoryLog(hContact, msg, EVENTTYPE_MESSAGE, dbflags| DBEF_READ); - HistoryLog(metaGetContact(hContact), msg, EVENTTYPE_MESSAGE, dbflags); + HistoryLog(hContact, db_event(msg, timestamp, 0, dbflags|DBEF_READ)); + HistoryLog(metaGetContact(hContact), db_event(msg, timestamp, 0, dbflags)); return 0; } - HistoryLog(hContact, msg, EVENTTYPE_MESSAGE, dbflags|DBEF_READ); + HistoryLog(hContact, db_event(msg, timestamp, 0, dbflags|DBEF_READ)); return 0; } - HistoryLog(hContact, msg, EVENTTYPE_MESSAGE, dbflags); + HistoryLog(hContact, db_event(msg, timestamp, 0, dbflags)); return 0; } @@ -459,9 +460,9 @@ int RecvMsgSvc(WPARAM w, LPARAM l) { setSrmmIcon(metaGetContact(ccs->hContact)); setClistIcon(metaGetContact(ccs->hContact)); - HistoryLog(metaGetContact(ccs->hContact), "PGP Encryption turned on by key autoexchange feature", EVENTTYPE_MESSAGE, 0); + HistoryLog(metaGetContact(ccs->hContact), "PGP Encryption turned on by key autoexchange feature"); } - HistoryLog(ccs->hContact, "PGP Encryption turned on by key autoexchange feature", EVENTTYPE_MESSAGE, 0); + HistoryLog(ccs->hContact, "PGP Encryption turned on by key autoexchange feature"); } } return 1; @@ -481,7 +482,7 @@ int RecvMsgSvc(WPARAM w, LPARAM l) { //this is public key if(metaIsProtoMetaContacts(ccs->hContact)) { - HistoryLog(ccs->hContact, msg, EVENTTYPE_MESSAGE, dbflags); + HistoryLog(ccs->hContact, db_event(msg, 0, 0, dbflags)); return 0; } debuglog<<time_str()<<": info: "<<"received key from: "<<(TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)ccs->hContact, GCDNF_TCHAR)<<"\n"; @@ -507,7 +508,7 @@ int RecvMsgSvc(WPARAM w, LPARAM l) new_key_hcnt_mutex.lock(); new_key_hcnt = ccs->hContact; ShowNewKeyDialog(); - HistoryLog(ccs->hContact, msg, EVENTTYPE_MESSAGE, dbflags); + HistoryLog(ccs->hContact, db_event(msg, 0, 0, dbflags)); return 0; } if(bAutoExchange && strstr(msg, "-----PGP KEY REQUEST-----") && isGPGConfigured()) @@ -568,7 +569,7 @@ int RecvMsgSvc(WPARAM w, LPARAM l) } if(!(strstr(msg, "-----BEGIN PGP MESSAGE-----") && strstr(msg, "-----END PGP MESSAGE-----"))) return CallService(MS_PROTO_CHAINRECV, w, l); - boost::thread *thr = new boost::thread(boost::bind(RecvMsgSvc_func, ccs->hContact, str, msg, ccs->wParam)); + boost::thread *thr = new boost::thread(boost::bind(RecvMsgSvc_func, ccs->hContact, str, msg, ccs->wParam, pre->timestamp)); return returnNoError(ccs->hContact); } @@ -602,7 +603,7 @@ int SendMsgSvc_func(HANDLE hContact, char *msg, DWORD flags) if(!tmp[0]) { mir_free(tmp); - HistoryLog(hContact, "Failed to encrypt message with GPG", EVENTTYPE_MESSAGE, DBEF_SENT); + 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"); mir_free(msg); return CallContactService(hContact, PSS_MESSAGE, (WPARAM)flags, (LPARAM)msg); @@ -721,7 +722,7 @@ int SendMsgSvc_func(HANDLE hContact, char *msg, DWORD flags) } if(str.empty()) { - HistoryLog(hContact, "Failed to encrypt message with GPG", EVENTTYPE_MESSAGE, DBEF_SENT); + 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<<time_str()<<": info: Failed to encrypt message with GPG\n"; mir_free(msg); @@ -738,11 +739,11 @@ int SendMsgSvc_func(HANDLE hContact, char *msg, DWORD flags) 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"; - HistoryLog(metaGetContact(hContact), (char*)str_event.c_str(), EVENTTYPE_MESSAGE, DBEF_SENT|dbflags); + HistoryLog(metaGetContact(hContact), db_event((char*)str_event.c_str(), 0,0, DBEF_SENT|dbflags)); } hcontact_data[hContact].msgs_to_pass.push_back(str_event); debuglog<<time_str()<<": adding event to contact: "<<(TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR)<<" on send message.\n"; - HistoryLog(hContact, (char*)str_event.c_str(), EVENTTYPE_MESSAGE, dbflags|DBEF_SENT); + HistoryLog(hContact, db_event((char*)str_event.c_str(), 0,0, dbflags|DBEF_SENT)); if(!(flags & PREF_UTF)) flags |= PREF_UTF; CallContactService(hContact, PSS_MESSAGE, (WPARAM)flags, (LPARAM)toUTF8(str).c_str()); |