From 2ebd139da2e1abf4fa148012ce741870485229e8 Mon Sep 17 00:00:00 2001 From: "admin@progandy.co.cc" Date: Fri, 17 Sep 2010 15:05:43 +0000 Subject: - [ issue 13 ] added option to remove OTR system messages from history git-svn-id: http://mirotr.googlecode.com/svn/trunk@19 eced67a3-f377-a0ae-92ae-d6de1850b05a --- MirOTR/dbfilter.cpp | 39 +++++++++++++++++++++------------------ MirOTR/options.cpp | 12 ++++++++---- MirOTR/options.h | 3 ++- MirOTR/resource.h | 1 + MirOTR/resources/resource.rc | 9 +++++---- 5 files changed, 37 insertions(+), 27 deletions(-) diff --git a/MirOTR/dbfilter.cpp b/MirOTR/dbfilter.cpp index c93b168..58e3b6d 100644 --- a/MirOTR/dbfilter.cpp +++ b/MirOTR/dbfilter.cpp @@ -178,7 +178,7 @@ INT_PTR OnDatabaseEventPreAdd(WPARAM wParam, LPARAM lParam) { } INT_PTR OnDatabaseEventAdded(WPARAM wParam, LPARAM lParam) { - if(!options.no_history) return 0; + if(!options.delete_history) return 0; DBEVENTINFO info = {0}; info.cbSize = sizeof(info); @@ -193,24 +193,27 @@ INT_PTR OnDatabaseEventAdded(WPARAM wParam, LPARAM lParam) { if(info.eventType == EVENTTYPE_MESSAGE) { HANDLE hContact = (HANDLE)wParam; ConnContext *context = otrl_context_find_miranda(otr_user_state, hContact); - if (context && otr_context_get_trust(context) != TRUST_NOT_PRIVATE - && ( (info.flags&DBEF_UTF && !(info.cbBlob >lenutf && 0==strncmp((char*)info.pBlob, prefixutf, lenutf))) - || (!(info.flags&DBEF_UTF) && !(info.cbBlob >len && 0==strncmp((char*)info.pBlob, prefix, len))) + if (context && otr_context_get_trust(context) != TRUST_NOT_PRIVATE ) { + // only delete encrypted messages that are no OTR system messages + if ( options.delete_systeminfo || + ((info.flags&DBEF_UTF && !(info.cbBlob >lenutf && 0==strncmp((char*)info.pBlob, prefixutf, lenutf))) + || (!(info.flags&DBEF_UTF) && !(info.cbBlob >len && 0==strncmp((char*)info.pBlob, prefix, len))) ) - ) // only delete encrypted messages that are no OTR system messages - { - DeleteEventNode *node = new DeleteEventNode(); - node->hContact = hContact; - node->hDbEvent = (HANDLE) lParam; - node->timestamp = time(0); - node->next = 0; - EnterCriticalSection(lpRemoveChainCS); - if (DeleteEvents.last) - DeleteEvents.last->next = node; - else - DeleteEvents.first = node; - DeleteEvents.last = node; - LeaveCriticalSection(lpRemoveChainCS); + ) + { + DeleteEventNode *node = new DeleteEventNode(); + node->hContact = hContact; + node->hDbEvent = (HANDLE) lParam; + node->timestamp = time(0); + node->next = 0; + EnterCriticalSection(lpRemoveChainCS); + if (DeleteEvents.last) + DeleteEvents.last->next = node; + else + DeleteEvents.first = node; + DeleteEvents.last = node; + LeaveCriticalSection(lpRemoveChainCS); + } } } } diff --git a/MirOTR/options.cpp b/MirOTR/options.cpp index eb24ec0..3ba46dc 100644 --- a/MirOTR/options.cpp +++ b/MirOTR/options.cpp @@ -83,7 +83,8 @@ void LoadOptions() { options.prefix_messages = (DBGetContactSettingByte(0, MODULENAME, "PrefixMessages", 0) == 1); options.msg_inline = (DBGetContactSettingByte(0, MODULENAME, "MsgInline", 0) == 1); options.msg_popup = (DBGetContactSettingByte(0, MODULENAME, "MsgPopup", 1) == 1); - options.no_history = (DBGetContactSettingByte(0, MODULENAME, "NoHistory", 0) == 1); + options.delete_history = (DBGetContactSettingByte(0, MODULENAME, "NoHistory", 0) == 1); + options.delete_systeminfo = (DBGetContactSettingByte(0, MODULENAME, "NoSystemHistory", 0) == 1); options.autoshow_verify = (DBGetContactSettingByte(0, MODULENAME, "AutoShowVerify", 1) == 1); DBVARIANT dbv; @@ -158,7 +159,8 @@ void SaveOptions() { DBWriteContactSettingByte(0, MODULENAME, "MsgInline", options.msg_inline ? 1 : 0); DBWriteContactSettingByte(0, MODULENAME, "MsgPopup", options.msg_popup ? 1 : 0); - DBWriteContactSettingByte(0, MODULENAME, "NoHistory", options.no_history ? 1 : 0); + DBWriteContactSettingByte(0, MODULENAME, "NoHistory", options.delete_history ? 1 : 0); + DBWriteContactSettingByte(0, MODULENAME, "NoSystemHistory", options.delete_systeminfo ? 1 : 0); DBWriteContactSettingByte(0, MODULENAME, "AutoShowVerify", options.autoshow_verify ? 1 : 0); /* @@ -217,7 +219,8 @@ static INT_PTR CALLBACK DlgProcMirOTROpts(HWND hwndDlg, UINT msg, WPARAM wParam, CheckDlgButton(hwndDlg, IDC_CHK_MSGINLINE, options.msg_inline ? TRUE : FALSE); CheckDlgButton(hwndDlg, IDC_CHK_MSGPOPUP, options.msg_popup ? TRUE : FALSE); CheckDlgButton(hwndDlg, IDC_CHK_TIMEFINISH, options.timeout_finished ? TRUE : FALSE); - CheckDlgButton(hwndDlg, IDC_CHK_PREVENTSAVE, options.no_history ? TRUE : FALSE); + CheckDlgButton(hwndDlg, IDC_CHK_PREVENTSAVE, options.delete_history ? TRUE : FALSE); + CheckDlgButton(hwndDlg, IDC_CHK_PREVENTSYSSAVE, options.delete_systeminfo ? TRUE : FALSE); CheckDlgButton(hwndDlg, IDC_CHK_AUTOSHOW_VERIFY, options.autoshow_verify ? TRUE : FALSE); CheckDlgButton(hwndDlg, IDC_CHK_ENDOFFLINE, options.end_offline ? TRUE : FALSE); CheckDlgButton(hwndDlg, IDC_CHK_ENDCLOSE, options.end_window_close ? TRUE : FALSE); @@ -273,7 +276,8 @@ static INT_PTR CALLBACK DlgProcMirOTROpts(HWND hwndDlg, UINT msg, WPARAM wParam, options.msg_inline = (TRUE==IsDlgButtonChecked(hwndDlg, IDC_CHK_MSGINLINE)); options.msg_popup = (TRUE==IsDlgButtonChecked(hwndDlg, IDC_CHK_MSGPOPUP)); options.timeout_finished = (TRUE==IsDlgButtonChecked(hwndDlg, IDC_CHK_TIMEFINISH)); - options.no_history = (TRUE==IsDlgButtonChecked(hwndDlg, IDC_CHK_PREVENTSAVE)); + options.delete_history = (TRUE==IsDlgButtonChecked(hwndDlg, IDC_CHK_PREVENTSAVE)); + options.delete_systeminfo = (TRUE==IsDlgButtonChecked(hwndDlg, IDC_CHK_PREVENTSYSSAVE)); options.autoshow_verify = (TRUE==IsDlgButtonChecked(hwndDlg, IDC_CHK_AUTOSHOW_VERIFY)); options.end_offline = (TRUE==IsDlgButtonChecked(hwndDlg, IDC_CHK_ENDOFFLINE)); options.end_window_close = (TRUE==IsDlgButtonChecked(hwndDlg, IDC_CHK_ENDCLOSE)); diff --git a/MirOTR/options.h b/MirOTR/options.h index 64ca730..0e915e7 100644 --- a/MirOTR/options.h +++ b/MirOTR/options.h @@ -27,7 +27,8 @@ typedef struct { bool timeout_finished; - bool no_history; + bool delete_history; + bool delete_systeminfo; bool autoshow_verify; bool end_offline, end_window_close; diff --git a/MirOTR/resource.h b/MirOTR/resource.h index c810a6d..b861799 100644 --- a/MirOTR/resource.h +++ b/MirOTR/resource.h @@ -32,6 +32,7 @@ #define IDC_CHK_TIMEFINISH 1062 #define IDC_CHK_ENDOFFLINE 1063 #define IDC_CHK_ENDCLOSE 1064 +#define IDC_CHK_PREVENTSYSSAVE 1065 // Proto policy & keys #define IDC_LV_PROTO_PROTOS 1101 diff --git a/MirOTR/resources/resource.rc b/MirOTR/resources/resource.rc index eea7258..9ffb3dc 100644 --- a/MirOTR/resources/resource.rc +++ b/MirOTR/resources/resource.rc @@ -44,10 +44,11 @@ BEGIN CONTROL "Prefix encrypted IMs:",IDC_CHK_PREFIX,"Button",WS_VISIBLE|WS_TABSTOP|BS_AUTOCHECKBOX,12,94,108,10 CONTROL "",IDC_ED_PREFIX,"Edit",WS_CHILDWINDOW|WS_VISIBLE|WS_TABSTOP|ES_AUTOHSCROLL,120,93,159,12,WS_EX_CLIENTEDGE CONTROL "Don't add encrypted messages to the history",IDC_CHK_PREVENTSAVE,"Button",WS_VISIBLE|WS_TABSTOP|BS_AUTOCHECKBOX,12,106,265,10 - CONTROL "Show OTR system messages inline",IDC_CHK_MSGINLINE,"Button",WS_VISIBLE|WS_TABSTOP|BS_AUTOCHECKBOX,12,118,265,10 - CONTROL "Show OTR system messages as popup",IDC_CHK_MSGPOPUP,"Button",WS_VISIBLE|WS_TABSTOP|BS_AUTOCHECKBOX,12,130,265,10 - CONTROL "Timeout FINISHED sessions back to PLAINTEXT (TAKE CARE!)",IDC_CHK_TIMEFINISH,"Button",WS_VISIBLE|WS_TABSTOP|BS_AUTOCHECKBOX,12,142,265,10 - CONTROL "Show verification dialog when receiving unverified fingerprint",IDC_CHK_AUTOSHOW_VERIFY,"Button",WS_VISIBLE|WS_TABSTOP|BS_AUTOCHECKBOX,12,154,265,10 + CONTROL "Also remove OTR system messages",IDC_CHK_PREVENTSYSSAVE,"Button",WS_VISIBLE|WS_TABSTOP|BS_AUTOCHECKBOX,32,118,245,10 + CONTROL "Show OTR system messages inline",IDC_CHK_MSGINLINE,"Button",WS_VISIBLE|WS_TABSTOP|BS_AUTOCHECKBOX,12,130,265,10 + CONTROL "Show OTR system messages as popup",IDC_CHK_MSGPOPUP,"Button",WS_VISIBLE|WS_TABSTOP|BS_AUTOCHECKBOX,12,142,265,10 + CONTROL "Timeout FINISHED sessions back to PLAINTEXT (TAKE CARE!)",IDC_CHK_TIMEFINISH,"Button",WS_VISIBLE|WS_TABSTOP|BS_AUTOCHECKBOX,12,154,265,10 + CONTROL "Show verification dialog when receiving unverified fingerprint",IDC_CHK_AUTOSHOW_VERIFY,"Button",WS_VISIBLE|WS_TABSTOP|BS_AUTOCHECKBOX,12,166,265,10 END IDD_OPT_PROTO DIALOGEX 0,0,296,220 -- cgit v1.2.3