From 7358b315743f75d1f470dbe8dd80ee9fcbe27100 Mon Sep 17 00:00:00 2001 From: Tobias Weimer Date: Sat, 14 Mar 2015 00:01:34 +0000 Subject: MirOTR: - Fixed "Convert HTML" menu for subcontacts - Minor warnings fixed git-svn-id: http://svn.miranda-ng.org/main/trunk@12398 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/MirOTR/MirOTR/src/dbfilter.cpp | 6 +-- plugins/MirOTR/MirOTR/src/dialogs.cpp | 91 ++++++++++++++++++-------------- plugins/MirOTR/MirOTR/src/mirotrmenu.cpp | 4 +- plugins/MirOTR/MirOTR/src/options.cpp | 55 +++++++++---------- plugins/MirOTR/MirOTR/src/otr.cpp | 53 ++++++++++--------- plugins/MirOTR/MirOTR/src/striphtml.cpp | 3 +- plugins/MirOTR/MirOTR/src/svcs_menu.cpp | 29 +++++----- plugins/MirOTR/MirOTR/src/utils.cpp | 15 +++--- plugins/MirOTR/MirOTR/src/utils.h | 1 - 9 files changed, 131 insertions(+), 126 deletions(-) diff --git a/plugins/MirOTR/MirOTR/src/dbfilter.cpp b/plugins/MirOTR/MirOTR/src/dbfilter.cpp index 81a5e00000..9f2223100d 100644 --- a/plugins/MirOTR/MirOTR/src/dbfilter.cpp +++ b/plugins/MirOTR/MirOTR/src/dbfilter.cpp @@ -55,7 +55,7 @@ int OnDatabaseEventPreAdd(WPARAM hContact, LPARAM lParam) if(dbei->cbBlob == 0 || dbei->pBlob == 0) return 0; // just to be safe - const char *proto = contact_get_proto(hContact); + const char *proto = GetContactProto(hContact); if (!proto) return 0; if (db_get_b(hContact, proto, "ChatRoom", 0) == 1) @@ -64,7 +64,7 @@ int OnDatabaseEventPreAdd(WPARAM hContact, LPARAM lParam) if(strcmp(proto, META_PROTO) == 0) { hContact = db_mc_getMostOnline(hContact); if (!hContact) return 0; - proto = contact_get_proto(hContact); + proto = GetContactProto(hContact); if (!proto ) return 0; } @@ -132,7 +132,7 @@ int OnDatabaseEventPreAdd(WPARAM hContact, LPARAM lParam) memset(newmsg, 0, alloclen+datalen); strncpy(newmsg, prefix, prefixlen); strncat(newmsg, msg, msglen); - wchar_t *p = (wchar_t*) newmsg + (msglen + prefixlen + 1) * sizeof(char); + wchar_t *p = (wchar_t*) newmsg + (msglen + prefixlen + 1); wcsncpy(p, prefixw, prefixlenw); wcsncat(p, msgw, msglenw); mir_free(prefix); diff --git a/plugins/MirOTR/MirOTR/src/dialogs.cpp b/plugins/MirOTR/MirOTR/src/dialogs.cpp index 2067ce64e4..d2609bff09 100644 --- a/plugins/MirOTR/MirOTR/src/dialogs.cpp +++ b/plugins/MirOTR/MirOTR/src/dialogs.cpp @@ -24,6 +24,7 @@ INT_PTR CALLBACK DlgSMPUpdateProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM SmpData *data = (SmpData*)lParam; ConnContext *context = data->context; + MCONTACT hContact = (MCONTACT)context->app_data; data->dialog = hwndDlg; //smp_for_contact.insert(SmpForContactMap::value_type(context->app_data, *data)); if (smp_for_contact[context->app_data].dialog) SendMessage(smp_for_contact[context->app_data].dialog, WMU_REFRESHSMP, 0, 0); @@ -33,8 +34,8 @@ INT_PTR CALLBACK DlgSMPUpdateProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM smp_for_contact[context->app_data].responder = data->responder; mir_free(data); - TCHAR title[512], *proto = mir_a2t(contact_get_proto((MCONTACT)context->app_data)); - const TCHAR *name =contact_get_nameT((MCONTACT)context->app_data); + TCHAR title[512], *proto = mir_a2t(GetContactProto(hContact)); + const TCHAR *name =contact_get_nameT(hContact); mir_sntprintf(title, SIZEOF(title), TranslateT(LANG_SMP_PROGRESS_TITLE), name, proto); SetWindowText(hwndDlg, title); mir_sntprintf(title, SIZEOF(title), TranslateT(LANG_SMP_PROGRESS_DESC), name, proto); @@ -100,14 +101,15 @@ INT_PTR CALLBACK DlgSMPUpdateProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM EnableWindow(GetDlgItem(hwndDlg, IDOK), true); smp_for_contact.erase(context->app_data); if (context->smstate->sm_prog_state == OTRL_SMP_PROG_SUCCEEDED) { - if (context->active_fingerprint->trust && - context->active_fingerprint->trust[0]) { - SetDlgItemText(hwndDlg, IDC_STC_SMP_PROGRESS, TranslateT(LANG_SMP_SUCCESS)); - } else { - SetDlgItemText(hwndDlg, IDC_STC_SMP_PROGRESS, TranslateT(LANG_SMP_SUCCESS_VERIFY)); - } - } else { - SetDlgItemText(hwndDlg, IDC_STC_SMP_PROGRESS, TranslateT(LANG_SMP_FAILED)); + if (context->active_fingerprint->trust && context->active_fingerprint->trust[0]) { + SetDlgItemText(hwndDlg, IDC_STC_SMP_PROGRESS, TranslateT(LANG_SMP_SUCCESS)); + } + else { + SetDlgItemText(hwndDlg, IDC_STC_SMP_PROGRESS, TranslateT(LANG_SMP_SUCCESS_VERIFY)); + } + } + else { + SetDlgItemText(hwndDlg, IDC_STC_SMP_PROGRESS, TranslateT(LANG_SMP_FAILED)); } } break; @@ -115,6 +117,7 @@ INT_PTR CALLBACK DlgSMPUpdateProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM SetDlgItemText(hwndDlg, IDC_STC_SMP_PROGRESS, _T("")); } } + break; case WM_COMMAND: switch ( HIWORD( wParam )) { @@ -160,6 +163,7 @@ INT_PTR CALLBACK DlgSMPResponseProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA SmpData *data = (SmpData*)lParam; ConnContext *context = data->context; + MCONTACT hContact = (MCONTACT)context->app_data; data->dialog = hwndDlg; //smp_for_contact.insert(SmpForContactMap::value_type(context->app_data, *data)); if (smp_for_contact[context->app_data].dialog) SendMessage(smp_for_contact[context->app_data].dialog, WMU_REFRESHSMP, 0, 0); @@ -168,15 +172,15 @@ INT_PTR CALLBACK DlgSMPResponseProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA smp_for_contact[context->app_data].oldlevel = data->oldlevel; smp_for_contact[context->app_data].responder = data->responder; - TCHAR buff[512], *proto = mir_a2t(contact_get_proto((MCONTACT)context->app_data)); - mir_sntprintf(buff, SIZEOF(buff), TranslateT(LANG_SMP_VERIFY_TITLE), contact_get_nameT((MCONTACT)context->app_data), proto); + TCHAR buff[512], *proto = mir_a2t(GetContactProto(hContact)); + mir_sntprintf(buff, SIZEOF(buff), TranslateT(LANG_SMP_VERIFY_TITLE), contact_get_nameT(hContact), proto); mir_free(proto); SetWindowText(hwndDlg, buff); SetDlgItemText(hwndDlg, IDC_STC_SMP_HEAD, buff); SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)context); if (data->question) { - mir_sntprintf(buff, SIZEOF(buff), TranslateT(LANG_OTR_SMPQUESTION_RESPOND_DESC), contact_get_nameT((MCONTACT)context->app_data)); + mir_sntprintf(buff, SIZEOF(buff), TranslateT(LANG_OTR_SMPQUESTION_RESPOND_DESC), contact_get_nameT(hContact)); SetDlgItemText(hwndDlg, IDC_STC_SMP_INFO, buff); @@ -195,7 +199,7 @@ INT_PTR CALLBACK DlgSMPResponseProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA mir_free(data->question); } else { - mir_sntprintf(buff, SIZEOF(buff), TranslateT(LANG_OTR_SMPPASSWORD_RESPOND_DESC), contact_get_nameT((MCONTACT)context->app_data)); + mir_sntprintf(buff, SIZEOF(buff), TranslateT(LANG_OTR_SMPPASSWORD_RESPOND_DESC), contact_get_nameT(hContact)); SetDlgItemText(hwndDlg, IDC_STC_SMP_INFO, buff); @@ -265,7 +269,7 @@ INT_PTR CALLBACK DlgSMPResponseProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA TCHAR *answer = new TCHAR[len+1]; GetDlgItemText(hwndDlg, IDC_EDT_SMP_FIELD2, answer, len+1); char *ans = mir_utf8encodeT(answer); - delete answer; + delete[] answer; otr_continue_smp(context, (const unsigned char *)ans, strlen(ans)); mir_free(ans); @@ -315,8 +319,9 @@ INT_PTR CALLBACK DlgProcSMPInitProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA return FALSE; } - TCHAR title[512], *proto = mir_a2t(contact_get_proto((MCONTACT)context->app_data)); - mir_sntprintf(title, SIZEOF(title), TranslateT(LANG_SMP_VERIFY_TITLE), contact_get_nameT((MCONTACT)context->app_data), proto); + MCONTACT hContact = (MCONTACT)context->app_data; + TCHAR title[512], *proto = mir_a2t(GetContactProto(hContact)); + mir_sntprintf(title, SIZEOF(title), TranslateT(LANG_SMP_VERIFY_TITLE), contact_get_nameT(hContact), proto); mir_free(proto); SetWindowText(hwndDlg, title); SetDlgItemText(hwndDlg, IDC_STC_SMP_HEAD, title); @@ -370,9 +375,9 @@ INT_PTR CALLBACK DlgProcSMPInitProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA } TCHAR buff[1024]; if (!fp->trust || fp->trust[0] == '\0') - mir_sntprintf(buff, SIZEOF(buff), TranslateT(LANG_OTR_SMPQUESTION_VERIFY_DESC), contact_get_nameT((MCONTACT)context->app_data)); + mir_sntprintf(buff, SIZEOF(buff), TranslateT(LANG_OTR_SMPQUESTION_VERIFY_DESC), contact_get_nameT(hContact)); else - mir_sntprintf(buff, SIZEOF(buff), TranslateT(LANG_OTR_SMPQUESTION_VERIFIED_DESC), contact_get_nameT((MCONTACT)context->app_data)); + mir_sntprintf(buff, SIZEOF(buff), TranslateT(LANG_OTR_SMPQUESTION_VERIFIED_DESC), contact_get_nameT(hContact)); SetDlgItemText(hwndDlg, IDC_STC_SMP_INFO, buff); @@ -397,7 +402,8 @@ INT_PTR CALLBACK DlgProcSMPInitProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA switch ( HIWORD( wParam )) { case BN_CLICKED: { - ConnContext* context = (ConnContext*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); + ConnContext *context = (ConnContext*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); + MCONTACT hContact = (MCONTACT)context->app_data; TCHAR msg[1024]; switch ( LOWORD( wParam )) { case IDCANCEL: @@ -408,7 +414,7 @@ INT_PTR CALLBACK DlgProcSMPInitProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA if (_tcsncmp(msg, TranslateT(LANG_SMPTYPE_QUESTION), 255)==0) { if (smp_for_contact.find(context->app_data) != smp_for_contact.end()) { TCHAR msg[512]; - mir_sntprintf(msg, SIZEOF(msg), TranslateT(LANG_SMP_IN_PROGRESS), contact_get_nameT((MCONTACT)context->app_data)); + mir_sntprintf(msg, SIZEOF(msg), TranslateT(LANG_SMP_IN_PROGRESS), contact_get_nameT(hContact)); ShowError(msg); }else { int len = SendDlgItemMessage(hwndDlg, IDC_EDT_SMP_FIELD1, WM_GETTEXTLENGTH, 0, 0); @@ -432,14 +438,14 @@ INT_PTR CALLBACK DlgProcSMPInitProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA }else if (_tcsncmp(msg, TranslateT(LANG_SMPTYPE_PASSWORD), 255)==0) { if (smp_for_contact.find(context->app_data) != smp_for_contact.end()) { TCHAR msg[512]; - mir_sntprintf(msg, SIZEOF(msg), TranslateT(LANG_SMP_IN_PROGRESS), contact_get_nameT((MCONTACT)context->app_data)); + mir_sntprintf(msg, SIZEOF(msg), TranslateT(LANG_SMP_IN_PROGRESS), contact_get_nameT(hContact)); ShowError(msg); }else { int len = SendDlgItemMessage(hwndDlg, IDC_EDT_SMP_FIELD2, WM_GETTEXTLENGTH, 0, 0); TCHAR *answer = new TCHAR[len+1]; GetDlgItemText(hwndDlg, IDC_EDT_SMP_FIELD2, answer, len+1); char *ans = mir_utf8encodeT(answer); - delete answer; + delete[] answer; SMPInitUpdateDialog(context, false); otr_start_smp(context, NULL, (const unsigned char*)ans, strlen(ans)); @@ -464,7 +470,8 @@ INT_PTR CALLBACK DlgProcSMPInitProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA switch ( LOWORD( wParam )) { case IDC_CBO_SMP_CHOOSE: { - ConnContext* context = (ConnContext*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); + ConnContext *context = (ConnContext*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); + MCONTACT hContact = (MCONTACT)context->app_data; Fingerprint *fp = context->active_fingerprint; if (!fp) { EndDialog(hwndDlg, IDCANCEL); @@ -477,9 +484,9 @@ INT_PTR CALLBACK DlgProcSMPInitProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA GetDlgItemText(hwndDlg, IDC_CBO_SMP_CHOOSE, buff, 255); if (_tcsncmp(buff, TranslateT(LANG_SMPTYPE_QUESTION), 255)==0) { if (trusted) - mir_sntprintf(buff, SIZEOF(buff), TranslateT(LANG_OTR_SMPQUESTION_VERIFIED_DESC), contact_get_nameT((MCONTACT)context->app_data)); + mir_sntprintf(buff, SIZEOF(buff), TranslateT(LANG_OTR_SMPQUESTION_VERIFIED_DESC), contact_get_nameT(hContact)); else - mir_sntprintf(buff, SIZEOF(buff), TranslateT(LANG_OTR_SMPQUESTION_VERIFY_DESC), contact_get_nameT((MCONTACT)context->app_data)); + mir_sntprintf(buff, SIZEOF(buff), TranslateT(LANG_OTR_SMPQUESTION_VERIFY_DESC), contact_get_nameT(hContact)); SetDlgItemText(hwndDlg, IDC_STC_SMP_INFO, buff); @@ -497,9 +504,9 @@ INT_PTR CALLBACK DlgProcSMPInitProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA ShowWindow(GetDlgItem(hwndDlg, IDNO), SW_HIDE); } else if (_tcsncmp(buff, TranslateT(LANG_SMPTYPE_PASSWORD), 255)==0) { if (trusted) - mir_sntprintf(buff, SIZEOF(buff), TranslateT(LANG_OTR_SMPPASSWORD_VERIFIED_DESC), contact_get_nameT((MCONTACT)context->app_data)); + mir_sntprintf(buff, SIZEOF(buff), TranslateT(LANG_OTR_SMPPASSWORD_VERIFIED_DESC), contact_get_nameT(hContact)); else - mir_sntprintf(buff, SIZEOF(buff), TranslateT(LANG_OTR_SMPPASSWORD_VERIFY_DESC), contact_get_nameT((MCONTACT)context->app_data)); + mir_sntprintf(buff, SIZEOF(buff), TranslateT(LANG_OTR_SMPPASSWORD_VERIFY_DESC), contact_get_nameT(hContact)); SetDlgItemText(hwndDlg, IDC_STC_SMP_INFO, buff); @@ -517,9 +524,9 @@ INT_PTR CALLBACK DlgProcSMPInitProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA ShowWindow(GetDlgItem(hwndDlg, IDNO), SW_HIDE); } else if (_tcsncmp(buff, TranslateT(LANG_SMPTYPE_FINGERPRINT), 255)==0) { if (trusted) - mir_sntprintf(buff, SIZEOF(buff), TranslateT(LANG_OTR_FPVERIFIED_DESC), contact_get_nameT((MCONTACT)context->app_data)); + mir_sntprintf(buff, SIZEOF(buff), TranslateT(LANG_OTR_FPVERIFIED_DESC), contact_get_nameT(hContact)); else - mir_sntprintf(buff, SIZEOF(buff), TranslateT(LANG_OTR_FPVERIFY_DESC), contact_get_nameT((MCONTACT)context->app_data)); + mir_sntprintf(buff, SIZEOF(buff), TranslateT(LANG_OTR_FPVERIFY_DESC), contact_get_nameT(hContact)); SetDlgItemText(hwndDlg, IDC_STC_SMP_INFO, buff); @@ -555,9 +562,9 @@ INT_PTR CALLBACK DlgProcSMPInitProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA return FALSE; } -void SMPInitDialog(ConnContext* context) { - if (!context) return; - CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_SMP_INPUT), 0, DlgProcSMPInitProc, (LPARAM) context); +void SMPInitDialog(ConnContext *context) { + if (context) + CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_SMP_INPUT), 0, DlgProcSMPInitProc, (LPARAM) context); } void SMPDialogUpdate(ConnContext *context, int percent) { @@ -655,6 +662,7 @@ INT_PTR CALLBACK DlgProcVerifyContext(HWND hwndDlg, UINT msg, WPARAM wParam, LPA // end center dialog ConnContext *context = (ConnContext*)lParam; + MCONTACT hContact = (MCONTACT) context->app_data; Fingerprint *fp = context->active_fingerprint; if (!fp) { EndDialog(hwndDlg, IDCANCEL); @@ -662,9 +670,9 @@ INT_PTR CALLBACK DlgProcVerifyContext(HWND hwndDlg, UINT msg, WPARAM wParam, LPA } TCHAR buff[512]; if (!fp->trust || fp->trust[0] == '\0') - mir_sntprintf(buff, SIZEOF(buff), TranslateT(LANG_OTR_FPVERIFY_DESC), contact_get_nameT((MCONTACT)context->app_data)); + mir_sntprintf(buff, SIZEOF(buff), TranslateT(LANG_OTR_FPVERIFY_DESC), contact_get_nameT(hContact)); else - mir_sntprintf(buff, SIZEOF(buff), TranslateT(LANG_OTR_FPVERIFIED_DESC), contact_get_nameT((MCONTACT)context->app_data)); + mir_sntprintf(buff, SIZEOF(buff), TranslateT(LANG_OTR_FPVERIFIED_DESC), contact_get_nameT(hContact)); SetDlgItemText(hwndDlg, IDC_STC_SMP_INFO, buff); @@ -721,6 +729,7 @@ unsigned int CALLBACK verify_context_thread(void *param) if (param) { ConnContext *context = (ConnContext *)param; + MCONTACT hContact = (MCONTACT)context->app_data; TCHAR msg[1024]; switch ( DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_SMP_INPUT), 0, DlgProcVerifyContext, (LPARAM)param) ) { case IDOK: @@ -729,18 +738,18 @@ unsigned int CALLBACK verify_context_thread(void *param) otrl_context_set_trust(context->active_fingerprint, "verified"); otrl_privkey_write_fingerprints(otr_user_state, g_fingerprint_store_filename); lib_cs_unlock(); - mir_sntprintf(msg, SIZEOF(msg), TranslateT(LANG_FINGERPRINT_VERIFIED), contact_get_nameT((MCONTACT)context->app_data)); - ShowMessage((MCONTACT)context->app_data, msg); - SetEncryptionStatus((MCONTACT)context->app_data, otr_context_get_trust(context)); + mir_sntprintf(msg, SIZEOF(msg), TranslateT(LANG_FINGERPRINT_VERIFIED), contact_get_nameT(hContact)); + ShowMessage(hContact, msg); + SetEncryptionStatus(hContact, otr_context_get_trust(context)); break; case IDNO: lib_cs_lock(); otrl_context_set_trust(context->active_fingerprint, NULL); otrl_privkey_write_fingerprints(otr_user_state, g_fingerprint_store_filename); lib_cs_unlock(); - mir_sntprintf(msg, SIZEOF(msg), TranslateT(LANG_FINGERPRINT_NOT_VERIFIED), contact_get_nameT((MCONTACT)context->app_data)); - ShowMessage((MCONTACT)context->app_data, msg); - SetEncryptionStatus((MCONTACT)context->app_data, otr_context_get_trust(context)); + mir_sntprintf(msg, SIZEOF(msg), TranslateT(LANG_FINGERPRINT_NOT_VERIFIED), contact_get_nameT(hContact)); + ShowMessage(hContact, msg); + SetEncryptionStatus(hContact, otr_context_get_trust(context)); break; } } diff --git a/plugins/MirOTR/MirOTR/src/mirotrmenu.cpp b/plugins/MirOTR/MirOTR/src/mirotrmenu.cpp index 99f7ba25ae..534d8fbfea 100644 --- a/plugins/MirOTR/MirOTR/src/mirotrmenu.cpp +++ b/plugins/MirOTR/MirOTR/src/mirotrmenu.cpp @@ -75,13 +75,12 @@ INT_PTR MirOTRMenuExecService(WPARAM wParam,LPARAM lParam) INT_PTR MirOTRMenuCheckService(WPARAM wParam,LPARAM) { PCheckProcParam pcpp = ( PCheckProcParam )wParam; - lpMirOTRMenuExecParam cmep=NULL; TMO_MenuItem mi; if ( pcpp == NULL ) return FALSE; - cmep = ( lpMirOTRMenuExecParam )pcpp->MenuItemOwnerData; + lpMirOTRMenuExecParam cmep = ( lpMirOTRMenuExecParam )pcpp->MenuItemOwnerData; if ( cmep == NULL ) //this is rootsection...build it return TRUE; @@ -143,7 +142,6 @@ INT_PTR FreeOwnerDataMirOTRMenu (WPARAM, LPARAM lParam) INT_PTR OnAddMenuItemMirOTRMenu (WPARAM wParam, LPARAM lParam) { - MENUITEMINFO *mii = (MENUITEMINFO*)wParam; if (!mii || mii->cbSize != sizeof(MENUITEMINFO)) return 0; diff --git a/plugins/MirOTR/MirOTR/src/options.cpp b/plugins/MirOTR/MirOTR/src/options.cpp index 0fa2586d40..7a4bce4afc 100644 --- a/plugins/MirOTR/MirOTR/src/options.cpp +++ b/plugins/MirOTR/MirOTR/src/options.cpp @@ -78,11 +78,11 @@ void LoadOptions() { DBVARIANT dbv; if (!db_get_utf(0, MODULENAME, "Prefix", &dbv)) { - strncpy(options.prefix, dbv.pszVal, OPTIONS_PREFIXLEN); + strncpy(options.prefix, dbv.pszVal, OPTIONS_PREFIXLEN-1); options.prefix[OPTIONS_PREFIXLEN-1] = 0; db_free(&dbv); } else - strcpy(options.prefix, ("OTR: ")); + strncpy(options.prefix, ("OTR: "), 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); @@ -220,8 +220,8 @@ static INT_PTR CALLBACK DlgProcMirOTROpts(HWND hwndDlg, UINT msg, WPARAM wParam, case IDC_CHK_ENDOFFLINE: case IDC_CHK_ENDCLOSE: SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); - break; } + break; case EN_CHANGE: if (LOWORD( wParam ) == IDC_ED_PREFIX && ( HWND )lParam == GetFocus()) SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); @@ -256,7 +256,7 @@ 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); + strncpy(options.prefix, prefix_utf, OPTIONS_PREFIXLEN-1); mir_free(prefix_utf); SaveOptions(); @@ -418,6 +418,7 @@ static INT_PTR CALLBACK DlgProcMirOTROptsProto(HWND hwndDlg, UINT msg, WPARAM wP } }break; } + break; case CBN_SELCHANGE: switch ( LOWORD( wParam )) { case IDC_CMB_PROTO_POLICY: @@ -431,7 +432,7 @@ static INT_PTR CALLBACK DlgProcMirOTROptsProto(HWND hwndDlg, UINT msg, WPARAM wP TCHAR *text = new TCHAR[len+1]; SendDlgItemMessage(hwndDlg, IDC_CMB_PROTO_POLICY, CB_GETLBTEXT, sel, (LPARAM)text); ListView_SetItemText(GetDlgItem(hwndDlg, IDC_LV_PROTO_PROTOS), proto, 1, text); - delete text; + delete[] text; SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); }break; } @@ -547,7 +548,7 @@ static INT_PTR CALLBACK DlgProcMirOTROptsContacts(HWND hwndDlg, UINT msg, WPARAM const char *proto; TCHAR *proto_t; for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) { - proto = contact_get_proto(hContact); + proto = GetContactProto(hContact); if(proto && db_get_b(hContact, proto, "ChatRoom", 0) == 0 && CallService(MS_PROTO_ISPROTOONCONTACT, hContact, (LPARAM)MODULENAME) // ignore chatrooms && strcmp(proto, META_PROTO) != 0) // and MetaContacts { @@ -586,7 +587,7 @@ static INT_PTR CALLBACK DlgProcMirOTROptsContacts(HWND hwndDlg, UINT msg, WPARAM SendDlgItemMessage(hwndDlg, IDC_CMB_CONT_POLICY, CB_GETLBTEXT, sel, (LPARAM)text); ListView_SetItemText(GetDlgItem(hwndDlg, IDC_LV_CONT_CONTACTS), iUser, 2, text); OtrlPolicy policy = policy_from_string(text); - delete text; + delete[] text; LVITEM lvi = {0}; lvi.mask = LVIF_PARAM; lvi.iItem = iUser; @@ -727,34 +728,29 @@ static INT_PTR CALLBACK DlgProcMirOTROptsFinger(HWND hwndDlg, UINT msg, WPARAM w // Initialize LVITEM members that are common to all // items. lvI.mask = LVIF_TEXT | LVIF_PARAM;// | LVIF_NORECOMPUTE;// | LVIF_IMAGE; - ConnContext * context = otr_user_state->context_root; + TCHAR *proto, *user, hash[45] = {0}; - Fingerprint *fp; - while (context) { + for (ConnContext *context = otr_user_state->context_root;context;context = context->next) { if (context->app_data) { user = (TCHAR*)contact_get_nameT((MCONTACT)context->app_data); if (user) { proto = mir_a2t(context->protocol); - fp = context->fingerprint_root.next; - while(fp) { + + for(Fingerprint *fp = context->fingerprint_root.next;fp;fp = fp->next) { otrl_privkey_hash_to_humanT(hash, fp->fingerprint); - if (hash) { - lvI.iSubItem = 0; - lvI.lParam = (LPARAM)fp; - lvI.pszText = user; - int d = ListView_InsertItem(lv, &lvI); - - ListView_SetItemText(lv,d, 1, proto); - ListView_SetItemText(lv,d, 2, (context->active_fingerprint == fp)? TranslateT(LANG_YES) : TranslateT(LANG_NO)); - ListView_SetItemText(lv,d, 3, (fp->trust && fp->trust[0] != '\0')? TranslateT(LANG_YES) : TranslateT(LANG_NO)); - ListView_SetItemText(lv,d, 4, hash ); - } - fp = fp->next; + lvI.iSubItem = 0; + lvI.lParam = (LPARAM)fp; + lvI.pszText = user; + int d = ListView_InsertItem(lv, &lvI); + + ListView_SetItemText(lv,d, 1, proto); + ListView_SetItemText(lv,d, 2, (context->active_fingerprint == fp)? TranslateT(LANG_YES) : TranslateT(LANG_NO)); + ListView_SetItemText(lv,d, 3, (fp->trust && fp->trust[0] != '\0')? TranslateT(LANG_YES) : TranslateT(LANG_NO)); + ListView_SetItemText(lv,d, 4, hash ); } mir_free(proto); } } - context = context->next; } } @@ -770,9 +766,8 @@ static INT_PTR CALLBACK DlgProcMirOTROptsFinger(HWND hwndDlg, UINT msg, WPARAM w LVITEM lvi = {0}; lvi.mask = LVIF_PARAM; lvi.iItem = sel; - Fingerprint *fp = NULL; ListView_GetItem(GetDlgItem(hwndDlg, IDC_LV_FINGER_LIST), &lvi); - fp = (Fingerprint*) lvi.lParam; + Fingerprint *fp = (Fingerprint*) lvi.lParam; FPModifyMap* fpm = (FPModifyMap*) GetWindowLongPtr(hwndDlg, GWLP_USERDATA); (*fpm)[fp] = FPM_NOTRUST; ListView_SetItemText(GetDlgItem(hwndDlg, IDC_LV_FINGER_LIST), sel, 3, TranslateT(LANG_NO)); @@ -786,9 +781,8 @@ static INT_PTR CALLBACK DlgProcMirOTROptsFinger(HWND hwndDlg, UINT msg, WPARAM w LVITEM lvi = {0}; lvi.mask = LVIF_PARAM; lvi.iItem = sel; - Fingerprint *fp = NULL; ListView_GetItem(GetDlgItem(hwndDlg, IDC_LV_FINGER_LIST), &lvi); - fp = (Fingerprint*) lvi.lParam; + Fingerprint *fp = (Fingerprint*) lvi.lParam; FPModifyMap* fpm = (FPModifyMap*) GetWindowLongPtr(hwndDlg, GWLP_USERDATA); (*fpm)[fp] = FPM_VERIFY; ListView_SetItemText(GetDlgItem(hwndDlg, IDC_LV_FINGER_LIST), sel, 3, TranslateT(LANG_YES)); @@ -802,9 +796,8 @@ static INT_PTR CALLBACK DlgProcMirOTROptsFinger(HWND hwndDlg, UINT msg, WPARAM w LVITEM lvi = {0}; lvi.mask = LVIF_PARAM; lvi.iItem = sel; - Fingerprint *fp = NULL; ListView_GetItem(GetDlgItem(hwndDlg, IDC_LV_FINGER_LIST), &lvi); - fp = (Fingerprint*) lvi.lParam; + Fingerprint *fp = (Fingerprint*) lvi.lParam; if (fp->context->active_fingerprint == fp) { TCHAR buff[1024], hash[45]; otrl_privkey_hash_to_humanT(hash, fp->fingerprint); diff --git a/plugins/MirOTR/MirOTR/src/otr.cpp b/plugins/MirOTR/MirOTR/src/otr.cpp index f09042ef1e..de3f7e42ed 100644 --- a/plugins/MirOTR/MirOTR/src/otr.cpp +++ b/plugins/MirOTR/MirOTR/src/otr.cpp @@ -110,7 +110,7 @@ extern "C" { //DWORD tid; //CloseHandle(CreateThread(0, 0, newKeyThread, (VOID *)nkd, 0, &tid)); //QueueUserAPC(newKeyAPC, Global::mainThread, (DWORD)nkd); - if (opdata) protocol = contact_get_proto((MCONTACT)opdata); + if (opdata) protocol = GetContactProto((MCONTACT)opdata); if (!protocol) return; DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_GENKEYNOTIFY), 0, GenKeyDlgFunc, (LPARAM)protocol ); @@ -126,7 +126,7 @@ extern "C" { DEBUGOUT_T("OTR_GUI_IS_LOGGED_IN") MCONTACT hContact = (MCONTACT)opdata; if(hContact) { - WORD status = db_get_w(hContact, contact_get_proto(hContact), "Status", ID_STATUS_OFFLINE); + WORD status = db_get_w(hContact, GetContactProto(hContact), "Status", ID_STATUS_OFFLINE); if(status == ID_STATUS_OFFLINE) return 0; else return 1; } @@ -149,7 +149,8 @@ extern "C" { * protocol / username conversation. */ void otr_gui_notify(void *opdata, OtrlNotifyLevel level, const char *accountname, const char *protocol, const char *username, const char *title, const char *primary, const char *secondary) { DEBUGOUT_T("OTR_GUI_NOTIFY") - const TCHAR* uname = contact_get_nameT((MCONTACT)opdata); + MCONTACT hContact = (MCONTACT) opdata; + const TCHAR* uname = contact_get_nameT(hContact); TCHAR* title_t = mir_utf8decodeT(title); TCHAR *notify = TranslateT(LANG_OTR_NOTIFY); @@ -162,7 +163,7 @@ extern "C" { char *buff2 = new char[len]; mir_snprintf(buff2, len, "%s\n%s", Translate(primary), Translate(secondary)); TCHAR* buff2_t = mir_utf8decodeT(buff2); - delete buff2; + delete[] buff2; DEBUGOUT_T("OTR_GUI_NOTIFY") @@ -178,13 +179,14 @@ extern "C" { * as a received message, or else by using the above notify() * callback. */ int otr_gui_display_otr_message(void *opdata, const char *accountname, const char *protocol, const char *username, const char *msg) { + MCONTACT hContact = (MCONTACT) opdata; DEBUGOUT_T("OTR_GUI_DISPLAY_OTR_MESSAGE") if(options.msg_inline) - ShowMessageInlineUtf((MCONTACT)opdata, Translate(msg)); + ShowMessageInlineUtf(hContact, Translate(msg)); if(options.msg_popup) { TCHAR buff[512]; TCHAR* proto = mir_a2t(protocol); - mir_sntprintf(buff, SIZEOF(buff), TranslateT(LANG_OTR_USERMESSAGE), contact_get_nameT((MCONTACT)opdata), proto); + mir_sntprintf(buff, SIZEOF(buff), TranslateT(LANG_OTR_USERMESSAGE), contact_get_nameT(hContact), proto); mir_free(proto); TCHAR *msg_t = mir_utf8decodeT(msg); ShowPopup(buff, TranslateTS(msg_t), 0); @@ -235,66 +237,69 @@ extern "C" { /* A ConnContext has entered a secure state. */ void otr_gui_gone_secure(void *opdata, ConnContext *context) { DEBUGOUT_T("OTR_GUI_GONE_SECURE") + MCONTACT hContact = (MCONTACT) opdata; TrustLevel trusted = otr_context_get_trust(context); // opdata is hContact - SetEncryptionStatus((MCONTACT)opdata, trusted); + SetEncryptionStatus(hContact, trusted); TCHAR buff[1024]; if(trusted == TRUST_PRIVATE) { - mir_sntprintf(buff, SIZEOF(buff), TranslateT(LANG_SESSION_START_OTR), contact_get_nameT((MCONTACT)opdata)); + mir_sntprintf(buff, SIZEOF(buff), TranslateT(LANG_SESSION_START_OTR), contact_get_nameT(hContact)); } else if (trusted == TRUST_UNVERIFIED) { if (options.autoshow_verify) SMPInitDialog(context); //VerifyContextDialog(context); - mir_sntprintf(buff, SIZEOF(buff), TranslateT(LANG_SESSION_START_OTR_VERIFY), contact_get_nameT((MCONTACT)opdata)); + mir_sntprintf(buff, SIZEOF(buff), TranslateT(LANG_SESSION_START_OTR_VERIFY), contact_get_nameT(hContact)); } else { // should never happen - mir_sntprintf(buff, SIZEOF(buff), TranslateT(LANG_SESSION_NOT_STARTED_OTR), contact_get_nameT((MCONTACT)opdata)); + mir_sntprintf(buff, SIZEOF(buff), TranslateT(LANG_SESSION_NOT_STARTED_OTR), contact_get_nameT(hContact)); } // opdata is hContact - ShowMessage((MCONTACT)opdata, buff); + ShowMessage(hContact, buff); } /* A ConnContext has left a secure state. */ void otr_gui_gone_insecure(void *opdata, ConnContext *context) { + MCONTACT hContact = (MCONTACT) opdata; DEBUGOUT_T("OTR_GUI_GONE_INSECURE") TCHAR buff[512]; - mir_sntprintf(buff, SIZEOF(buff), TranslateT(LANG_SESSION_TERMINATED_BY_OTR), contact_get_nameT((MCONTACT)opdata)); + mir_sntprintf(buff, SIZEOF(buff), TranslateT(LANG_SESSION_TERMINATED_BY_OTR), contact_get_nameT(hContact)); //MessageBox(0, buff, Translate("OTR Information"), MB_OK); if (!Miranda_Terminated()) { - ShowMessage((MCONTACT)opdata, buff); + ShowMessage(hContact, buff); } // opdata is hContact - SetEncryptionStatus((MCONTACT)opdata, otr_context_get_trust(context)); + SetEncryptionStatus(hContact, otr_context_get_trust(context)); } /* We have completed an authentication, using the D-H keys we * already knew. is_reply indicates whether we initiated the AKE. */ void otr_gui_still_secure(void *opdata, ConnContext *context, int is_reply) { + MCONTACT hContact = (MCONTACT) opdata; DEBUGOUT_T("OTR_GUI_STILL_SECURE") TrustLevel trusted = otr_context_get_trust(context); - SetEncryptionStatus((MCONTACT)opdata, trusted); + SetEncryptionStatus(hContact, trusted); TCHAR buff[1024]; if (!is_reply) { if(trusted == TRUST_PRIVATE) { - mir_sntprintf(buff, SIZEOF(buff), TranslateT(LANG_SESSION_CONTINUE_OTR), contact_get_nameT((MCONTACT)opdata)); + mir_sntprintf(buff, SIZEOF(buff), TranslateT(LANG_SESSION_CONTINUE_OTR), contact_get_nameT(hContact)); } else if (trusted == TRUST_UNVERIFIED) { if (options.autoshow_verify) SMPInitDialog(context); //VerifyContextDialog(context); - mir_sntprintf(buff, SIZEOF(buff), TranslateT(LANG_SESSION_CONTINUE_OTR_VERIFY), contact_get_nameT((MCONTACT)opdata)); + mir_sntprintf(buff, SIZEOF(buff), TranslateT(LANG_SESSION_CONTINUE_OTR_VERIFY), contact_get_nameT(hContact)); } else { // should never happen - mir_sntprintf(buff, SIZEOF(buff), TranslateT(LANG_SESSION_NOT_STARTED_OTR), contact_get_nameT((MCONTACT)opdata)); + mir_sntprintf(buff, SIZEOF(buff), TranslateT(LANG_SESSION_NOT_STARTED_OTR), contact_get_nameT(hContact)); } // opdata is hContact - ShowMessage((MCONTACT)opdata, buff); + ShowMessage(hContact, buff); } else { if(trusted == TRUST_PRIVATE) { - mir_sntprintf(buff, SIZEOF(buff), TranslateT(LANG_SESSION_HAS_CONTINUE_OTR), contact_get_nameT((MCONTACT)opdata)); + mir_sntprintf(buff, SIZEOF(buff), TranslateT(LANG_SESSION_HAS_CONTINUE_OTR), contact_get_nameT(hContact)); } else if (trusted == TRUST_UNVERIFIED) { - mir_sntprintf(buff, SIZEOF(buff), TranslateT(LANG_SESSION_HAS_CONTINUE_OTR_VERIFY), contact_get_nameT((MCONTACT)opdata)); + mir_sntprintf(buff, SIZEOF(buff), TranslateT(LANG_SESSION_HAS_CONTINUE_OTR_VERIFY), contact_get_nameT(hContact)); } else { // should never happen - mir_sntprintf(buff, SIZEOF(buff), TranslateT(LANG_SESSION_NOT_STARTED_OTR), contact_get_nameT((MCONTACT)opdata)); + mir_sntprintf(buff, SIZEOF(buff), TranslateT(LANG_SESSION_NOT_STARTED_OTR), contact_get_nameT(hContact)); } } - SetEncryptionStatus((MCONTACT)opdata, trusted); + SetEncryptionStatus(hContact, trusted); } /* Log a message. The passed message will end in "\n". */ @@ -314,7 +319,7 @@ extern "C" { if (context && context->protocol) proto = context->protocol; else - proto = contact_get_proto((MCONTACT)opdata); + proto = GetContactProto((MCONTACT)opdata); // ugly wokaround for ICQ. ICQ protocol reports more than 7k, but in SMP this is too long. // possibly ICQ doesn't allow single words without spaces to become longer than ~2340? if (strcmp("ICQ", proto)==0 || strncmp("ICQ_", proto, 4)==0) diff --git a/plugins/MirOTR/MirOTR/src/striphtml.cpp b/plugins/MirOTR/MirOTR/src/striphtml.cpp index c1dbb0cd55..4a3c3759ff 100644 --- a/plugins/MirOTR/MirOTR/src/striphtml.cpp +++ b/plugins/MirOTR/MirOTR/src/striphtml.cpp @@ -4,7 +4,7 @@ void starttag_cb (void *cbdata, ekhtml_string_t *tag, ekhtml_attr_t *attrs) { STRIPHTML_DATA *data = (STRIPHTML_DATA *)cbdata; switch (tag->len) { case 1: - switch (*(tag->str)) { + switch (tag->str[0]) { case 'a': case 'A': for(ekhtml_attr_t *attr=attrs; attr; attr=attr->next) { @@ -23,6 +23,7 @@ void starttag_cb (void *cbdata, ekhtml_string_t *tag, ekhtml_attr_t *attrs) { data->buffer.append(" _"); break; } + break; case 2: if (toupper(tag->str[0]) == 'B' && toupper(tag->str[1]) == 'R') data->buffer.append("\r\n"); diff --git a/plugins/MirOTR/MirOTR/src/svcs_menu.cpp b/plugins/MirOTR/MirOTR/src/svcs_menu.cpp index c0596262ec..6699c00adc 100644 --- a/plugins/MirOTR/MirOTR/src/svcs_menu.cpp +++ b/plugins/MirOTR/MirOTR/src/svcs_menu.cpp @@ -6,8 +6,7 @@ static HGENMENU hStopItem, hStartItem; ///////// Menu Services //////// /////////////////////////////// int StartOTR(MCONTACT hContact) { - - const char *proto = contact_get_proto(hContact); + const char *proto = GetContactProto(hContact); if (!proto) return 1; // error char *uname = contact_get_id(hContact); if (!uname) return 1; // error @@ -25,10 +24,10 @@ int StartOTR(MCONTACT hContact) { INT_PTR SVC_StartOTR(WPARAM hContact, LPARAM lParam) { - MCONTACT hSub; TCHAR buff[512]; - if((hSub = db_mc_getMostOnline(hContact)) != 0) + MCONTACT hSub = db_mc_getMostOnline(hContact); + if(hSub != 0) hContact = hSub; if ( options.bHaveSecureIM && CallService("SecureIM/IsContactSecured", hContact, 0) != 0 ) { @@ -45,10 +44,10 @@ INT_PTR SVC_StartOTR(WPARAM hContact, LPARAM lParam) INT_PTR SVC_RefreshOTR(WPARAM hContact, LPARAM lParam) { - MCONTACT hSub; TCHAR buff[512]; - if((hSub = db_mc_getMostOnline(hContact)) != 0) + MCONTACT hSub = db_mc_getMostOnline(hContact); + if(hSub != 0) hContact = hSub; if ( options.bHaveSecureIM && CallService("SecureIM/IsContactSecured", hContact, 0) != 0 ) { @@ -68,11 +67,11 @@ INT_PTR SVC_RefreshOTR(WPARAM hContact, LPARAM lParam) int otr_disconnect_contact(MCONTACT hContact) { - MCONTACT hSub; - if((hSub = db_mc_getMostOnline(hContact)) != 0) + MCONTACT hSub = db_mc_getMostOnline(hContact); + if (hSub != 0) hContact = hSub; - const char *proto = contact_get_proto(hContact); + const char *proto = GetContactProto(hContact); if (!proto) return 1; // error char *uname = contact_get_id(hContact); if (!uname) return 1; // error @@ -99,8 +98,8 @@ INT_PTR SVC_StopOTR(WPARAM hContact, LPARAM lParam) INT_PTR SVC_VerifyOTR(WPARAM hContact, LPARAM lParam) { - MCONTACT hSub; - if((hSub = db_mc_getMostOnline(hContact)) != 0) + MCONTACT hSub = db_mc_getMostOnline(hContact); + if(hSub != 0) hContact = hSub; ConnContext *context = otrl_context_find_miranda(otr_user_state, hContact); @@ -114,6 +113,10 @@ INT_PTR SVC_VerifyOTR(WPARAM hContact, LPARAM lParam) INT_PTR SVC_ToggleHTMLOTR(WPARAM hContact, LPARAM lParam) { + MCONTACT hSub = db_mc_getMostOnline(hContact); + if (hSub != 0) + hContact = hSub; + if (db_get_b(hContact, MODULENAME, "HTMLConv", 0)) db_set_b(hContact, MODULENAME, "HTMLConv", 0); else @@ -154,7 +157,7 @@ int SVC_PrebuildContactMenu(WPARAM hContact, LPARAM lParam) CLISTMENUITEM mi = { sizeof(mi) }; mi.flags = CMIM_FLAGS | CMIF_NOTOFFLINE | CMIF_TCHAR; - const char *proto = contact_get_proto(hContact); + const char *proto = GetContactProto(hContact); DWORD pol = CONTACT_DEFAULT_POLICY; if (!proto || db_get_b(hContact, proto, "ChatRoom", 0) == 1) { @@ -169,7 +172,7 @@ hide_all: hContact = db_mc_getMostOnline(hContact); if (!hContact) goto hide_all; - proto = contact_get_proto(hContact); + proto = GetContactProto(hContact); } pol = db_get_dw(hContact, MODULENAME, "Policy", CONTACT_DEFAULT_POLICY); diff --git a/plugins/MirOTR/MirOTR/src/utils.cpp b/plugins/MirOTR/MirOTR/src/utils.cpp index 7b6323d86e..d834fb84a1 100644 --- a/plugins/MirOTR/MirOTR/src/utils.cpp +++ b/plugins/MirOTR/MirOTR/src/utils.cpp @@ -25,7 +25,7 @@ void lib_cs_unlock() MCONTACT find_contact(const char* userid, const char* protocol) { for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) { - const char *proto = contact_get_proto(hContact); + const char *proto = GetContactProto(hContact); if(proto && strcmp(proto, protocol) == 0) { char *name = contact_get_id(hContact); if(name && strcmp(name, userid) == 0) { @@ -84,11 +84,12 @@ void VerifyFingerprint(ConnContext *context, bool verify) { } void VerifyFingerprintMessage(ConnContext *context, bool verify) { + MCONTACT hContact = (MCONTACT)context->app_data; TCHAR msg[1024]; - mir_sntprintf(msg, SIZEOF(msg), (verify)?TranslateT(LANG_FINGERPRINT_VERIFIED):TranslateT(LANG_FINGERPRINT_NOT_VERIFIED), contact_get_nameT((MCONTACT)context->app_data)); - ShowMessage((MCONTACT)context->app_data, msg); - SetEncryptionStatus((MCONTACT)context->app_data, otr_context_get_trust(context)); + mir_sntprintf(msg, SIZEOF(msg), (verify)?TranslateT(LANG_FINGERPRINT_VERIFIED):TranslateT(LANG_FINGERPRINT_NOT_VERIFIED), contact_get_nameT(hContact)); + ShowMessage(hContact, msg); + SetEncryptionStatus(hContact, otr_context_get_trust(context)); } /* Convert a 20-byte hash value to a 45-byte human-readable value */ @@ -146,10 +147,6 @@ __inline const TCHAR* contact_get_nameT(MCONTACT hContact) { return (TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, hContact, GCDNF_TCHAR); } -__inline const char* contact_get_proto(MCONTACT hContact) { - char *uproto = GetContactProto(hContact); - return uproto; -} __inline const char* contact_get_account(MCONTACT hContact) { char *uacc = (char *)CallService(MS_PROTO_GETCONTACTBASEACCOUNT, hContact, 0); @@ -168,7 +165,7 @@ void ShowPopup(const TCHAR* line1, const TCHAR* line2, int timeout, const MCONTA TCHAR *message = new TCHAR[size]; // newline and null terminator mir_sntprintf(message, size, _T("%s\r\n%s"), line1, line2); MessageBox( NULL, message, title, MB_OK | MB_ICONINFORMATION ); - delete message; + delete[] message; } else if(line1) { MessageBox( NULL, line1, title, MB_OK | MB_ICONINFORMATION ); } else if(line2) { diff --git a/plugins/MirOTR/MirOTR/src/utils.h b/plugins/MirOTR/MirOTR/src/utils.h index a174e9828e..71890a77eb 100644 --- a/plugins/MirOTR/MirOTR/src/utils.h +++ b/plugins/MirOTR/MirOTR/src/utils.h @@ -23,7 +23,6 @@ void VerifyFingerprintMessage(ConnContext *context, bool verify); void otrl_privkey_hash_to_humanT(TCHAR human[45], const unsigned char hash[20]); char* contact_get_id(MCONTACT hContact, bool bNameOnError=true); -__inline const char* contact_get_proto(MCONTACT hContact); __inline const char* contact_get_account(MCONTACT hContact); extern __inline const TCHAR* contact_get_nameT(MCONTACT hContact); -- cgit v1.2.3