summaryrefslogtreecommitdiff
path: root/messages.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'messages.cpp')
-rw-r--r--messages.cpp49
1 files changed, 47 insertions, 2 deletions
diff --git a/messages.cpp b/messages.cpp
index a0389a7..2e3c78f 100644
--- a/messages.cpp
+++ b/messages.cpp
@@ -263,7 +263,31 @@ int RecvMsgSvc(WPARAM w, LPARAM l)
if(!DBGetContactSettingByte(metaGetCurrent(hContact), szGPGModuleName, "GPGEncryption", 0))
{
debuglog<<time_str()<<": info: "<<"received message from: "<<(TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR)<<" whith tyrned off encryption\n";
- 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)
+ if(bAutoExchange)
+ {
+ if(!isContactHaveKey(hContact))
+ {
+ void ShowLoadPublicKeyDialog();
+ extern map<int, HANDLE> user_data;
+ extern int item_num;
+ item_num = 0; //black magic here
+ user_data[1] = hContact;
+ ShowLoadPublicKeyDialog();
+ }
+ else
+ {
+ DBWriteContactSettingByte(metaGetCurrent(hContact), szGPGModuleName, "GPGEncryption", 1);
+ setSrmmIcon(hContact);
+ setClistIcon(hContact);
+ }
+ if(isContactHaveKey(hContact))
+ {
+ DBWriteContactSettingByte(metaGetCurrent(hContact), szGPGModuleName, "GPGEncryption", 1);
+ setSrmmIcon(hContact);
+ setClistIcon(hContact);
+ }
+ }
+ else 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)
{
if(!isContactHaveKey(hContact))
{
@@ -682,7 +706,28 @@ int SendMsgSvc(WPARAM w, LPARAM l)
if(out.find("There is no assurance this key belongs to the named user") != string::npos)
{
out.clear();
- if(MessageBox(0, _T("We trying to encrypt with untrusted key, do you want to trust this key permanently ?"), _T("Warning"), MB_YESNO) == IDYES)
+ if(bAutoExchange)
+ {
+ DBWriteContactSettingByte(hContact, szGPGModuleName, "bAlwaysTrust", 1);
+ cmd.insert(0, _T("--trust-model always "));
+ gpg_execution_params params;
+ pxResult result;
+ params.cmd = &cmd;
+ params.useless = "";
+ params.out = &out;
+ params.code = &code;
+ params.result = &result;
+ boost::thread gpg_thread(boost::bind(&pxEexcute_thread, &params));
+ if(!gpg_thread.timed_join(boost::posix_time::seconds(10)))
+ {
+ gpg_thread.~thread();
+ debuglog<<time_str()<<": GPG execution timed out, aborted\n";
+ return CallService(MS_PROTO_CHAINSEND, w, l);
+ }
+ if(result == pxNotFound)
+ return CallService(MS_PROTO_CHAINSEND, w, l);
+ }
+ else if(MessageBox(0, _T("We trying to encrypt with untrusted key, do you want to trust this key permanently ?"), _T("Warning"), MB_YESNO) == IDYES)
{
DBWriteContactSettingByte(hContact, szGPGModuleName, "bAlwaysTrust", 1);
cmd.insert(0, _T("--trust-model always "));