summaryrefslogtreecommitdiff
path: root/messages.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'messages.cpp')
-rw-r--r--messages.cpp39
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);
}