diff options
author | Alexander Gluzsky <sss123next@list.ru> | 2012-08-22 03:08:17 +0000 |
---|---|---|
committer | Alexander Gluzsky <sss123next@list.ru> | 2012-08-22 03:08:17 +0000 |
commit | d1f33e658727c85581f40579f4aa0ef8f512c0fe (patch) | |
tree | 0caa2435528973830e019e660085e2e84936e9d4 /plugins | |
parent | 7ba410935ead3bad52bec10a6970eaa5f4b4277c (diff) |
autoexchange fixes
db event filter fixes
git-svn-id: http://svn.miranda-ng.org/main/trunk@1518 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins')
-rwxr-xr-x | plugins/New_GPG/src/messages.cpp | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/plugins/New_GPG/src/messages.cpp b/plugins/New_GPG/src/messages.cpp index f551680c36..73522424d5 100755 --- a/plugins/New_GPG/src/messages.cpp +++ b/plugins/New_GPG/src/messages.cpp @@ -384,7 +384,7 @@ int RecvMsgSvc(WPARAM w, LPARAM l) 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)) + if(bAutoExchange && (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-----")); @@ -393,6 +393,7 @@ int RecvMsgSvc(WPARAM w, LPARAM l) 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); + DBWriteContactSettingByte(ccs->hContact, szGPGModuleName, "bViaAutoExchange", 1); { //gpg execute block wstring cmd; TCHAR tmp2[MAX_PATH] = {0}; @@ -554,11 +555,14 @@ int RecvMsgSvc(WPARAM w, LPARAM l) char *tmp = UniGetContactSettingUtf(NULL, szGPGModuleName, "GPGPubKey", ""); if(tmp[0]) { - DBWriteContactSettingByte(ccs->hContact, szGPGModuleName, "GPGEncryption", 0); + int enc_state = DBGetContactSettingByte(ccs->hContact, szGPGModuleName, "GPGEncryption", 0); + if(enc_state) + 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); + if(enc_state) + DBWriteContactSettingByte(ccs->hContact, szGPGModuleName, "GPGEncryption", 1); } mir_free(tmp); return returnNoError(ccs->hContact); @@ -671,6 +675,8 @@ void SendMsgSvc_func(HANDLE hContact, char *msg, DWORD flags) CallContactService(hContact, PSS_MESSAGE, (WPARAM)flags, (LPARAM)msg); return; } + if(DBGetContactSettingByte(hContact, szGPGModuleName, "bViaAutoExchange", 0)) + DBWriteContactSettingByte(hContact, szGPGModuleName, "bAlwaysTrust", 1); if(!bJabberAPI || !bIsMiranda09) //force jabber to handle encrypted message by itself cmd += _T("--comment \"\" --no-version "); if(DBGetContactSettingByte(hContact, szGPGModuleName, "bAlwaysTrust", 0)) @@ -909,8 +915,8 @@ int SendMsgSvc(WPARAM w, LPARAM l) 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::thread *thr = new boost::thread(boost::bind(SendMsgSvc_func, ccs->hContact, msg, (DWORD)ccs->wParam)); + return returnNoError(ccs->hContact); } boost::mutex event_processing_mutex; @@ -922,12 +928,14 @@ int HookSendMsg(WPARAM w, LPARAM l) DBEVENTINFO * dbei = (DBEVENTINFO*)l; if(dbei->eventType != EVENTTYPE_MESSAGE) return 0; + HANDLE hContact = (HANDLE)w; 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. + if(isContactSecured(hContact) && strstr((char*)dbei->pBlob, "-----BEGIN PGP MESSAGE-----")) //our service data, can be double added by metacontacts e.t.c. + 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 return 1; } - HANDLE hContact = (HANDLE)w; if(isContactSecured(hContact) && (dbei->flags & DBEF_SENT)) //aggressive outgoing events filtering { if(!hcontact_data[hContact].msgs_to_pass.empty()) |