From b9548a4f0c0c9315928814fb629f4e52fbebe66c Mon Sep 17 00:00:00 2001 From: Gluzskiy Alexandr Date: Tue, 24 Aug 2010 00:30:00 +0300 Subject: modified: init.cpp modified: messages.cpp modified: new_gpg.rc modified: new_gpg.vcproj modified: options.cpp modified: srmm.cpp modified: utilities.cpp --- messages.cpp | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) (limited to 'messages.cpp') diff --git a/messages.cpp b/messages.cpp index ad87255..f7e0d9c 100644 --- a/messages.cpp +++ b/messages.cpp @@ -80,10 +80,36 @@ int RecvMsgSvc(WPARAM w, LPARAM l) s2 = str.find(_T("-----END PGP MESSAGE-----")); if((s2 != wstring::npos) && (s1 != wstring::npos)) { //this is generic encrypted data block + void setSrmmIcon(HANDLE); + void setClistIcon(HANDLE); + bool isContactHaveKey(HANDLE hContact); if(!DBGetContactSettingByte(ccs->hContact, szGPGModuleName, "GPGEncryption", 0)) { 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) - DBWriteContactSettingByte(ccs->hContact, szGPGModuleName, "GPGEncryption", 1); + { + if(!isContactHaveKey(ccs->hContact)) + { + void ShowLoadPublicKeyDialog(); + extern map user_data; + extern int item_num; + item_num = 0; //black magic here + user_data[1] = ccs->hContact; + ShowLoadPublicKeyDialog(); + } + else + { + DBWriteContactSettingByte(ccs->hContact, szGPGModuleName, "GPGEncryption", 1); + setSrmmIcon(ccs->hContact); + setClistIcon(ccs->hContact); + return 0; + } + if(isContactHaveKey(ccs->hContact)) + { + DBWriteContactSettingByte(ccs->hContact, szGPGModuleName, "GPGEncryption", 1); + setSrmmIcon(ccs->hContact); + setClistIcon(ccs->hContact); + } + } else if(MessageBox(0, _T("Do you want try to decrypt encrypted message ?"), _T("Warning"), MB_YESNO) == IDNO) return CallService(MS_PROTO_CHAINRECV, w, l); } @@ -222,6 +248,17 @@ int RecvMsgSvc(WPARAM w, LPARAM l) } } } + if(DBGetContactSettingByte(ccs->hContact, szGPGModuleName, "GPGEncryption", 0)) + { + wchar_t *tmp = mir_utf8decodeW(msg); + wstring str = tmp; + mir_free(tmp); + mir_free((void**)pre->szMessage); + str.insert(0, _T("Received unencrypted message:\n")); + char *utf = mir_utf8encodeW(str.c_str()); + pre->szMessage = utf; + return CallService(MS_PROTO_CHAINRECV, w, (LPARAM)ccs); + } return CallService(MS_PROTO_CHAINRECV, w, l); } -- cgit v1.2.3