diff options
author | Gluzskiy Alexandr <sss123next@list.ru> | 2010-08-24 00:30:00 +0300 |
---|---|---|
committer | Gluzskiy Alexandr <sss123next@list.ru> | 2010-08-24 00:30:00 +0300 |
commit | b9548a4f0c0c9315928814fb629f4e52fbebe66c (patch) | |
tree | 68b9c6b4ab01de2f3dfa4666adb67a9a3e12686c /messages.cpp | |
parent | 437e9f0426ef27117fce94646a13c33b76c13f54 (diff) |
modified: init.cpp
modified: messages.cpp
modified: new_gpg.rc
modified: new_gpg.vcproj
modified: options.cpp
modified: srmm.cpp
modified: utilities.cpp
Diffstat (limited to 'messages.cpp')
-rw-r--r-- | messages.cpp | 39 |
1 files changed, 38 insertions, 1 deletions
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<int, HANDLE> 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);
}
|