diff options
author | George Hazan <george.hazan@gmail.com> | 2015-05-22 16:04:17 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2015-05-22 16:04:17 +0000 |
commit | e2c2a1f5a84c6c9b705dc85c6a2dd1f97edd57e4 (patch) | |
tree | ba79bdcede96f80039f8b88d2791f198b9ec2981 /plugins/MirOTR/src | |
parent | f8e34b5f83f3ce5f39d541e9068b6b8cb6d92acd (diff) |
T2Utf - handy replacement for ptrA<mir_utf8decodeT()>
git-svn-id: http://svn.miranda-ng.org/main/trunk@13758 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/MirOTR/src')
-rw-r--r-- | plugins/MirOTR/src/dialogs.cpp | 57 | ||||
-rw-r--r-- | plugins/MirOTR/src/options.cpp | 15 | ||||
-rw-r--r-- | plugins/MirOTR/src/svcs_menu.cpp | 4 | ||||
-rw-r--r-- | plugins/MirOTR/src/utils.cpp | 4 |
4 files changed, 36 insertions, 44 deletions
diff --git a/plugins/MirOTR/src/dialogs.cpp b/plugins/MirOTR/src/dialogs.cpp index f724c5a371..350d761d8d 100644 --- a/plugins/MirOTR/src/dialogs.cpp +++ b/plugins/MirOTR/src/dialogs.cpp @@ -266,34 +266,32 @@ INT_PTR CALLBACK DlgSMPResponseProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA case WM_COMMAND: switch ( HIWORD( wParam )) { - case BN_CLICKED: - { - ConnContext *context = (ConnContext *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); - switch ( LOWORD( wParam )) { - case IDOK: - { - SMPInitUpdateDialog(context, true); - - 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; - - otr_continue_smp(context, (const unsigned char *)ans, mir_strlen(ans)); - mir_free(ans); - SetWindowLongPtr(hwndDlg, GWLP_USERDATA, NULL); - DestroyWindow(hwndDlg); - }break; - case IDCANCEL: - smp_for_contact.erase(context->app_data); - DestroyWindow(hwndDlg); - break; - } + case BN_CLICKED: + ConnContext *context = (ConnContext *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); + switch ( LOWORD( wParam )) { + case IDOK: + SMPInitUpdateDialog(context, true); + { + 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); + + T2Utf ans(answer); + otr_continue_smp(context, (const unsigned char *)ans, mir_strlen(ans)); + delete[] answer; + + SetWindowLongPtr(hwndDlg, GWLP_USERDATA, NULL); + DestroyWindow(hwndDlg); } + break; + + case IDCANCEL: + smp_for_contact.erase(context->app_data); + DestroyWindow(hwndDlg); + break; + } } break; - } return FALSE; @@ -429,19 +427,17 @@ INT_PTR CALLBACK DlgProcSMPInitProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA int len = SendDlgItemMessage(hwndDlg, IDC_EDT_SMP_FIELD1, WM_GETTEXTLENGTH, 0, 0); TCHAR *question = new TCHAR[len+1]; GetDlgItemText(hwndDlg, IDC_EDT_SMP_FIELD1, question, len+1); - char *quest = mir_utf8encodeT(question); + T2Utf quest(question); delete question; 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); + T2Utf ans(answer); delete answer; SMPInitUpdateDialog(context, false); otr_start_smp(context, quest, (const unsigned char*)ans, mir_strlen(ans)); - mir_free(quest); - mir_free(ans); } }else if (_tcsncmp(msg, TranslateT(LANG_SMPTYPE_PASSWORD), 255)==0) { @@ -453,12 +449,11 @@ INT_PTR CALLBACK DlgProcSMPInitProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA 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); + T2Utf ans(answer); delete[] answer; SMPInitUpdateDialog(context, false); otr_start_smp(context, NULL, (const unsigned char*)ans, mir_strlen(ans)); - mir_free(ans); } }else break; diff --git a/plugins/MirOTR/src/options.cpp b/plugins/MirOTR/src/options.cpp index 72b5d0d023..21ac240c25 100644 --- a/plugins/MirOTR/src/options.cpp +++ b/plugins/MirOTR/src/options.cpp @@ -137,7 +137,7 @@ void ReadPrivkeyFiles() static INT_PTR CALLBACK DlgProcMirOTROpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { - TCHAR *prefix; char* prefix_utf; + TCHAR *prefix; switch ( msg ) { case WM_INITDIALOG: TranslateDialogDefault( hwndDlg ); @@ -218,16 +218,15 @@ static INT_PTR CALLBACK DlgProcMirOTROpts(HWND hwndDlg, UINT msg, WPARAM wParam, options.end_offline = (TRUE==IsDlgButtonChecked(hwndDlg, IDC_CHK_ENDOFFLINE)); options.end_window_close = (TRUE==IsDlgButtonChecked(hwndDlg, IDC_CHK_ENDCLOSE)); - prefix = (TCHAR*)mir_alloc(sizeof(TCHAR)*OPTIONS_PREFIXLEN); + prefix = (TCHAR*)_alloca(sizeof(TCHAR)*OPTIONS_PREFIXLEN); GetDlgItemText(hwndDlg, IDC_ED_PREFIX, prefix, OPTIONS_PREFIXLEN); - prefix_utf = mir_utf8encodeT(prefix); - mir_free(prefix); - if(!prefix_utf[0]){ + + T2Utf prefix_utf(prefix); + if (!mir_strlen(prefix_utf)) { SetDlgItemTextA(hwndDlg, IDC_ED_PREFIX, OPTIONS_DEFAULT_PREFIX); mir_strncpy(options.prefix, OPTIONS_DEFAULT_PREFIX, OPTIONS_PREFIXLEN); - } else - mir_strncpy(options.prefix, prefix_utf, OPTIONS_PREFIXLEN); - mir_free(prefix_utf); + } + else mir_strncpy(options.prefix, prefix_utf, OPTIONS_PREFIXLEN); SaveOptions(); return TRUE; diff --git a/plugins/MirOTR/src/svcs_menu.cpp b/plugins/MirOTR/src/svcs_menu.cpp index 93771cfa23..86a8e44a37 100644 --- a/plugins/MirOTR/src/svcs_menu.cpp +++ b/plugins/MirOTR/src/svcs_menu.cpp @@ -39,9 +39,9 @@ int StartOTR(MCONTACT hContact) { } *msgoff='\0'; mir_free(nick); - char* msg_utf8 = mir_utf8encodeT(msg); + + T2Utf msg_utf8(msg); otr_gui_inject_message((void*)hContact, proto, proto, uname, msg_utf8 ? msg_utf8 : MIROTR_PROTO_HELLO); - mir_free(msg_utf8); } #endif mir_free(uname); diff --git a/plugins/MirOTR/src/utils.cpp b/plugins/MirOTR/src/utils.cpp index 93375922e8..5e9715e256 100644 --- a/plugins/MirOTR/src/utils.cpp +++ b/plugins/MirOTR/src/utils.cpp @@ -316,15 +316,13 @@ void ShowErrorUtf(char* msg) { void ShowMessageInline(const MCONTACT hContact, const TCHAR *msg) { TCHAR buff[1024]; mir_sntprintf(buff, SIZEOF(buff), _T("%s%s"), TranslateT(LANG_INLINE_PREFIX), msg); + T2Utf utf(buff); PROTORECVEVENT pre = {0}; pre.timestamp = time(0); - char *utf = mir_utf8encodeT(buff); pre.szMessage = utf; pre.flags = PREF_BYPASS_OTR; ProtoChainRecvMsg(hContact, &pre); - - mir_free(utf); } void ShowMessageInlineUtf(const MCONTACT hContact, const char *msg) { |