From 81bac0208e177b647682b4d115fe47547cd43ab6 Mon Sep 17 00:00:00 2001 From: Gluzskiy Alexandr Date: Fri, 4 Jan 2013 20:28:34 +0200 Subject: implemented #83 --- src/globals.h | 2 +- src/init.cpp | 3 +- src/options.cpp | 6 ++++ src/resource.h | 7 ++++- src/utilities.cpp | 93 ++++++++++++++++++++++++++++++++++++++++++++++++++----- 5 files changed, 101 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/globals.h b/src/globals.h index e84ae1e..4e561d8 100755 --- a/src/globals.h +++ b/src/globals.h @@ -16,7 +16,7 @@ #ifndef GLOBALS_H #define GLOBALS_H -extern bool bAppendTags, bPresenceSigning, bStripTags, gpg_valid, gpg_keyexist, tabsrmm_used; +extern bool bAppendTags, bPresenceSigning, bStripTags, gpg_valid, gpg_keyexist, tabsrmm_used, bSameAction, bFileTransfers; extern TCHAR *inopentag, *inclosetag, *outopentag, *outclosetag; extern logtofile debuglog; #endif diff --git a/src/init.cpp b/src/init.cpp index e01fed2..3ef7c51 100755 --- a/src/init.cpp +++ b/src/init.cpp @@ -17,7 +17,7 @@ #include "commonheaders.h" //global variables -bool bAppendTags = false, bDebugLog = false, bJabberAPI = false, bPresenceSigning = false, bIsMiranda09 = false, bMetaContacts = false, bFileTransfers = false, bAutoExchange = false, bStripTags = false, tabsrmm_used = false; +bool bAppendTags = false, bDebugLog = false, bJabberAPI = false, bPresenceSigning = false, bIsMiranda09 = false, bMetaContacts = false, bFileTransfers = false, bSameAction = false, bAutoExchange = false, bStripTags = false, tabsrmm_used = false; TCHAR *inopentag = NULL, *inclosetag = NULL, *outopentag = NULL, *outclosetag = NULL, *password = NULL; list Accounts; @@ -90,6 +90,7 @@ void init_vars() outclosetag = UniGetContactSettingUtf(NULL, szGPGModuleName, "szOutCloseTag", _T("")); bDebugLog = DBGetContactSettingByte(NULL, szGPGModuleName, "bDebugLog", 0); bAutoExchange = DBGetContactSettingByte(NULL, szGPGModuleName, "bAutoExchange", 0); + bSameAction = DBGetContactSettingByte(NULL, szGPGModuleName, "bSameAction", 0); password = UniGetContactSettingUtf(NULL, szGPGModuleName, "szKeyPassword", _T("")); debuglog.init(); bIsMiranda09 = (DWORD)CallService(MS_SYSTEM_GETVERSION, 0, 0) >= 0x00090001?true:false; diff --git a/src/options.cpp b/src/options.cpp index 17a383f..6d44cd4 100755 --- a/src/options.cpp +++ b/src/options.cpp @@ -463,7 +463,13 @@ static INT_PTR CALLBACK DlgProcGpgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP if(bDebugLog) debuglog.init(); bJabberAPI = CheckStateStoreDB(hwndDlg, IDC_JABBER_API, "bJabberAPI"); + bool old_bFileTransfers = DBGetContactSettingByte(NULL, szGPGModuleName, "bFileTransfers", 0); bFileTransfers = CheckStateStoreDB(hwndDlg, IDC_FILE_TRANSFERS, "bFileTransfers"); + if(bFileTransfers != old_bFileTransfers) + { + DBWriteContactSettingByte(NULL, szGPGModuleName, "bSameAction", 0); + bSameAction = false; + } bAutoExchange = CheckStateStoreDB(hwndDlg, IDC_AUTO_EXCHANGE, "bAutoExchange"); { TCHAR tmp[512]; diff --git a/src/resource.h b/src/resource.h index 027e279..1135dbd 100755 --- a/src/resource.h +++ b/src/resource.h @@ -16,6 +16,7 @@ #define IDD_IMPORT_KEY 112 #define IDI_UNSECURED 113 #define IDD_OPT_GPG_ADVANCED 113 +#define IDD_ENCRYPTED_FILE_MSG_BOX 114 #define IDC_SET_BIN_PATH 1016 #define IDC_SET_HOME_DIR 1017 #define IDC_BIN_PATH 1018 @@ -38,6 +39,7 @@ #define IDC_IGNORE_KEY 1026 #define IDC_SELECT_EXISTING 1026 #define IDC_KEY_EMAIL 1026 +#define IDC_IGNORE 1026 #define IDC_DELETE_KEY_BUTTON 1027 #define IDC_IN_CLOSE_TAG 1027 #define IDC_KEY_REAL_NAME 1027 @@ -58,6 +60,7 @@ #define IDC_OTHER 1046 #define IDC_LOG_FILE_SET 1046 #define IDC_IMPORT 1046 +#define IDC_DECRYPT 1046 #define IDC_SAVE_PASSWORD 1047 #define IDC_DEBUG_LOG 1048 #define IDC_JABBER_API 1049 @@ -78,6 +81,8 @@ #define IDC_STRIP_TAGS 1067 #define IDC_CHECK1 1068 #define IDC_PRESCENSE_SUBSCRIPTION 1068 +#define IDC_REMEMBRE 1068 +#define IDC_REMEMBER 1068 #define IDC_GENERATING_KEY 1069 #define IDC_GENERATING_TEXT 1070 #define IDC_KEY_ID 1071 @@ -88,7 +93,7 @@ // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 114 +#define _APS_NEXT_RESOURCE_VALUE 115 #define _APS_NEXT_COMMAND_VALUE 40001 #define _APS_NEXT_CONTROL_VALUE 1073 #define _APS_NEXT_SYMED_VALUE 101 diff --git a/src/utilities.cpp b/src/utilities.cpp index a430964..ab9b776 100755 --- a/src/utilities.cpp +++ b/src/utilities.cpp @@ -328,14 +328,15 @@ int OnPreBuildContactMenu(WPARAM w, LPARAM l) list transfers; -extern bool bFileTransfers; + +DWORD file_msg_state = -1; int onProtoAck(WPARAM w, LPARAM l) { ACKDATA *ack=(ACKDATA*)l; CCSDATA *ccs=(CCSDATA*)ack->lParam; - if(ack->type == ACKTYPE_FILE && bFileTransfers) + if(ack->type == ACKTYPE_FILE) { switch(ack->result) { @@ -363,6 +364,15 @@ int onProtoAck(WPARAM w, LPARAM l) } if(_tcsstr(filename, _T(".gpg"))) //decrypt it { //process encrypted file + if(!bFileTransfers && !bSameAction) + { + void ShowEncryptedFileMsgBox(); + ShowEncryptedFileMsgBox(); + } + if(!bFileTransfers && bSameAction) + return 0; + if(file_msg_state < 1) + return 0; HistoryLog(ack->hContact, db_event("Recieved encrypted file, trying to decrypt", 0,0, 0)); if(_waccess(f->tszCurrentFile, 0) == -1) { @@ -473,7 +483,7 @@ int onProtoAck(WPARAM w, LPARAM l) } out.clear(); gpg_execution_params params; - pxResult result; + //pxResult result; params.cmd = &cmd2; params.useless = ""; params.out = &out; @@ -486,16 +496,17 @@ int onProtoAck(WPARAM w, LPARAM l) TerminateProcess(params.hProcess, 1); params.hProcess = NULL; debuglog<