From 0ab2db678a2a79f624a74a51ac617110d9b4413e Mon Sep 17 00:00:00 2001 From: Gluzskiy Alexandr Date: Tue, 22 Mar 2011 08:23:16 +0200 Subject: extended threading (test) --- messages.cpp | 177 ++++++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 113 insertions(+), 64 deletions(-) (limited to 'messages.cpp') diff --git a/messages.cpp b/messages.cpp index dbb87c2..b37bbd0 100644 --- a/messages.cpp +++ b/messages.cpp @@ -23,24 +23,13 @@ boost::mutex new_key_hcnt_mutex; bool _terminate = false; int returnNoError(HANDLE hContact); -int RecvMsgSvc(WPARAM w, LPARAM l) +int RecvMsgSvc_func(HANDLE hContact, char *msg, DWORD flags) { - CCSDATA *ccs = (CCSDATA*)l; - if (!ccs) - return CallService(MS_PROTO_CHAINRECV, w, l); - PROTORECVEVENT *pre = (PROTORECVEVENT*)(ccs->lParam); - if (!pre) - return CallService(MS_PROTO_CHAINRECV, w, l); - char *msg = pre->szMessage; - if (!msg) - return CallService(MS_PROTO_CHAINRECV, w, l); - HANDLE hContact = ccs->hContact; - { //check for gpg related data wstring str = toUTF16(msg); wstring::size_type s1 = wstring::npos, s2 = wstring::npos; - if((str.find(_T("-----PGP KEY RESPONSE-----")) != wstring::npos) && !metaIsProtoMetaContacts(ccs->hContact)) + if((str.find(_T("-----PGP KEY RESPONSE-----")) != wstring::npos) && !metaIsProtoMetaContacts(hContact)) { s2 = str.find(_T("-----END PGP PUBLIC KEY BLOCK-----")); s1 = str.find(_T("-----BEGIN PGP PUBLIC KEY BLOCK-----")); @@ -85,10 +74,14 @@ int RecvMsgSvc(WPARAM w, LPARAM l) { gpg_thread.~thread(); debuglog<szMessage; - mir_free((void**)pre->szMessage); + string str = msg; str.insert(0, "Received unencrypted message:\n"); debuglog<szMessage = tmp; - return CallService(MS_PROTO_CHAINRECV, w, (LPARAM)ccs); + HistoryLog(hContact, tmp, EVENTTYPE_MESSAGE, flags); + mir_free(tmp); + mir_free(msg); + return 0; } } } @@ -486,12 +502,14 @@ int RecvMsgSvc(WPARAM w, LPARAM l) } if(str.empty()) { - string str = pre->szMessage; - mir_free((void**)pre->szMessage); + string str = msg; str.insert(0, "Failed to decrypt GPG encrypted message.\nMessage body for manual decryption:\n"); debuglog<szMessage = mir_strdup(str.c_str()); - return CallService(MS_PROTO_CHAINRECV, w, (LPARAM)ccs); + char *tmp = mir_strdup(str.c_str()); + HistoryLog(hContact, tmp, EVENTTYPE_MESSAGE, flags); + mir_free(tmp); + mir_free(msg); + return 0; } else { @@ -508,9 +526,13 @@ int RecvMsgSvc(WPARAM w, LPARAM l) mir_free(msg); return 1; } - mir_free((void**)pre->szMessage); - pre->szMessage = mir_strdup(toUTF8(str).c_str()); - return CallService(MS_PROTO_CHAINRECV, w, (LPARAM)ccs); + char *tmp = mir_strdup(toUTF8(str).c_str()); + if(!(flags & DBEF_UTF)) + flags |= DBEF_UTF; + HistoryLog(hContact, tmp, EVENTTYPE_MESSAGE, flags); + mir_free(tmp); + mir_free(msg); + return 0; } } } @@ -526,31 +548,35 @@ int RecvMsgSvc(WPARAM w, LPARAM l) return 1; } string str = msg; - mir_free((void**)pre->szMessage); str.insert(0, "Received unencrypted message:\n"); - pre->szMessage = mir_strdup(str.c_str()); - return CallService(MS_PROTO_CHAINRECV, w, (LPARAM)ccs); + char *tmp = mir_strdup(str.c_str()); + HistoryLog(hContact, tmp, EVENTTYPE_MESSAGE, flags); + mir_free(tmp); + mir_free(msg); + return 0; } - return CallService(MS_PROTO_CHAINRECV, w, l); + HistoryLog(hContact, msg, EVENTTYPE_MESSAGE, flags); + mir_free(msg); + return 0; } -int SendMsgSvc(WPARAM w, LPARAM l) +int RecvMsgSvc(WPARAM w, LPARAM l) { CCSDATA *ccs = (CCSDATA*)l; if (!ccs) - return CallService(MS_PROTO_CHAINSEND, w, l); - - char *msg = (char*)(ccs->lParam); + return CallService(MS_PROTO_CHAINRECV, w, l); + PROTORECVEVENT *pre = (PROTORECVEVENT*)(ccs->lParam); + if (!pre) + return CallService(MS_PROTO_CHAINRECV, w, l); + char *msg = mir_strdup(pre->szMessage); if (!msg) - return CallService(MS_PROTO_CHAINSEND, w, l); - if(strstr(msg,"-----BEGIN PGP MESSAGE-----")) //metecontacts .... %) - return CallService(MS_PROTO_CHAINSEND, w, l); - HANDLE hContact = ccs->hContact; - if(metaIsProtoMetaContacts(hContact)) - { - hcontact_data[ccs->hContact].msgs_to_ignore.push_back((char*)ccs->lParam); - return CallService(MS_PROTO_CHAINSEND, w, l); - } + return CallService(MS_PROTO_CHAINRECV, w, l); + boost::thread *thr = new boost::thread(boost::bind(RecvMsgSvc_func, ccs->hContact, msg, ccs->wParam)); + return returnNoError(ccs->hContact); +} + +int SendMsgSvc_func(HANDLE hContact, char *msg, DWORD flags) +{ if(!isContactHaveKey(hContact) && bAutoExchange && !strstr(msg, "-----PGP KEY REQUEST-----") && !strstr(msg, "-----BEGIN PGP PUBLIC KEY BLOCK-----") && isGPGConfigured()) { void send_encrypted_msgs_thread(HANDLE hContact); @@ -564,7 +590,7 @@ int SendMsgSvc(WPARAM w, LPARAM l) strcpy(cap.caps, "GPG AutoExchange"); if(CallService("ICQ"PS_ICQ_CHECKCAPABILITY, (WPARAM)hContact, (LPARAM)&cap)) { - CallContactService(hContact, PSS_MESSAGE, (WPARAM)PREF_UTF, (LPARAM)"-----PGP KEY REQUEST-----"); + CallContactService(hContact, PSS_MESSAGE, (WPARAM)flags, (LPARAM)"-----PGP KEY REQUEST-----"); hcontact_data[hContact].msgs_to_ignore.push_back(msg); hcontact_data[hContact].msgs_to_send.push_back(msg); boost::thread *thr = new boost::thread(boost::bind(send_encrypted_msgs_thread, hContact)); @@ -595,7 +621,7 @@ int SendMsgSvc(WPARAM w, LPARAM l) mir_free(caps); if(str.find(_T("GPG_Key_Auto_Exchange:0")) != string::npos) { - CallContactService(hContact, PSS_MESSAGE, (WPARAM)PREF_UTF, (LPARAM)"-----PGP KEY REQUEST-----"); + CallContactService(hContact, PSS_MESSAGE, (WPARAM)flags, (LPARAM)"-----PGP KEY REQUEST-----"); hcontact_data[hContact].msgs_to_ignore.push_back(msg); hcontact_data[hContact].msgs_to_send.push_back(msg); boost::thread *thr = new boost::thread(boost::bind(send_encrypted_msgs_thread, hContact)); @@ -607,7 +633,7 @@ int SendMsgSvc(WPARAM w, LPARAM l) } } if(!isContactSecured(hContact)) - return CallService(MS_PROTO_CHAINSEND, w, l); + return CallContactService(hContact, PSS_MESSAGE, (WPARAM)flags, (LPARAM)msg); { //encrypt data here wstring str; @@ -636,7 +662,7 @@ int SendMsgSvc(WPARAM w, LPARAM l) { mir_free(tmp); HistoryLog(hContact, "Failed to encrypt message with GPG", EVENTTYPE_MESSAGE, DBEF_SENT); - return CallService(MS_PROTO_CHAINSEND, w, l); + return CallContactService(hContact, PSS_MESSAGE, (WPARAM)flags, (LPARAM)msg); } if(!bJabberAPI || !bIsMiranda09) //force jabber to handle encrypted message by itself cmd += _T("--comment \"\" --no-version "); @@ -675,10 +701,10 @@ int SendMsgSvc(WPARAM w, LPARAM l) { gpg_thread.~thread(); debuglog<lParam; + string str_event = msg; if(bAppendTags) { //utf8 tag will cause problems here str_event.insert(0, toUTF8(outopentag)); @@ -755,11 +781,34 @@ int SendMsgSvc(WPARAM w, LPARAM l) return returnNoError(hContact); } if(bAppendTags) - hcontact_data[hContact].msgs_to_tag.push_back((char*)ccs->lParam); - ccs->lParam = (LPARAM)mir_strdup(toUTF8(str).c_str()); + hcontact_data[hContact].msgs_to_tag.push_back(msg); + mir_free(msg); + msg = mir_strdup(toUTF8(str).c_str()); } } - return CallService(MS_PROTO_CHAINSEND, w, l); + if(!(flags & PREF_UTF)) + flags |= PREF_UTF; + CallContactService(hContact, PSS_MESSAGE, (WPARAM)flags, (LPARAM)msg); + return 0; +} + +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)); + if (!msg) + return CallService(MS_PROTO_CHAINSEND, w, l); + if(strstr(msg,"-----BEGIN PGP MESSAGE-----")) + return CallService(MS_PROTO_CHAINSEND, w, l); + if(metaIsProtoMetaContacts(ccs->hContact)) + { + hcontact_data[ccs->hContact].msgs_to_ignore.push_back((char*)msg); + return CallService(MS_PROTO_CHAINSEND, w, l); + } + boost::thread *thr = new boost::thread(boost::bind(SendMsgSvc_func, ccs->hContact, msg, (DWORD)ccs->wParam)); + return returnNoError(ccs->hContact); } int HookSendMsg(WPARAM w, LPARAM l) -- cgit v1.2.3 From 59822f2c393d553d43adb4a5eb8daf77609063f2 Mon Sep 17 00:00:00 2001 From: Gluzskiy Alexandr Date: Tue, 22 Mar 2011 14:09:37 +0200 Subject: new threading code (part 2, usable) --- messages.cpp | 490 +++++++++++++++++++++++++++++------------------------------ 1 file changed, 237 insertions(+), 253 deletions(-) (limited to 'messages.cpp') diff --git a/messages.cpp b/messages.cpp index b37bbd0..05d138a 100644 --- a/messages.cpp +++ b/messages.cpp @@ -28,6 +28,9 @@ int RecvMsgSvc_func(HANDLE hContact, char *msg, DWORD flags) { //check for gpg related data wstring str = toUTF16(msg); wstring::size_type s1 = wstring::npos, s2 = wstring::npos; + DWORD dbflags = 0; + if(flags & PREF_UTF) + flags |= DBEF_UTF; if((str.find(_T("-----PGP KEY RESPONSE-----")) != wstring::npos) && !metaIsProtoMetaContacts(hContact)) { @@ -147,7 +150,6 @@ int RecvMsgSvc_func(HANDLE hContact, char *msg, DWORD flags) HistoryLog(hContact, "PGP Encryption turned on by key autoexchange feature", EVENTTYPE_MESSAGE, 0); } } - hcontact_data[hContact].msgs_to_ignore.push_back(msg); mir_free(msg); return 1; } @@ -166,7 +168,7 @@ int RecvMsgSvc_func(HANDLE hContact, char *msg, DWORD flags) { //this is public key if(metaIsSubcontact(hContact)) { - HistoryLog(hContact, msg, EVENTTYPE_MESSAGE, flags); + HistoryLog(hContact, msg, EVENTTYPE_MESSAGE, dbflags); mir_free(msg); return 0; } @@ -193,7 +195,7 @@ int RecvMsgSvc_func(HANDLE hContact, char *msg, DWORD flags) new_key_hcnt_mutex.lock(); new_key_hcnt = hContact; ShowNewKeyDialog(); - HistoryLog(hContact, msg, EVENTTYPE_MESSAGE, flags); + HistoryLog(hContact, msg, EVENTTYPE_MESSAGE, dbflags); mir_free(msg); return 0; } @@ -290,7 +292,7 @@ int RecvMsgSvc_func(HANDLE hContact, 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, flags); + HistoryLog(hContact, msg, EVENTTYPE_MESSAGE, dbflags); mir_free(msg); return 0; } @@ -376,14 +378,14 @@ int RecvMsgSvc_func(HANDLE hContact, char *msg, DWORD flags) delete gpg_thread; debuglog< Accounts; - list::iterator end = Accounts.end(); - for(list::iterator p = Accounts.begin(); p != end; p++) - { - TCHAR *caps = (*p)->getJabberInterface()->Net()->GetResourceFeatures(jid); - if(caps) - { - wstring str; - for(int i =0;;i++) - { - str.push_back(caps[i]); - if(caps[i] == '\0') - if(caps[i+1] == '\0') - break; - } - mir_free(caps); - if(str.find(_T("GPG_Key_Auto_Exchange:0")) != string::npos) - { - CallContactService(hContact, PSS_MESSAGE, (WPARAM)flags, (LPARAM)"-----PGP KEY REQUEST-----"); - hcontact_data[hContact].msgs_to_ignore.push_back(msg); - hcontact_data[hContact].msgs_to_send.push_back(msg); - boost::thread *thr = new boost::thread(boost::bind(send_encrypted_msgs_thread, hContact)); - return returnNoError(hContact); - } - } - } - } + tmp = mir_a2t(msg); + isansi = true; } + str.append(tmp); + mir_free(tmp); } - if(!isContactSecured(hContact)) + string out; + DWORD code; + wstring cmd; + wstring path; + extern bool bJabberAPI, bIsMiranda09; + char *tmp = UniGetContactSettingUtf(hContact, szGPGModuleName, "KeyID", ""); + if(!tmp[0]) + { + mir_free(tmp); + HistoryLog(hContact, "Failed to encrypt message with GPG", EVENTTYPE_MESSAGE, 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); - - { //encrypt data here - wstring str; - bool isansi = false; - if(!metaIsSubcontact(hContact)) - str = toUTF16(msg); - else - {//workaround ... - wchar_t *tmp = mir_utf8decodeW(msg); - if(!tmp) - { - tmp = mir_a2t(msg); - isansi = true; - } - str.append(tmp); - mir_free(tmp); - } + } + if(!bJabberAPI || !bIsMiranda09) //force jabber to handle encrypted message by itself + cmd += _T("--comment \"\" --no-version "); + if(DBGetContactSettingByte(hContact, szGPGModuleName, "bAlwaysTrust", 0)) + cmd += _T("--trust-model always "); + cmd += _T("--batch --yes -e -a -r "); + TCHAR *tmp2 = mir_a2t(tmp); + mir_free(tmp); + cmd += tmp2; + mir_free(tmp2); + cmd += _T(" \""); + tmp2 = UniGetContactSettingUtf(NULL, szGPGModuleName, "szHomePath", _T("")); + path.append(tmp2); + cmd += tmp2; + mir_free(tmp2); + cmd += _T("\\exported_data"); + path.append(_T("\\exported_data")); + cmd += _T("\""); + { + char *tmp; + tmp = mir_strdup(toUTF8(str).c_str()); + fstream f(path.c_str(), std::ios::out); + f<lParam)); if (!msg) + { + mir_free(msg); return CallService(MS_PROTO_CHAINSEND, w, l); + } if(strstr(msg,"-----BEGIN PGP MESSAGE-----")) return CallService(MS_PROTO_CHAINSEND, w, l); + if(!isContactHaveKey(ccs->hContact)) + { + if(bAutoExchange && !strstr(msg, "-----PGP KEY REQUEST-----") && !strstr(msg, "-----BEGIN PGP PUBLIC KEY BLOCK-----") && isGPGConfigured()) + { + void send_encrypted_msgs_thread(HANDLE hContact); + LPSTR proto = (LPSTR)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)ccs->hContact, 0); + DWORD uin = DBGetContactSettingDword(ccs->hContact, proto, "UIN", 0); + if(uin) + { + if(ServiceExists("ICQ"PS_ICQ_CHECKCAPABILITY)) + { + ICQ_CUSTOMCAP cap = {0}; + strcpy(cap.caps, "GPG AutoExchange"); + if(CallService("ICQ"PS_ICQ_CHECKCAPABILITY, (WPARAM)ccs->hContact, (LPARAM)&cap)) + { + 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)); + mir_free(msg); + return returnNoError(ccs->hContact); + } + } + } + else + { + TCHAR *jid = UniGetContactSettingUtf(ccs->hContact, proto, "jid", _T("")); + if(jid[0]) + { + extern list Accounts; + list::iterator end = Accounts.end(); + for(list::iterator p = Accounts.begin(); p != end; p++) + { + TCHAR *caps = (*p)->getJabberInterface()->Net()->GetResourceFeatures(jid); + if(caps) + { + wstring str; + for(int i =0;;i++) + { + str.push_back(caps[i]); + if(caps[i] == '\0') + if(caps[i+1] == '\0') + break; + } + mir_free(caps); + if(str.find(_T("GPG_Key_Auto_Exchange:0")) != string::npos) + { + 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)); + mir_free(msg); + return returnNoError(ccs->hContact); + } + } + } + } + } + } + else + { + mir_free(msg); + return CallService(MS_PROTO_CHAINSEND, w, l); + } + } if(metaIsProtoMetaContacts(ccs->hContact)) { - hcontact_data[ccs->hContact].msgs_to_ignore.push_back((char*)msg); + mir_free(msg); return CallService(MS_PROTO_CHAINSEND, w, l); } boost::thread *thr = new boost::thread(boost::bind(SendMsgSvc_func, ccs->hContact, msg, (DWORD)ccs->wParam)); return returnNoError(ccs->hContact); } +boost::mutex event_processing_mutex; + int HookSendMsg(WPARAM w, LPARAM l) -{ //TODO: implement additional filtering for metacontacts data... +{ if(!l) return 0; DBEVENTINFO * dbei = (DBEVENTINFO*)l; - if((dbei->eventType == EVENTTYPE_MESSAGE) && (dbei->flags & DBEF_SENT)) + if(dbei->eventType != EVENTTYPE_MESSAGE) + return 0; + if(dbei->flags & DBEF_SENT) { if(strstr((char*)dbei->pBlob, "-----BEGIN PGP MESSAGE-----") || strstr((char*)dbei->pBlob, "-----PGP KEY RESPONSE-----") || strstr((char*)dbei->pBlob, "-----PGP KEY REQUEST-----") || strstr((char*)dbei->pBlob, "-----PGP KEY RESPONSE-----")) //our service data, can be double added by metacontacts e.t.c. return 1; - HANDLE hContact = NULL; - if(!hcontact_data[(HANDLE)w].msgs_to_ignore.empty()) - hContact = (HANDLE)w; - else if(!hcontact_data[metaGetContact((HANDLE)w)].msgs_to_ignore.empty()) - hContact = metaGetContact((HANDLE)w); - if(hContact) - { - list::iterator end = hcontact_data[hContact].msgs_to_ignore.end(); - for(list::iterator p = hcontact_data[hContact].msgs_to_ignore.begin(); p != end; p++) - { - if(*p == (char*)dbei->pBlob) - { - hcontact_data[hContact].msgs_to_ignore.erase(p); - return 1; - } - } - } } HANDLE hContact = (HANDLE)w; - - - if(metaIsProtoMetaContacts(hContact)) - hContact = metaGetCurrent(hContact); - if(!DBGetContactSettingByte(hContact, szGPGModuleName, "GPGEncryption", 0)) - return 0; - - if(bAppendTags) + if(isContactSecured(hContact) && (dbei->flags & DBEF_SENT)) //aggressive outgoing events filtering { - if((dbei->eventType == EVENTTYPE_MESSAGE) && (dbei->flags & DBEF_SENT)) + if(!hcontact_data[hContact].msgs_to_pass.empty()) { - if(!hcontact_data[hContact].msgs_to_tag.empty()) + event_processing_mutex.lock(); + std::list::iterator end = hcontact_data[hContact].msgs_to_pass.end(); + for(std::list::iterator i = hcontact_data[hContact].msgs_to_pass.begin(); i != end; ++i) { - std::list::iterator end = hcontact_data[hContact].msgs_to_tag.end(); - for(std::list::iterator i = hcontact_data[hContact].msgs_to_tag.begin(); i != end; ++i) + if(!strcmp((*i).c_str(), (char*)dbei->pBlob)) { - if(*i == (char*)dbei->pBlob) - { - char *msg = (char*)dbei->pBlob; - wstring str = toUTF16(msg); - str.insert(0, outopentag); - str.append(outclosetag); - char *msg2 = mir_strdup(toUTF8(str).c_str()); - mir_free(dbei->pBlob); - dbei->pBlob = (PBYTE)msg2; - dbei->cbBlob = strlen(msg2)+1; - hcontact_data[hContact].msgs_to_tag.erase(i); - break; - } + hcontact_data[hContact].msgs_to_pass.erase(i); + event_processing_mutex.unlock(); + return 0; } } + event_processing_mutex.unlock(); } + return 1; } - if((dbei->eventType == EVENTTYPE_MESSAGE) && !(dbei->flags & DBEF_SENT) && metaIsProtoMetaContacts((HANDLE)w)) + if(!DBGetContactSettingByte(hContact, szGPGModuleName, "GPGEncryption", 0)) + return 0; + if(!(dbei->flags & DBEF_SENT) && metaIsProtoMetaContacts((HANDLE)w)) { char tmp[29]; strncpy(tmp, (char*)dbei->pBlob, 27); @@ -883,11 +872,6 @@ int HookSendMsg(WPARAM w, LPARAM l) return 0; } -int TestHook(WPARAM w, LPARAM l) -{ - return 0; -} - static BOOL CALLBACK DlgProcKeyPassword(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { -- cgit v1.2.3 From 5f55dcc2e10098ac93710d13176939e4c30d5b5f Mon Sep 17 00:00:00 2001 From: Gluzskiy Alexandr Date: Tue, 22 Mar 2011 17:04:43 +0200 Subject: thread safety (incompete) --- messages.cpp | 62 +++++++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 43 insertions(+), 19 deletions(-) (limited to 'messages.cpp') diff --git a/messages.cpp b/messages.cpp index 05d138a..6875ece 100644 --- a/messages.cpp +++ b/messages.cpp @@ -19,18 +19,16 @@ wstring new_key; HANDLE new_key_hcnt = NULL; -boost::mutex new_key_hcnt_mutex; +boost::mutex new_key_hcnt_mutex, gpg_file_mutex; bool _terminate = false; int returnNoError(HANDLE hContact); int RecvMsgSvc_func(HANDLE hContact, char *msg, DWORD flags) -{ +{ + DWORD dbflags = DBEF_UTF; { //check for gpg related data wstring str = toUTF16(msg); wstring::size_type s1 = wstring::npos, s2 = wstring::npos; - DWORD dbflags = 0; - if(flags & PREF_UTF) - flags |= DBEF_UTF; if((str.find(_T("-----PGP KEY RESPONSE-----")) != wstring::npos) && !metaIsProtoMetaContacts(hContact)) { @@ -54,7 +52,10 @@ int RecvMsgSvc_func(HANDLE hContact, char *msg, DWORD flags) _tcscat(tmp2, _T("\\")); _tcscat(tmp2, _T("temporary_exported.asc")); DeleteFile(tmp2); + gpg_file_mutex.timed_lock(boost::posix_time::minutes(1)); wfstream f(tmp2, std::ios::out); + while(!f.is_open()) + f.open(tmp2, std::ios::out); ptmp = UniGetContactSettingUtf(hContact, szGPGModuleName, "GPGPubKey", _T("")); wstring new_key = ptmp; mir_free(ptmp); @@ -78,13 +79,16 @@ int RecvMsgSvc_func(HANDLE hContact, char *msg, DWORD flags) gpg_thread.~thread(); debuglog< Date: Wed, 23 Mar 2011 12:18:19 +0200 Subject: modified: init.cpp modified: messages.cpp modified: new_gpg.rc --- messages.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'messages.cpp') diff --git a/messages.cpp b/messages.cpp index 6875ece..3cb59c0 100644 --- a/messages.cpp +++ b/messages.cpp @@ -52,7 +52,8 @@ int RecvMsgSvc_func(HANDLE hContact, char *msg, DWORD flags) _tcscat(tmp2, _T("\\")); _tcscat(tmp2, _T("temporary_exported.asc")); DeleteFile(tmp2); - gpg_file_mutex.timed_lock(boost::posix_time::minutes(1)); + while(!gpg_file_mutex.timed_lock(boost::posix_time::seconds(15))) + gpg_file_mutex.unlock(); wfstream f(tmp2, std::ios::out); while(!f.is_open()) f.open(tmp2, std::ios::out); @@ -312,7 +313,8 @@ int RecvMsgSvc_func(HANDLE hContact, char *msg, DWORD flags) wstring path = tmp2; path.append(_T("\\encrypted_data.asc")); DeleteFile(path.c_str()); - gpg_file_mutex.timed_lock(boost::posix_time::minutes(1)); + while(!gpg_file_mutex.timed_lock(boost::posix_time::seconds(15))) + gpg_file_mutex.unlock(); fstream f(path.c_str(), std::ios::out); while(!f.is_open()) f.open(path.c_str(), std::ios::out); @@ -500,7 +502,8 @@ int RecvMsgSvc_func(HANDLE hContact, char *msg, DWORD flags) wstring path = tmp2; mir_free(tmp2); path += _T("\\decrypted_data"); - gpg_file_mutex.timed_lock(boost::posix_time::minutes(1)); + while(!gpg_file_mutex.timed_lock(boost::posix_time::seconds(15))) + gpg_file_mutex.unlock(); fstream f(path.c_str(), std::ios::in | std::ios::ate | std::ios::binary); if(f.is_open()) { @@ -642,7 +645,8 @@ int SendMsgSvc_func(HANDLE hContact, char *msg, DWORD flags) { char *tmp; tmp = mir_strdup(toUTF8(str).c_str()); - gpg_file_mutex.timed_lock(boost::posix_time::minutes(1)); + while(!gpg_file_mutex.timed_lock(boost::posix_time::seconds(15))) + gpg_file_mutex.unlock(); fstream f(path.c_str(), std::ios::out); while(!f.is_open()) f.open(path.c_str(), std::ios::out); @@ -840,7 +844,7 @@ int SendMsgSvc(WPARAM w, LPARAM l) return CallService(MS_PROTO_CHAINSEND, w, l); } } - if(metaIsProtoMetaContacts(ccs->hContact)) + if(metaIsProtoMetaContacts(ccs->hContact) || !isContactSecured(ccs->hContact)) { mir_free(msg); return CallService(MS_PROTO_CHAINSEND, w, l); -- cgit v1.2.3 From c5e0140f26c8f95a1f83f1e2c86e1eb11820e901 Mon Sep 17 00:00:00 2001 From: Gluzskiy Alexandr Date: Thu, 24 Mar 2011 04:47:22 +0200 Subject: modified: messages.cpp modified: utilities.cpp --- messages.cpp | 483 +++++++++++++++++++++++++++++------------------------------ 1 file changed, 234 insertions(+), 249 deletions(-) (limited to 'messages.cpp') diff --git a/messages.cpp b/messages.cpp index 3cb59c0..ef6cf97 100644 --- a/messages.cpp +++ b/messages.cpp @@ -23,244 +23,12 @@ boost::mutex new_key_hcnt_mutex, gpg_file_mutex; bool _terminate = false; int returnNoError(HANDLE hContact); -int RecvMsgSvc_func(HANDLE hContact, char *msg, DWORD flags) +int RecvMsgSvc_func(HANDLE hContact, std::wstring str, char *msg, DWORD flags) { DWORD dbflags = DBEF_UTF; { //check for gpg related data - wstring str = toUTF16(msg); wstring::size_type s1 = wstring::npos, s2 = wstring::npos; - if((str.find(_T("-----PGP KEY RESPONSE-----")) != wstring::npos) && !metaIsProtoMetaContacts(hContact)) - { - 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) - { - s2 += _tcslen(_T("-----END PGP PUBLIC KEY BLOCK-----")); - DBWriteContactSettingTString(hContact, szGPGModuleName, "GPGPubKey", str.substr(s1,s2-s1).c_str()); - DBWriteContactSettingByte(hContact, szGPGModuleName, "GPGEncryption", 1); - { //gpg execute block - wstring cmd; - TCHAR tmp2[MAX_PATH] = {0}; - TCHAR *ptmp; - string output; - DWORD exitcode; - { - ptmp = UniGetContactSettingUtf(NULL, szGPGModuleName, "szHomePath", _T("")); - _tcscpy(tmp2, ptmp); - mir_free(ptmp); - _tcscat(tmp2, _T("\\")); - _tcscat(tmp2, _T("temporary_exported.asc")); - DeleteFile(tmp2); - while(!gpg_file_mutex.timed_lock(boost::posix_time::seconds(15))) - gpg_file_mutex.unlock(); - wfstream f(tmp2, std::ios::out); - while(!f.is_open()) - f.open(tmp2, std::ios::out); - ptmp = UniGetContactSettingUtf(hContact, szGPGModuleName, "GPGPubKey", _T("")); - wstring new_key = ptmp; - mir_free(ptmp); - f< output.find("<", s)) - s2 = output.find("<", s); - tmp = new char [output.substr(s,s2-s-1).length()+1]; - strcpy(tmp, output.substr(s,s2-s-1).c_str()); - mir_utf8decode(tmp, 0); - DBWriteContactSettingString(hContact, szGPGModuleName, "KeyMainName", tmp); - mir_free(tmp); - if((s = output.find(")", s2)) == string::npos) - s = output.find(">", s2); - else if(s > output.find(">", s2)) - s = output.find(">", s2); - s2++; - if(output[s] == ')') - { - tmp = new char [output.substr(s2,s-s2).length()+1]; - strcpy(tmp, output.substr(s2,s-s2).c_str()); - mir_utf8decode(tmp, 0); - DBWriteContactSettingString(hContact, szGPGModuleName, "KeyComment", tmp); - mir_free(tmp); - s+=3; - s2 = output.find(">", s); - tmp = new char [output.substr(s,s2-s).length()+1]; - strcpy(tmp, output.substr(s,s2-s).c_str()); - mir_utf8decode(tmp, 0); - DBWriteContactSettingString(hContact, szGPGModuleName, "KeyMainEmail", tmp); - mir_free(tmp); - } - else - { - tmp = new char [output.substr(s2,s-s2).length()+1]; - strcpy(tmp, output.substr(s2,s-s2).c_str()); - mir_utf8decode(tmp, 0); - DBWriteContactSettingString(hContact, szGPGModuleName, "KeyMainEmail", output.substr(s2,s-s2).c_str()); - mir_free(tmp); - } - DBWriteContactSettingByte(hContact, szGPGModuleName, "bAlwatsTrust", 1); - void setSrmmIcon(HANDLE); - void setClistIcon(HANDLE); - setSrmmIcon(hContact); - setClistIcon(hContact); - if(metaIsSubcontact(hContact)) - { - setSrmmIcon(metaGetContact(hContact)); - setClistIcon(metaGetContact(hContact)); - HistoryLog(metaGetContact(hContact), "PGP Encryption turned on by key autoexchange feature", EVENTTYPE_MESSAGE, 0); - } - HistoryLog(hContact, "PGP Encryption turned on by key autoexchange feature", EVENTTYPE_MESSAGE, 0); - } - } - mir_free(msg); - return 1; - } - } - if((str.find(_T("-----END PGP PUBLIC KEY BLOCK-----")) != wstring::npos) && (str.find(_T("-----BEGIN PGP PUBLIC KEY BLOCK-----")) != wstring::npos)) - { - s2 = str.find(_T("-----END PGP PUBLIC KEY BLOCK-----")); - s1 = str.find(_T("-----BEGIN PGP PUBLIC KEY BLOCK-----")); - } - else if((str.find(_T("-----BEGIN PGP PRIVATE KEY BLOCK-----")) != wstring::npos) && (str.find(_T("-----END PGP PRIVATE KEY BLOCK-----")) != wstring::npos)) - { - s2 = str.find(_T("-----END PGP PRIVATE KEY BLOCK-----")); - s1 = str.find(_T("-----BEGIN PGP PRIVATE KEY BLOCK-----")); - } - if((s2 != wstring::npos) && (s1 != wstring::npos)) - { //this is public key - if(metaIsSubcontact(hContact)) - { - HistoryLog(hContact, msg, EVENTTYPE_MESSAGE, dbflags); - mir_free(msg); - return 0; - } - debuglog< Accounts; - list::iterator end = Accounts.end(); - for(list::iterator p = Accounts.begin(); p != end; p++) - { - TCHAR *caps = (*p)->getJabberInterface()->Net()->GetResourceFeatures(jid); - if(caps) - { - wstring str; - for(int i =0;;i++) - { - str.push_back(caps[i]); - if(caps[i] == '\0') - if(caps[i+1] == '\0') - break; - } - mir_free(caps); - if(str.find(_T("GPG_Key_Auto_Exchange:0")) != string::npos) - CallContactService(hContact, PSS_MESSAGE, (WPARAM)0, (LPARAM)"-----PGP KEY REQUEST-----"); - } - } - } - } - } - mir_free(msg); - return 1; - } s1 = str.find(_T("-----BEGIN PGP MESSAGE-----")); s2 = str.find(_T("-----END PGP MESSAGE-----")); if((s2 != wstring::npos) && (s1 != wstring::npos)) @@ -298,7 +66,6 @@ int RecvMsgSvc_func(HANDLE hContact, 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); - mir_free(msg); return 0; } } @@ -388,7 +155,6 @@ int RecvMsgSvc_func(HANDLE hContact, char *msg, DWORD flags) debuglog<lParam); if (!pre) return CallService(MS_PROTO_CHAINRECV, w, l); - char *msg = mir_strdup(pre->szMessage); + char *msg = pre->szMessage; if (!msg) return CallService(MS_PROTO_CHAINRECV, w, l); - boost::thread *thr = new boost::thread(boost::bind(RecvMsgSvc_func, ccs->hContact, msg, ccs->wParam)); + wstring str = toUTF16(msg); + wstring::size_type s1 = wstring::npos, s2 = wstring::npos; + DWORD dbflags = DBEF_UTF; + if((str.find(_T("-----PGP KEY RESPONSE-----")) != wstring::npos) && !metaIsProtoMetaContacts(ccs->hContact)) + { + 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) + { + s2 += _tcslen(_T("-----END PGP PUBLIC KEY BLOCK-----")); + DBWriteContactSettingTString(ccs->hContact, szGPGModuleName, "GPGPubKey", str.substr(s1,s2-s1).c_str()); + DBWriteContactSettingByte(ccs->hContact, szGPGModuleName, "GPGEncryption", 1); + { //gpg execute block + wstring cmd; + TCHAR tmp2[MAX_PATH] = {0}; + TCHAR *ptmp; + string output; + DWORD exitcode; + { + ptmp = UniGetContactSettingUtf(NULL, szGPGModuleName, "szHomePath", _T("")); + _tcscpy(tmp2, ptmp); + mir_free(ptmp); + _tcscat(tmp2, _T("\\")); + _tcscat(tmp2, _T("temporary_exported.asc")); + DeleteFile(tmp2); + while(!gpg_file_mutex.timed_lock(boost::posix_time::seconds(15))) + gpg_file_mutex.unlock(); + wfstream f(tmp2, std::ios::out); + while(!f.is_open()) + f.open(tmp2, std::ios::out); + ptmp = UniGetContactSettingUtf(ccs->hContact, szGPGModuleName, "GPGPubKey", _T("")); + wstring new_key = ptmp; + mir_free(ptmp); + f<hContact, szGPGModuleName, "KeyID", output.substr(s,s2-s).c_str()); + s2+=2; + s = output.find("“", s2); + if(s == string::npos) + { + s = output.find("\"", s2); + s += 1; + } + else + s += 3; + if((s2 = output.find("(", s)) == string::npos) + s2 = output.find("<", s); + else if(s2 > output.find("<", s)) + s2 = output.find("<", s); + tmp = new char [output.substr(s,s2-s-1).length()+1]; + strcpy(tmp, output.substr(s,s2-s-1).c_str()); + mir_utf8decode(tmp, 0); + DBWriteContactSettingString(ccs->hContact, szGPGModuleName, "KeyMainName", tmp); + mir_free(tmp); + if((s = output.find(")", s2)) == string::npos) + s = output.find(">", s2); + else if(s > output.find(">", s2)) + s = output.find(">", s2); + s2++; + if(output[s] == ')') + { + tmp = new char [output.substr(s2,s-s2).length()+1]; + strcpy(tmp, output.substr(s2,s-s2).c_str()); + mir_utf8decode(tmp, 0); + DBWriteContactSettingString(ccs->hContact, szGPGModuleName, "KeyComment", tmp); + mir_free(tmp); + s+=3; + s2 = output.find(">", s); + tmp = new char [output.substr(s,s2-s).length()+1]; + strcpy(tmp, output.substr(s,s2-s).c_str()); + mir_utf8decode(tmp, 0); + DBWriteContactSettingString(ccs->hContact, szGPGModuleName, "KeyMainEmail", tmp); + mir_free(tmp); + } + else + { + tmp = new char [output.substr(s2,s-s2).length()+1]; + strcpy(tmp, output.substr(s2,s-s2).c_str()); + mir_utf8decode(tmp, 0); + DBWriteContactSettingString(ccs->hContact, szGPGModuleName, "KeyMainEmail", output.substr(s2,s-s2).c_str()); + mir_free(tmp); + } + DBWriteContactSettingByte(ccs->hContact, szGPGModuleName, "bAlwatsTrust", 1); + void setSrmmIcon(HANDLE); + void setClistIcon(HANDLE); + setSrmmIcon(ccs->hContact); + setClistIcon(ccs->hContact); + if(metaIsSubcontact(ccs->hContact)) + { + setSrmmIcon(metaGetContact(ccs->hContact)); + setClistIcon(metaGetContact(ccs->hContact)); + HistoryLog(metaGetContact(ccs->hContact), "PGP Encryption turned on by key autoexchange feature", EVENTTYPE_MESSAGE, 0); + } + HistoryLog(ccs->hContact, "PGP Encryption turned on by key autoexchange feature", EVENTTYPE_MESSAGE, 0); + } + } + return 1; + } + } + if((str.find(_T("-----END PGP PUBLIC KEY BLOCK-----")) != wstring::npos) && (str.find(_T("-----BEGIN PGP PUBLIC KEY BLOCK-----")) != wstring::npos)) + { + s2 = str.find(_T("-----END PGP PUBLIC KEY BLOCK-----")); + s1 = str.find(_T("-----BEGIN PGP PUBLIC KEY BLOCK-----")); + } + else if((str.find(_T("-----BEGIN PGP PRIVATE KEY BLOCK-----")) != wstring::npos) && (str.find(_T("-----END PGP PRIVATE KEY BLOCK-----")) != wstring::npos)) + { + s2 = str.find(_T("-----END PGP PRIVATE KEY BLOCK-----")); + s1 = str.find(_T("-----BEGIN PGP PRIVATE KEY BLOCK-----")); + } + if((s2 != wstring::npos) && (s1 != wstring::npos)) + { //this is public key + if(metaIsSubcontact(ccs->hContact)) + { + HistoryLog(ccs->hContact, msg, EVENTTYPE_MESSAGE, dbflags); + return 0; + } + debuglog<hContact, GCDNF_TCHAR)<<"\n"; + s1 = 0; + while((s1 = str.find(_T("\r"), s1)) != wstring::npos) + { + str.erase(s1, 1); + } + void ShowNewKeyDialog(); + if((str.find(_T("-----END PGP PUBLIC KEY BLOCK-----")) != wstring::npos) && (str.find(_T("-----BEGIN PGP PUBLIC KEY BLOCK-----")) != wstring::npos)) + { + s2 = str.find(_T("-----END PGP PUBLIC KEY BLOCK-----")); + s1 = str.find(_T("-----BEGIN PGP PUBLIC KEY BLOCK-----")); + s2 += _tcslen(_T("-----END PGP PUBLIC KEY BLOCK-----")); + } + else if((str.find(_T("-----BEGIN PGP PRIVATE KEY BLOCK-----")) != wstring::npos) && (str.find(_T("-----END PGP PRIVATE KEY BLOCK-----")) != wstring::npos)) + { + s2 = str.find(_T("-----END PGP PRIVATE KEY BLOCK-----")); + s1 = str.find(_T("-----BEGIN PGP PRIVATE KEY BLOCK-----")); + s2 += _tcslen(_T("-----END PGP PRIVATE KEY BLOCK-----")); + } + new_key.append(str.substr(s1,s2-s1)); + new_key_hcnt_mutex.lock(); + new_key_hcnt = ccs->hContact; + ShowNewKeyDialog(); + HistoryLog(ccs->hContact, msg, EVENTTYPE_MESSAGE, dbflags); + return 0; + } + if(bAutoExchange && strstr(msg, "-----PGP KEY REQUEST-----") && isGPGConfigured()) + { + char *tmp = UniGetContactSettingUtf(NULL, szGPGModuleName, "GPGPubKey", ""); + if(tmp[0]) + { + DBWriteContactSettingByte(ccs->hContact, szGPGModuleName, "GPGEncryption", 0); + string str = "-----PGP KEY RESPONSE-----"; + str.append(tmp); + CallContactService(ccs->hContact, PSS_MESSAGE, (WPARAM)PREF_UTF, (LPARAM)str.c_str()); + DBWriteContactSettingByte(ccs->hContact, szGPGModuleName, "GPGEncryption", 1); + } + mir_free(tmp); + if(!isContactHaveKey(ccs->hContact) && bAutoExchange && isGPGConfigured()) + { + LPSTR proto = (LPSTR)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)ccs->hContact, 0); + DWORD uin = DBGetContactSettingDword(ccs->hContact, proto, "UIN", 0); + if(uin) + { + if(ServiceExists("ICQ"PS_ICQ_CHECKCAPABILITY)) + { + ICQ_CUSTOMCAP cap = {0}; + strcpy(cap.caps, "GPG AutoExchange"); + if(CallService("ICQ"PS_ICQ_CHECKCAPABILITY, (WPARAM)ccs->hContact, (LPARAM)&cap)) + CallContactService(ccs->hContact, PSS_MESSAGE, (WPARAM)PREF_UTF, (LPARAM)"-----PGP KEY REQUEST-----"); + } + } + else + { + TCHAR *jid = UniGetContactSettingUtf(ccs->hContact, proto, "jid", _T("")); + if(jid[0]) + { + extern list Accounts; + list::iterator end = Accounts.end(); + for(list::iterator p = Accounts.begin(); p != end; p++) + { + TCHAR *caps = (*p)->getJabberInterface()->Net()->GetResourceFeatures(jid); + if(caps) + { + wstring str; + for(int i =0;;i++) + { + str.push_back(caps[i]); + if(caps[i] == '\0') + if(caps[i+1] == '\0') + break; + } + mir_free(caps); + if(str.find(_T("GPG_Key_Auto_Exchange:0")) != string::npos) + CallContactService(ccs->hContact, PSS_MESSAGE, (WPARAM)0, (LPARAM)"-----PGP KEY REQUEST-----"); + } + } + } + } + } + return 1; + } + 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)); return returnNoError(ccs->hContact); } @@ -887,7 +872,7 @@ int HookSendMsg(WPARAM w, LPARAM l) } return 1; } - if(!DBGetContactSettingByte(hContact, szGPGModuleName, "GPGEncryption", 0)) + if(!isContactSecured(hContact)) return 0; if(!(dbei->flags & DBEF_SENT) && metaIsProtoMetaContacts((HANDLE)w)) { -- cgit v1.2.3 From 8174eb73282e177112615c2dd332b69401959764 Mon Sep 17 00:00:00 2001 From: Gluzskiy Alexandr Date: Wed, 30 Mar 2011 08:51:28 +0300 Subject: one more threading variant (without mutexes) --- messages.cpp | 63 +++++++++++++++++++++--------------------------------------- 1 file changed, 22 insertions(+), 41 deletions(-) (limited to 'messages.cpp') diff --git a/messages.cpp b/messages.cpp index ef6cf97..3426b5e 100644 --- a/messages.cpp +++ b/messages.cpp @@ -19,7 +19,7 @@ wstring new_key; HANDLE new_key_hcnt = NULL; -boost::mutex new_key_hcnt_mutex, gpg_file_mutex; +boost::mutex new_key_hcnt_mutex; bool _terminate = false; int returnNoError(HANDLE hContact); @@ -78,10 +78,11 @@ int RecvMsgSvc_func(HANDLE hContact, std::wstring str, char *msg, DWORD flags) char *tmp = mir_t2a(str.substr(s1,s2-s1).c_str()); TCHAR *tmp2 = UniGetContactSettingUtf(NULL, szGPGModuleName, "szHomePath", _T("")); wstring path = tmp2; - path.append(_T("\\encrypted_data.asc")); + wstring encfile = toUTF16(get_random(10)); + wstring decfile = toUTF16(get_random(10)); + path.append(_T("\\tmp\\")); + path.append(encfile); DeleteFile(path.c_str()); - while(!gpg_file_mutex.timed_lock(boost::posix_time::seconds(15))) - gpg_file_mutex.unlock(); fstream f(path.c_str(), std::ios::out); while(!f.is_open()) f.open(path.c_str(), std::ios::out); @@ -132,12 +133,15 @@ int RecvMsgSvc_func(HANDLE hContact, std::wstring str, char *msg, DWORD flags) } { wstring path = tmp2; - path += _T("\\decrypted_data"); + path += _T("\\tmp\\"); + path += decfile; DeleteFile(path.c_str()); } cmd += _T("--output \""); cmd += tmp2; - cmd += _T("\\decrypted_data\""); + cmd += _T("\\tmp\\"); + cmd += decfile; + cmd += _T("\""); cmd += _T(" -d -a \""); cmd += path; cmd += _T("\""); @@ -155,14 +159,12 @@ int RecvMsgSvc_func(HANDLE hContact, std::wstring str, char *msg, DWORD flags) debuglog< Date: Wed, 30 Mar 2011 09:36:35 +0300 Subject: some agression ) --- messages.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'messages.cpp') diff --git a/messages.cpp b/messages.cpp index 3426b5e..226445a 100644 --- a/messages.cpp +++ b/messages.cpp @@ -156,6 +156,7 @@ int RecvMsgSvc_func(HANDLE hContact, std::wstring str, char *msg, DWORD flags) if(!gpg_thread->timed_join(boost::posix_time::seconds(10))) { delete gpg_thread; + TerminateProcess(params.hProcess, 1); debuglog<timed_join(boost::posix_time::seconds(10))) { delete gpg_thread; + TerminateProcess(params.hProcess, 1); debuglog<timed_join(boost::posix_time::seconds(10))) { delete gpg_thread; + TerminateProcess(params.hProcess, 1); debuglog< Date: Thu, 31 Mar 2011 20:32:41 +0300 Subject: fixed another metacontacts problem, optimized some functions --- messages.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'messages.cpp') diff --git a/messages.cpp b/messages.cpp index 226445a..e1b3bdf 100644 --- a/messages.cpp +++ b/messages.cpp @@ -820,6 +820,7 @@ int SendMsgSvc(WPARAM w, LPARAM l) { mir_free(msg); return CallService(MS_PROTO_CHAINSEND, w, l); +// return returnNoError(ccs->hContact); } boost::thread *thr = new boost::thread(boost::bind(SendMsgSvc_func, ccs->hContact, msg, (DWORD)ccs->wParam)); return returnNoError(ccs->hContact); -- cgit v1.2.3 From 089c1fb6bcbdb5ea07419486b78da9c3e120ee9c Mon Sep 17 00:00:00 2001 From: Gluzskiy Alexandr Date: Fri, 1 Apr 2011 01:28:48 +0300 Subject: ) --- messages.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'messages.cpp') diff --git a/messages.cpp b/messages.cpp index e1b3bdf..226445a 100644 --- a/messages.cpp +++ b/messages.cpp @@ -820,7 +820,6 @@ int SendMsgSvc(WPARAM w, LPARAM l) { mir_free(msg); return CallService(MS_PROTO_CHAINSEND, w, l); -// return returnNoError(ccs->hContact); } boost::thread *thr = new boost::thread(boost::bind(SendMsgSvc_func, ccs->hContact, msg, (DWORD)ccs->wParam)); return returnNoError(ccs->hContact); -- cgit v1.2.3 From 8cdda41b119526a2741938d57b7e066e1697315b Mon Sep 17 00:00:00 2001 From: Gluzskiy Alexandr Date: Fri, 1 Apr 2011 02:20:17 +0300 Subject: hm )) --- messages.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'messages.cpp') diff --git a/messages.cpp b/messages.cpp index 226445a..f7ea63f 100644 --- a/messages.cpp +++ b/messages.cpp @@ -36,7 +36,7 @@ int RecvMsgSvc_func(HANDLE hContact, std::wstring str, char *msg, DWORD flags) void setSrmmIcon(HANDLE); void setClistIcon(HANDLE); bool isContactHaveKey(HANDLE hContact); - if(!DBGetContactSettingByte(metaGetCurrent(hContact), szGPGModuleName, "GPGEncryption", 0)) + if(!DBGetContactSettingByte(metaGetMostOnline(hContact), szGPGModuleName, "GPGEncryption", 0)) { debuglog< 0) { @@ -179,7 +179,7 @@ int RecvMsgSvc_func(HANDLE hContact, std::wstring str, char *msg, DWORD flags) s = out.find(" ID ", s); s += strlen(" ID "); string::size_type s2 = out.find(",",s); - DBWriteContactSettingString(metaGetCurrent(hContact), szGPGModuleName, "InKeyID", out.substr(s, s2-s).c_str()); + DBWriteContactSettingString(metaGetMostOnline(hContact), szGPGModuleName, "InKeyID", out.substr(s, s2-s).c_str()); } void ShowLoadKeyPasswordWindow(); new_key_hcnt_mutex.lock(); @@ -313,7 +313,7 @@ int RecvMsgSvc_func(HANDLE hContact, std::wstring str, char *msg, DWORD flags) } } } - if(DBGetContactSettingByte(metaGetCurrent(hContact), szGPGModuleName, "GPGEncryption", 0)) + if(DBGetContactSettingByte(metaGetMostOnline(hContact), szGPGModuleName, "GPGEncryption", 0)) { if(metaIsSubcontact(hContact)) { -- cgit v1.2.3