diff options
-rw-r--r-- | main.cpp | 51 | ||||
-rw-r--r-- | messages.cpp | 49 | ||||
-rw-r--r-- | new_gpg.vcxproj | 2 |
3 files changed, 74 insertions, 28 deletions
@@ -1,4 +1,4 @@ -// Copyright © 2010 sss +// Copyright � 2010 sss // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License @@ -610,6 +610,7 @@ static BOOL CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP mir_free(tmp); if(gpg_exists && lang_exists && !bad_version) MessageBox(0, _T("You have supported version of gpg binary, and gpg language file in place!\ngpg plugin should work fine on your installation!\njust press ok in wollowing diallog."), _T("Info"), MB_OK); + CheckDlgButton(hwndDlg, IDC_AUTO_EXCHANGE, 1); extern bool bIsMiranda09; EnableWindow(GetDlgItem(hwndDlg, IDC_AUTO_EXCHANGE), bIsMiranda09); return TRUE; @@ -723,15 +724,15 @@ static BOOL CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP MessageBox(0, _T("please set keyring's home directory"), _T("Warning"), MB_OK); break; } - DBWriteContactSettingTString(NULL, szGPGModuleName, "szHomePath", tmp);
- {
- TCHAR *path = UniGetContactSettingUtf(NULL, szGPGModuleName, "szHomePath", _T(""));
- DWORD dwFileAttr = GetFileAttributes(path);
- if (dwFileAttr != INVALID_FILE_ATTRIBUTES)
- {
- dwFileAttr &=~ FILE_ATTRIBUTE_READONLY;
- SetFileAttributes(path, dwFileAttr);
- }
+ DBWriteContactSettingTString(NULL, szGPGModuleName, "szHomePath", tmp); + { + TCHAR *path = UniGetContactSettingUtf(NULL, szGPGModuleName, "szHomePath", _T("")); + DWORD dwFileAttr = GetFileAttributes(path); + if (dwFileAttr != INVALID_FILE_ATTRIBUTES) + { + dwFileAttr &=~ FILE_ATTRIBUTE_READONLY; + SetFileAttributes(path, dwFileAttr); + } mir_free(path); } gpg_configured = true; @@ -806,15 +807,15 @@ static BOOL CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP { MessageBox(0, _T("please set keyring's home directory"), _T("Warning"), MB_OK); break; - }
- DBWriteContactSettingTString(NULL, szGPGModuleName, "szHomePath", tmp);
- {
- TCHAR *path = UniGetContactSettingUtf(NULL, szGPGModuleName, "szHomePath", _T(""));
- DWORD dwFileAttr = GetFileAttributes(path);
- if (dwFileAttr != INVALID_FILE_ATTRIBUTES)
- {
- dwFileAttr &=~ FILE_ATTRIBUTE_READONLY;
- SetFileAttributes(path, dwFileAttr);
+ } + DBWriteContactSettingTString(NULL, szGPGModuleName, "szHomePath", tmp); + { + TCHAR *path = UniGetContactSettingUtf(NULL, szGPGModuleName, "szHomePath", _T("")); + DWORD dwFileAttr = GetFileAttributes(path); + if (dwFileAttr != INVALID_FILE_ATTRIBUTES) + { + dwFileAttr &=~ FILE_ATTRIBUTE_READONLY; + SetFileAttributes(path, dwFileAttr); } mir_free(path); } @@ -1730,12 +1731,12 @@ void InitCheck() if(MessageBoxA(0, question.c_str(), "Own secret key warning", MB_YESNO) == IDYES) ShowFirstRunDialog(); } - {
- TCHAR *path = UniGetContactSettingUtf(NULL, szGPGModuleName, "szHomePath", _T(""));
- DWORD dwFileAttr = GetFileAttributes(path);
- if (dwFileAttr != INVALID_FILE_ATTRIBUTES)
- {
- dwFileAttr &=~ FILE_ATTRIBUTE_READONLY;
+ { + TCHAR *path = UniGetContactSettingUtf(NULL, szGPGModuleName, "szHomePath", _T("")); + DWORD dwFileAttr = GetFileAttributes(path); + if (dwFileAttr != INVALID_FILE_ATTRIBUTES) + { + dwFileAttr &=~ FILE_ATTRIBUTE_READONLY; SetFileAttributes(path, dwFileAttr); } mir_free(path); diff --git a/messages.cpp b/messages.cpp index e8954e1..4f058b2 100644 --- a/messages.cpp +++ b/messages.cpp @@ -264,7 +264,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)) { @@ -677,7 +701,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, ¶ms)); + 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 ")); diff --git a/new_gpg.vcxproj b/new_gpg.vcxproj index 39bdf92..a0bec18 100644 --- a/new_gpg.vcxproj +++ b/new_gpg.vcxproj @@ -654,7 +654,7 @@ <Link>
<AdditionalDependencies>shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<SuppressStartupBanner>true</SuppressStartupBanner>
- <AdditionalLibraryDirectories>x:\temp\windows\libs\boost\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <AdditionalLibraryDirectories>C:\Boost\lib-release;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>false</GenerateDebugInformation>
<SubSystem>NotSet</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
|