From a02de2743a09366b17473f77567a8ca47a8db0d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Sch=C3=BCmann?= Date: Thu, 26 Mar 2015 20:39:16 +0000 Subject: MirOTR: ! fixed options dialog radio button grouping (resource.rc) ! fixed crash when trying to delete fingerprint in use (options.cpp) * changed default OTR prefix to one that cannot be faked by other parties and added note about this fact to options (options.cpp) + small improvement to options. Reset prefix to default if user enters an empty one (options.cpp) git-svn-id: http://svn.miranda-ng.org/main/trunk@12504 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/MirOTR/res/resource.rc | 20 ++++++++++---------- plugins/MirOTR/src/options.cpp | 20 ++++++++++++++++---- plugins/MirOTR/src/options.h | 2 ++ 3 files changed, 28 insertions(+), 14 deletions(-) (limited to 'plugins/MirOTR') diff --git a/plugins/MirOTR/res/resource.rc b/plugins/MirOTR/res/resource.rc index d6cb4a330f..710afcaa17 100644 --- a/plugins/MirOTR/res/resource.rc +++ b/plugins/MirOTR/res/resource.rc @@ -53,27 +53,27 @@ STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_VISIBLE EXSTYLE WS_EX_CONTROLPARENT FONT 8, "MS Shell Dlg", 0, 0, 0x1 BEGIN - LTEXT "",IDC_STATIC,0,0,1,1,NOT WS_GROUP | WS_TABSTOP GROUPBOX "Default Policy",IDC_GRP_POLICY,5,3,139,60 - CONTROL "Always",IDC_RAD_ALWAYS,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,12,12,126,10 - CONTROL "Opportunistic",IDC_RAD_OPP,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,12,24,126,10 - CONTROL "Manual",IDC_RAD_MANUAL,"Button",BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,12,36,126,10 - CONTROL "Never",IDC_RAD_NEVER,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,12,48,126,10 + CONTROL "Always",IDC_RAD_ALWAYS,"Button",BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,12,12,126,10 + CONTROL "Opportunistic",IDC_RAD_OPP,"Button",BS_AUTORADIOBUTTON,12,24,126,10 + CONTROL "Manual",IDC_RAD_MANUAL,"Button",BS_AUTORADIOBUTTON,12,36,126,10 + CONTROL "Never",IDC_RAD_NEVER,"Button",BS_AUTORADIOBUTTON,12,48,126,10 CONTROL "End sessions on window close",IDC_CHK_ENDCLOSE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,70,265,10 CONTROL "End sessions when contacts go offline",IDC_CHK_ENDOFFLINE, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,82,265,10 CONTROL "Prefix encrypted IMs:",IDC_CHK_PREFIX,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,94,108,10 EDITTEXT IDC_ED_PREFIX,120,93,159,12,ES_AUTOHSCROLL | NOT WS_BORDER,WS_EX_CLIENTEDGE + LTEXT """?OTR? "" is a protected prefix and can't be faked",IDC_STATIC,23,106,271,8,SS_LEFT CONTROL "Don't add encrypted messages to the history",IDC_CHK_PREVENTSAVE, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,106,265,10 + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,118,265,10 CONTROL "Also remove OTR system messages",IDC_CHK_PREVENTSYSSAVE, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,117,245,10 + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,130,245,10 CONTROL "Show OTR system messages inline",IDC_CHK_MSGINLINE, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,130,265,10 - CONTROL "Show OTR system messages as popup",IDC_CHK_MSGPOPUP, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,142,265,10 + CONTROL "Show OTR system messages as popup",IDC_CHK_MSGPOPUP, + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,154,265,10 CONTROL "Show verification dialog when receiving unverified fingerprint",IDC_CHK_AUTOSHOW_VERIFY, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,166,265,10 + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,175,265,10 END IDD_OPT_PROTO DIALOGEX 0, 0, 296, 220 diff --git a/plugins/MirOTR/src/options.cpp b/plugins/MirOTR/src/options.cpp index 89f2b49b46..c547d7afde 100644 --- a/plugins/MirOTR/src/options.cpp +++ b/plugins/MirOTR/src/options.cpp @@ -90,7 +90,7 @@ void LoadOptions() { options.prefix[OPTIONS_PREFIXLEN-1] = 0; db_free(&dbv); } else - strncpy(options.prefix, ("OTR: "), OPTIONS_PREFIXLEN-1); + strncpy(options.prefix, OPTIONS_DEFAULT_PREFIX, OPTIONS_PREFIXLEN-1); options.end_offline = (db_get_b(0, MODULENAME, "EndOffline", 1) == 1); options.end_window_close = (db_get_b(0, MODULENAME, "EndWindowClose", 0) == 1); @@ -265,7 +265,11 @@ static INT_PTR CALLBACK DlgProcMirOTROpts(HWND hwndDlg, UINT msg, WPARAM wParam, GetDlgItemText(hwndDlg, IDC_ED_PREFIX, prefix, OPTIONS_PREFIXLEN); prefix_utf = mir_utf8encodeT(prefix); mir_free(prefix); - strncpy(options.prefix, prefix_utf, OPTIONS_PREFIXLEN-1); + if(!prefix_utf[0]){ + SetDlgItemTextA(hwndDlg, IDC_ED_PREFIX, OPTIONS_DEFAULT_PREFIX); + strncpy(options.prefix, OPTIONS_DEFAULT_PREFIX, OPTIONS_PREFIXLEN-1); + } else + strncpy(options.prefix, prefix_utf, OPTIONS_PREFIXLEN-1); mir_free(prefix_utf); SaveOptions(); @@ -808,9 +812,13 @@ static INT_PTR CALLBACK DlgProcMirOTROptsFinger(HWND hwndDlg, UINT msg, WPARAM w ListView_GetItem(GetDlgItem(hwndDlg, IDC_LV_FINGER_LIST), &lvi); Fingerprint *fp = (Fingerprint*) lvi.lParam; if (fp->context->active_fingerprint == fp) { + MCONTACT hContact = (MCONTACT)fp->context->app_data; TCHAR buff[1024], hash[45]; otrl_privkey_hash_to_humanT(hash, fp->fingerprint); - mir_sntprintf(buff, SIZEOF(buff), TranslateT(LANG_FINGERPRINT_STILL_IN_USE), hash, contact_get_nameT((MCONTACT)fp->context->app_data)); + TCHAR *proto = mir_a2t(GetContactProto(hContact)); + mir_sntprintf(buff, SIZEOF(buff)-1, TranslateT(LANG_FINGERPRINT_STILL_IN_USE), hash, contact_get_nameT(hContact), proto); + mir_free(proto); + buff[SIZEOF(buff)-1] = '\0'; ShowError(buff); } else { FPModifyMap* fpm = (FPModifyMap*) GetWindowLongPtr(hwndDlg, GWLP_USERDATA); @@ -837,9 +845,13 @@ static INT_PTR CALLBACK DlgProcMirOTROptsFinger(HWND hwndDlg, UINT msg, WPARAM w switch (it->second) { case FPM_DELETE: if (it->first->context->active_fingerprint == it->first) { + MCONTACT hContact = (MCONTACT)it->first->context->app_data; TCHAR buff[1024], hash[45]; otrl_privkey_hash_to_humanT(hash, it->first->fingerprint); - mir_sntprintf(buff, SIZEOF(buff), TranslateT(LANG_FINGERPRINT_NOT_DELETED), hash, contact_get_nameT((MCONTACT)it->first->context->app_data)); + TCHAR *proto = mir_a2t(GetContactProto(hContact)); + mir_sntprintf(buff, SIZEOF(buff)-1, TranslateT(LANG_FINGERPRINT_NOT_DELETED), hash, contact_get_nameT(hContact), proto); + mir_free(proto); + buff[SIZEOF(buff)-1] = '\0'; ShowError(buff); } else { otrl_context_forget_fingerprint(it->first, 1); diff --git a/plugins/MirOTR/src/options.h b/plugins/MirOTR/src/options.h index da2e59ba3c..fc236d05cd 100644 --- a/plugins/MirOTR/src/options.h +++ b/plugins/MirOTR/src/options.h @@ -14,6 +14,8 @@ extern char g_instag_filename[MAX_PATH]; typedef enum {ED_POP, ED_BAL, ED_MB} ErrorDisplay; #define OPTIONS_PREFIXLEN 64 +//#define OPTIONS_DEFAULT_PREFIX "OTR: " +#define OPTIONS_DEFAULT_PREFIX "?OTR? " typedef struct { OtrlPolicy default_policy; -- cgit v1.2.3