summaryrefslogtreecommitdiff
path: root/plugins/MirOTR
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2015-08-27 15:15:33 +0000
committerGeorge Hazan <george.hazan@gmail.com>2015-08-27 15:15:33 +0000
commitd6eee2018898f2442883a0aa77ad095b75572cfb (patch)
tree8fbfe32690b9b32e5d47b1958a02f6f6a5fbf000 /plugins/MirOTR
parent2d37d969153b5fad810984182f747755c1cbc616 (diff)
fix for 64-bit issues & warnings
git-svn-id: http://svn.miranda-ng.org/main/trunk@15043 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/MirOTR')
-rw-r--r--plugins/MirOTR/Libgpg-error/estream.c2
-rw-r--r--plugins/MirOTR/src/dbfilter.cpp2
-rw-r--r--plugins/MirOTR/src/dialogs.cpp656
-rw-r--r--plugins/MirOTR/src/options.cpp6
-rw-r--r--plugins/MirOTR/src/otr.cpp18
-rw-r--r--plugins/MirOTR/src/utils.cpp2
6 files changed, 348 insertions, 338 deletions
diff --git a/plugins/MirOTR/Libgpg-error/estream.c b/plugins/MirOTR/Libgpg-error/estream.c
index 42609ee6eb..f4bda2a1c0 100644
--- a/plugins/MirOTR/Libgpg-error/estream.c
+++ b/plugins/MirOTR/Libgpg-error/estream.c
@@ -4168,7 +4168,7 @@ tmpfd (void)
#ifdef HAVE_W32CE_SYSTEM
int fd = (int)file;
#else
- int fd = _open_osfhandle ((long)file, 0);
+ int fd = _open_osfhandle((INT_PTR)file, 0);
if (fd == -1)
{
CloseHandle (file);
diff --git a/plugins/MirOTR/src/dbfilter.cpp b/plugins/MirOTR/src/dbfilter.cpp
index 1f349a4c22..354a25e00d 100644
--- a/plugins/MirOTR/src/dbfilter.cpp
+++ b/plugins/MirOTR/src/dbfilter.cpp
@@ -202,7 +202,7 @@ int StatusModeChange(WPARAM wParam, LPARAM lParam)
ConnContext *context = otr_user_state->context_root;
while (context) {
if (context->msgstate == OTRL_MSGSTATE_ENCRYPTED && (proto == 0 || mir_strcmp(proto, context->protocol) == 0)) {
- MCONTACT hContact = (MCONTACT)context->app_data;
+ MCONTACT hContact = (UINT_PTR)context->app_data;
if (hContact) {
otrl_message_disconnect(otr_user_state, &ops, (void*)hContact, context->accountname, context->protocol, context->username, OTRL_INSTAG_BEST);
diff --git a/plugins/MirOTR/src/dialogs.cpp b/plugins/MirOTR/src/dialogs.cpp
index 76a690976e..898cffe408 100644
--- a/plugins/MirOTR/src/dialogs.cpp
+++ b/plugins/MirOTR/src/dialogs.cpp
@@ -1,6 +1,7 @@
#include "stdafx.h"
-struct SmpData {
+struct SmpData
+{
HWND dialog;
TrustLevel oldlevel;
ConnContext *context;
@@ -13,23 +14,23 @@ SmpForContactMap smp_for_contact;
INT_PTR CALLBACK DlgSMPUpdateProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- switch ( msg ) {
- case WM_DESTROY:{
- ConnContext *context = (ConnContext*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- if(context)
- otr_abort_smp(context);
- break;}
+ switch (msg) {
+ case WM_DESTROY: {
+ ConnContext *context = (ConnContext*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ if (context)
+ otr_abort_smp(context);
+ break; }
case WM_INITDIALOG:
{
if (!lParam) {
DestroyWindow(hwndDlg);
return FALSE;
}
- TranslateDialogDefault( hwndDlg );
+ TranslateDialogDefault(hwndDlg);
SmpData *data = (SmpData*)lParam;
ConnContext *context = data->context;
- MCONTACT hContact = (MCONTACT)context->app_data;
+ MCONTACT hContact = (UINT_PTR)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);
@@ -40,7 +41,7 @@ INT_PTR CALLBACK DlgSMPUpdateProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM
mir_free(data);
TCHAR title[512], *proto = mir_a2t(GetContactProto(hContact));
- const TCHAR *name =contact_get_nameT(hContact);
+ const TCHAR *name = contact_get_nameT(hContact);
mir_sntprintf(title, _countof(title), TranslateT(LANG_SMP_PROGRESS_TITLE), name, proto);
SetWindowText(hwndDlg, title);
mir_sntprintf(title, _countof(title), TranslateT(LANG_SMP_PROGRESS_DESC), name, proto);
@@ -51,32 +52,31 @@ INT_PTR CALLBACK DlgSMPUpdateProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM
// Move window to screen center
// Get the owner window and dialog box rectangles.
HWND hwndOwner; RECT rcOwner, rcDlg, rc;
- if ((hwndOwner = GetParent(hwndDlg)) == NULL)
- {
- hwndOwner = GetDesktopWindow();
+ if ((hwndOwner = GetParent(hwndDlg)) == NULL) {
+ hwndOwner = GetDesktopWindow();
}
- GetWindowRect(hwndOwner, &rcOwner);
- GetWindowRect(hwndDlg, &rcDlg);
- CopyRect(&rc, &rcOwner);
+ GetWindowRect(hwndOwner, &rcOwner);
+ GetWindowRect(hwndDlg, &rcDlg);
+ CopyRect(&rc, &rcOwner);
// Offset the owner and dialog box rectangles so that right and bottom
// values represent the width and height, and then offset the owner again
// to discard space taken up by the dialog box.
- OffsetRect(&rcDlg, -rcDlg.left, -rcDlg.top);
- OffsetRect(&rc, -rc.left, -rc.top);
- OffsetRect(&rc, -rcDlg.right, -rcDlg.bottom);
+ OffsetRect(&rcDlg, -rcDlg.left, -rcDlg.top);
+ OffsetRect(&rc, -rc.left, -rc.top);
+ OffsetRect(&rc, -rcDlg.right, -rcDlg.bottom);
// The new position is the sum of half the remaining space and the owner's
// original position.
- SetWindowPos(hwndDlg,
- HWND_TOP,
- rcOwner.left + (rc.right / 2),
- rcOwner.top + (rc.bottom / 2),
+ SetWindowPos(hwndDlg,
+ HWND_TOP,
+ rcOwner.left + (rc.right / 2),
+ rcOwner.top + (rc.bottom / 2),
0, 0, // Ignores size arguments.
- SWP_NOSIZE);
+ SWP_NOSIZE);
// end center dialog
@@ -94,50 +94,50 @@ INT_PTR CALLBACK DlgSMPUpdateProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM
ConnContext *context = (ConnContext*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
SendDlgItemMessage(hwndDlg, IDC_PGB_SMP, PBM_SETPOS, wParam, 0);
switch (wParam) {
- case 0:
+ case 0:
+ EnableWindow(GetDlgItem(hwndDlg, IDCANCEL), false);
+ EnableWindow(GetDlgItem(hwndDlg, IDOK), true);
+ SetDlgItemText(hwndDlg, IDC_STC_SMP_PROGRESS, TranslateT(LANG_SMP_ERROR));
+ smp_for_contact.erase(context->app_data);
+ break;
+ case 100:
+ {
EnableWindow(GetDlgItem(hwndDlg, IDCANCEL), false);
EnableWindow(GetDlgItem(hwndDlg, IDOK), true);
- SetDlgItemText(hwndDlg, IDC_STC_SMP_PROGRESS, TranslateT(LANG_SMP_ERROR));
smp_for_contact.erase(context->app_data);
- break;
- case 100:
- {
- EnableWindow(GetDlgItem(hwndDlg, IDCANCEL), false);
- 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));
- }
+ 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_FAILED));
+ SetDlgItemText(hwndDlg, IDC_STC_SMP_PROGRESS, TranslateT(LANG_SMP_SUCCESS_VERIFY));
}
}
- break;
- default:
- SetDlgItemText(hwndDlg, IDC_STC_SMP_PROGRESS, _T(""));
+ else {
+ SetDlgItemText(hwndDlg, IDC_STC_SMP_PROGRESS, TranslateT(LANG_SMP_FAILED));
+ }
+ }
+ break;
+ default:
+ SetDlgItemText(hwndDlg, IDC_STC_SMP_PROGRESS, _T(""));
}
}
break;
- case WM_COMMAND:
- switch ( HIWORD( wParam )) {
- case BN_CLICKED:
- {
- ConnContext *context = (ConnContext*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- switch ( LOWORD( wParam )) {
- case IDOK:
- smp_for_contact.erase(context->app_data);
- SetWindowLongPtr(hwndDlg, GWLP_USERDATA, NULL);
- case IDCANCEL:
- DestroyWindow(hwndDlg);
- break;
- }
- }break;
+ case WM_COMMAND:
+ switch (HIWORD(wParam)) {
+ case BN_CLICKED:
+ {
+ ConnContext *context = (ConnContext*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ switch (LOWORD(wParam)) {
+ case IDOK:
+ smp_for_contact.erase(context->app_data);
+ SetWindowLongPtr(hwndDlg, GWLP_USERDATA, NULL);
+ case IDCANCEL:
+ DestroyWindow(hwndDlg);
+ break;
+ }
+ }break;
}
}
@@ -145,34 +145,35 @@ INT_PTR CALLBACK DlgSMPUpdateProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM
return FALSE;
}
-void SMPInitUpdateDialog(ConnContext *context, bool responder) {
+void SMPInitUpdateDialog(ConnContext *context, bool responder)
+{
if (!context) return;
SmpData *data = (SmpData*)mir_calloc(sizeof(SmpData));
data->context = context;
data->oldlevel = otr_context_get_trust(context);
data->responder = responder;
- CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_SMP_PROGRESS), 0, DlgSMPUpdateProc, (LPARAM) data);
+ CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_SMP_PROGRESS), 0, DlgSMPUpdateProc, (LPARAM)data);
}
INT_PTR CALLBACK DlgSMPResponseProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- switch ( msg ) {
- case WM_DESTROY:{
- ConnContext *context = (ConnContext*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- if(context)
- otr_abort_smp(context);
- break;}
- case WM_INITDIALOG:
+ switch (msg) {
+ case WM_DESTROY: {
+ ConnContext *context = (ConnContext*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ if (context)
+ otr_abort_smp(context);
+ break; }
+ case WM_INITDIALOG:
{
if (!lParam) {
DestroyWindow(hwndDlg);
return FALSE;
}
- TranslateDialogDefault( hwndDlg );
+ TranslateDialogDefault(hwndDlg);
SmpData *data = (SmpData*)lParam;
ConnContext *context = data->context;
- MCONTACT hContact = (MCONTACT)context->app_data;
+ MCONTACT hContact = (UINT_PTR)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);
@@ -207,7 +208,8 @@ INT_PTR CALLBACK DlgSMPResponseProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
ShowWindow(GetDlgItem(hwndDlg, IDNO), SW_HIDE);
mir_free(data->question);
- } else {
+ }
+ else {
mir_sntprintf(buff, TranslateT(LANG_OTR_SMPPASSWORD_RESPOND_DESC), contact_get_nameT(hContact));
SetDlgItemText(hwndDlg, IDC_STC_SMP_INFO, buff);
@@ -230,51 +232,50 @@ INT_PTR CALLBACK DlgSMPResponseProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
// Move window to screen center
// Get the owner window and dialog box rectangles.
HWND hwndOwner; RECT rcOwner, rcDlg, rc;
- if ((hwndOwner = GetParent(hwndDlg)) == NULL)
- {
- hwndOwner = GetDesktopWindow();
+ if ((hwndOwner = GetParent(hwndDlg)) == NULL) {
+ hwndOwner = GetDesktopWindow();
}
- GetWindowRect(hwndOwner, &rcOwner);
- GetWindowRect(hwndDlg, &rcDlg);
- CopyRect(&rc, &rcOwner);
+ GetWindowRect(hwndOwner, &rcOwner);
+ GetWindowRect(hwndDlg, &rcDlg);
+ CopyRect(&rc, &rcOwner);
// Offset the owner and dialog box rectangles so that right and bottom
// values represent the width and height, and then offset the owner again
// to discard space taken up by the dialog box.
- OffsetRect(&rcDlg, -rcDlg.left, -rcDlg.top);
- OffsetRect(&rc, -rc.left, -rc.top);
- OffsetRect(&rc, -rcDlg.right, -rcDlg.bottom);
+ OffsetRect(&rcDlg, -rcDlg.left, -rcDlg.top);
+ OffsetRect(&rc, -rc.left, -rc.top);
+ OffsetRect(&rc, -rcDlg.right, -rcDlg.bottom);
// The new position is the sum of half the remaining space and the owner's
// original position.
- SetWindowPos(hwndDlg,
- HWND_TOP,
- rcOwner.left + (rc.right / 2),
- rcOwner.top + (rc.bottom / 2),
+ SetWindowPos(hwndDlg,
+ HWND_TOP,
+ rcOwner.left + (rc.right / 2),
+ rcOwner.top + (rc.bottom / 2),
0, 0, // Ignores size arguments.
- SWP_NOSIZE);
+ SWP_NOSIZE);
// end center dialog
-
-
+
+
return TRUE;
}
- case WM_COMMAND:
- switch ( HIWORD( wParam )) {
- case BN_CLICKED:
+ case WM_COMMAND:
+ switch (HIWORD(wParam)) {
+ case BN_CLICKED:
ConnContext *context = (ConnContext *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- switch ( LOWORD( wParam )) {
+ 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);
+ 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));
@@ -311,14 +312,14 @@ void SMPInitResponseDialog(ConnContext *context, const TCHAR *question) {
INT_PTR CALLBACK DlgProcSMPInitProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- switch ( msg ) {
- case WM_INITDIALOG:
+ switch (msg) {
+ case WM_INITDIALOG:
{
if (!lParam) {
DestroyWindow(hwndDlg);
return FALSE;
}
- TranslateDialogDefault( hwndDlg );
+ TranslateDialogDefault(hwndDlg);
ConnContext *context = (ConnContext*)lParam;
if (smp_for_contact.find(context->app_data) != smp_for_contact.end()) {
@@ -326,7 +327,7 @@ INT_PTR CALLBACK DlgProcSMPInitProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
return FALSE;
}
- MCONTACT hContact = (MCONTACT)context->app_data;
+ MCONTACT hContact = (UINT_PTR)context->app_data;
TCHAR title[512], *proto = mir_a2t(GetContactProto(hContact));
mir_sntprintf(title, _countof(title), TranslateT(LANG_SMP_VERIFY_TITLE), contact_get_nameT(hContact), proto);
mir_free(proto);
@@ -337,32 +338,31 @@ INT_PTR CALLBACK DlgProcSMPInitProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
// Move window to screen center
// Get the owner window and dialog box rectangles.
HWND hwndOwner; RECT rcOwner, rcDlg, rc;
- if ((hwndOwner = GetParent(hwndDlg)) == NULL)
- {
- hwndOwner = GetDesktopWindow();
+ if ((hwndOwner = GetParent(hwndDlg)) == NULL) {
+ hwndOwner = GetDesktopWindow();
}
- GetWindowRect(hwndOwner, &rcOwner);
- GetWindowRect(hwndDlg, &rcDlg);
- CopyRect(&rc, &rcOwner);
+ GetWindowRect(hwndOwner, &rcOwner);
+ GetWindowRect(hwndDlg, &rcDlg);
+ CopyRect(&rc, &rcOwner);
// Offset the owner and dialog box rectangles so that right and bottom
// values represent the width and height, and then offset the owner again
// to discard space taken up by the dialog box.
- OffsetRect(&rcDlg, -rcDlg.left, -rcDlg.top);
- OffsetRect(&rc, -rc.left, -rc.top);
- OffsetRect(&rc, -rcDlg.right, -rcDlg.bottom);
+ OffsetRect(&rcDlg, -rcDlg.left, -rcDlg.top);
+ OffsetRect(&rc, -rc.left, -rc.top);
+ OffsetRect(&rc, -rcDlg.right, -rcDlg.bottom);
// The new position is the sum of half the remaining space and the owner's
// original position.
- SetWindowPos(hwndDlg,
- HWND_TOP,
- rcOwner.left + (rc.right / 2),
- rcOwner.top + (rc.bottom / 2),
+ SetWindowPos(hwndDlg,
+ HWND_TOP,
+ rcOwner.left + (rc.right / 2),
+ rcOwner.top + (rc.bottom / 2),
0, 0, // Ignores size arguments.
- SWP_NOSIZE);
+ SWP_NOSIZE);
// end center dialog
@@ -374,7 +374,7 @@ INT_PTR CALLBACK DlgProcSMPInitProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
SendMessage(cmb, CB_SELECTSTRING, -1, (WPARAM)TranslateT(LANG_SMPTYPE_QUESTION));
EnableWindow(GetDlgItem(hwndDlg, IDC_CBO_SMP_CHOOSE), TRUE);
-
+
Fingerprint *fp = context->active_fingerprint;
if (!fp) {
DestroyWindow(hwndDlg);
@@ -391,172 +391,179 @@ INT_PTR CALLBACK DlgProcSMPInitProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
SetDlgItemText(hwndDlg, IDC_EDT_SMP_FIELD1, _T(""));
SendDlgItemMessage(hwndDlg, IDC_EDT_SMP_FIELD1, EM_SETREADONLY, FALSE, 0);
SetDlgItemText(hwndDlg, IDC_STC_SMP_FIELD1, TranslateT(LANG_SMP_QUESTION));
-
+
SetDlgItemText(hwndDlg, IDC_EDT_SMP_FIELD2, _T(""));
SendDlgItemMessage(hwndDlg, IDC_EDT_SMP_FIELD2, EM_SETREADONLY, FALSE, 0);
SetDlgItemText(hwndDlg, IDC_STC_SMP_FIELD2, TranslateT(LANG_SMP_ANSWER));
-
+
ShowWindow(GetDlgItem(hwndDlg, IDOK), SW_SHOWNA);
ShowWindow(GetDlgItem(hwndDlg, IDYES), SW_HIDE);
ShowWindow(GetDlgItem(hwndDlg, IDNO), SW_HIDE);
SetFocus(GetDlgItem(hwndDlg, IDC_CBO_SMP_CHOOSE));
-
+
return FALSE;
}
- case WM_COMMAND:
- switch ( HIWORD( wParam )) {
- case BN_CLICKED:
- {
- ConnContext *context = (ConnContext*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- MCONTACT hContact = (MCONTACT)context->app_data;
- TCHAR msg[1024];
- switch ( LOWORD( wParam )) {
- case IDCANCEL:
- DestroyWindow(hwndDlg);
- break;
- case IDOK:
- GetDlgItemText(hwndDlg, IDC_CBO_SMP_CHOOSE, msg, 255);
- 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, _countof(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);
- TCHAR *question = new TCHAR[len+1];
- GetDlgItemText(hwndDlg, IDC_EDT_SMP_FIELD1, question, len+1);
- 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);
- T2Utf ans(answer);
- delete answer;
-
- SMPInitUpdateDialog(context, false);
- otr_start_smp(context, quest, (const unsigned char*)ans, mir_strlen(ans));
- }
-
- }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, _countof(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);
- T2Utf ans(answer);
- delete[] answer;
-
- SMPInitUpdateDialog(context, false);
- otr_start_smp(context, NULL, (const unsigned char*)ans, mir_strlen(ans));
- }
-
- }else break;
- DestroyWindow(hwndDlg);
- break;
- case IDYES:
- VerifyFingerprint(context, true);
- DestroyWindow(hwndDlg);
- break;
- case IDNO:
- VerifyFingerprint(context, false);
- DestroyWindow(hwndDlg);
- break;
+ case WM_COMMAND:
+ switch (HIWORD(wParam)) {
+ case BN_CLICKED:
+ {
+ ConnContext *context = (ConnContext*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ MCONTACT hContact = (UINT_PTR)context->app_data;
+ TCHAR msg[1024];
+ switch (LOWORD(wParam)) {
+ case IDCANCEL:
+ DestroyWindow(hwndDlg);
+ break;
+ case IDOK:
+ GetDlgItemText(hwndDlg, IDC_CBO_SMP_CHOOSE, msg, 255);
+ 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, _countof(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);
+ TCHAR *question = new TCHAR[len + 1];
+ GetDlgItemText(hwndDlg, IDC_EDT_SMP_FIELD1, question, len + 1);
+ 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);
+ T2Utf ans(answer);
+ delete answer;
+
+ SMPInitUpdateDialog(context, false);
+ otr_start_smp(context, quest, (const unsigned char*)ans, mir_strlen(ans));
}
- break;
- case CBN_SELCHANGE:
- switch ( LOWORD( wParam )) {
- case IDC_CBO_SMP_CHOOSE:
- {
- ConnContext *context = (ConnContext*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- MCONTACT hContact = (MCONTACT)context->app_data;
- Fingerprint *fp = context->active_fingerprint;
- if (!fp) {
- DestroyWindow(hwndDlg);
- return TRUE;
- }
- BOOL trusted = false;
- if (fp->trust && fp->trust[0] != '\0') trusted = true;
-
- TCHAR buff[512];
- GetDlgItemText(hwndDlg, IDC_CBO_SMP_CHOOSE, buff, 255);
- if (_tcsncmp(buff, TranslateT(LANG_SMPTYPE_QUESTION), 255)==0) {
- if (trusted)
- mir_sntprintf(buff, TranslateT(LANG_OTR_SMPQUESTION_VERIFIED_DESC), contact_get_nameT(hContact));
- else
- mir_sntprintf(buff, TranslateT(LANG_OTR_SMPQUESTION_VERIFY_DESC), contact_get_nameT(hContact));
-
- SetDlgItemText(hwndDlg, IDC_STC_SMP_INFO, buff);
-
- SetDlgItemText(hwndDlg, IDC_EDT_SMP_FIELD1, _T(""));
- SendDlgItemMessage(hwndDlg, IDC_EDT_SMP_FIELD1, EM_SETREADONLY, FALSE, 0);
- SetDlgItemText(hwndDlg, IDC_STC_SMP_FIELD1, TranslateT(LANG_SMP_QUESTION));
-
- SetDlgItemText(hwndDlg, IDC_EDT_SMP_FIELD2, _T(""));
- SendDlgItemMessage(hwndDlg, IDC_EDT_SMP_FIELD2, EM_SETREADONLY, FALSE, 0);
- SetDlgItemText(hwndDlg, IDC_STC_SMP_FIELD2, TranslateT(LANG_SMP_ANSWER));
-
-
- ShowWindow(GetDlgItem(hwndDlg, IDOK), SW_SHOWNA);
- ShowWindow(GetDlgItem(hwndDlg, IDYES), SW_HIDE);
- ShowWindow(GetDlgItem(hwndDlg, IDNO), SW_HIDE);
- } else if (_tcsncmp(buff, TranslateT(LANG_SMPTYPE_PASSWORD), 255)==0) {
- if (trusted)
- mir_sntprintf(buff, TranslateT(LANG_OTR_SMPPASSWORD_VERIFIED_DESC), contact_get_nameT(hContact));
- else
- mir_sntprintf(buff, TranslateT(LANG_OTR_SMPPASSWORD_VERIFY_DESC), contact_get_nameT(hContact));
-
- SetDlgItemText(hwndDlg, IDC_STC_SMP_INFO, buff);
-
- SetDlgItemText(hwndDlg, IDC_EDT_SMP_FIELD1, _T(""));
- SendDlgItemMessage(hwndDlg, IDC_EDT_SMP_FIELD1, EM_SETREADONLY, TRUE, 0);
- SetDlgItemText(hwndDlg, IDC_STC_SMP_FIELD1, _T(""));
-
- SetDlgItemText(hwndDlg, IDC_EDT_SMP_FIELD2, _T(""));
- SendDlgItemMessage(hwndDlg, IDC_EDT_SMP_FIELD2, EM_SETREADONLY, FALSE, 0);
- SetDlgItemText(hwndDlg, IDC_STC_SMP_FIELD2, TranslateT(LANG_SMP_PASSWORD));
-
-
- ShowWindow(GetDlgItem(hwndDlg, IDOK), SW_SHOWNA);
- ShowWindow(GetDlgItem(hwndDlg, IDYES), SW_HIDE);
- ShowWindow(GetDlgItem(hwndDlg, IDNO), SW_HIDE);
- } else if (_tcsncmp(buff, TranslateT(LANG_SMPTYPE_FINGERPRINT), 255)==0) {
- if (trusted)
- mir_sntprintf(buff, TranslateT(LANG_OTR_FPVERIFIED_DESC), contact_get_nameT(hContact));
- else
- mir_sntprintf(buff, TranslateT(LANG_OTR_FPVERIFY_DESC), contact_get_nameT(hContact));
-
- SetDlgItemText(hwndDlg, IDC_STC_SMP_INFO, buff);
-
- unsigned char hash[20];
- lib_cs_lock();
- if (!otrl_privkey_fingerprint_raw(otr_user_state, hash, context->accountname, context->protocol)) {
- DestroyWindow(hwndDlg);
- return FALSE;
- }
- otrl_privkey_hash_to_humanT(buff, hash);
- SetDlgItemText(hwndDlg, IDC_EDT_SMP_FIELD1, buff);
- SendDlgItemMessage(hwndDlg, IDC_EDT_SMP_FIELD1, EM_SETREADONLY, TRUE, 0);
- SetDlgItemText(hwndDlg, IDC_STC_SMP_FIELD1, TranslateT(LANG_YOUR_PRIVKEY));
-
- otrl_privkey_hash_to_humanT(buff, fp->fingerprint);
- SetDlgItemText(hwndDlg, IDC_EDT_SMP_FIELD2, buff);
- SendDlgItemMessage(hwndDlg, IDC_EDT_SMP_FIELD2, EM_SETREADONLY, TRUE, 0);
- SetDlgItemText(hwndDlg, IDC_STC_SMP_FIELD2, TranslateT(LANG_CONTACT_FINGERPRINT));
-
- ShowWindow(GetDlgItem(hwndDlg, IDOK), SW_HIDE);
- ShowWindow(GetDlgItem(hwndDlg, IDYES), SW_SHOWNA);
- ShowWindow(GetDlgItem(hwndDlg, IDNO), SW_SHOWNA);
-
- }
- }break;
+
+ }
+ 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, _countof(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);
+ T2Utf ans(answer);
+ delete[] answer;
+
+ SMPInitUpdateDialog(context, false);
+ otr_start_smp(context, NULL, (const unsigned char*)ans, mir_strlen(ans));
+ }
+
+ }
+ else break;
+ DestroyWindow(hwndDlg);
+ break;
+ case IDYES:
+ VerifyFingerprint(context, true);
+ DestroyWindow(hwndDlg);
+ break;
+ case IDNO:
+ VerifyFingerprint(context, false);
+ DestroyWindow(hwndDlg);
+ break;
}
+ }
+ break;
+
+ case CBN_SELCHANGE:
+ switch (LOWORD(wParam)) {
+ case IDC_CBO_SMP_CHOOSE:
+ {
+ ConnContext *context = (ConnContext*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ MCONTACT hContact = (UINT_PTR)context->app_data;
+ Fingerprint *fp = context->active_fingerprint;
+ if (!fp) {
+ DestroyWindow(hwndDlg);
+ return TRUE;
+ }
+ BOOL trusted = false;
+ if (fp->trust && fp->trust[0] != '\0') trusted = true;
+
+ TCHAR buff[512];
+ GetDlgItemText(hwndDlg, IDC_CBO_SMP_CHOOSE, buff, 255);
+ if (_tcsncmp(buff, TranslateT(LANG_SMPTYPE_QUESTION), 255) == 0) {
+ if (trusted)
+ mir_sntprintf(buff, TranslateT(LANG_OTR_SMPQUESTION_VERIFIED_DESC), contact_get_nameT(hContact));
+ else
+ mir_sntprintf(buff, TranslateT(LANG_OTR_SMPQUESTION_VERIFY_DESC), contact_get_nameT(hContact));
+
+ SetDlgItemText(hwndDlg, IDC_STC_SMP_INFO, buff);
+
+ SetDlgItemText(hwndDlg, IDC_EDT_SMP_FIELD1, _T(""));
+ SendDlgItemMessage(hwndDlg, IDC_EDT_SMP_FIELD1, EM_SETREADONLY, FALSE, 0);
+ SetDlgItemText(hwndDlg, IDC_STC_SMP_FIELD1, TranslateT(LANG_SMP_QUESTION));
+
+ SetDlgItemText(hwndDlg, IDC_EDT_SMP_FIELD2, _T(""));
+ SendDlgItemMessage(hwndDlg, IDC_EDT_SMP_FIELD2, EM_SETREADONLY, FALSE, 0);
+ SetDlgItemText(hwndDlg, IDC_STC_SMP_FIELD2, TranslateT(LANG_SMP_ANSWER));
+
+
+ ShowWindow(GetDlgItem(hwndDlg, IDOK), SW_SHOWNA);
+ ShowWindow(GetDlgItem(hwndDlg, IDYES), SW_HIDE);
+ ShowWindow(GetDlgItem(hwndDlg, IDNO), SW_HIDE);
+ }
+ else if (_tcsncmp(buff, TranslateT(LANG_SMPTYPE_PASSWORD), 255) == 0) {
+ if (trusted)
+ mir_sntprintf(buff, TranslateT(LANG_OTR_SMPPASSWORD_VERIFIED_DESC), contact_get_nameT(hContact));
+ else
+ mir_sntprintf(buff, TranslateT(LANG_OTR_SMPPASSWORD_VERIFY_DESC), contact_get_nameT(hContact));
+
+ SetDlgItemText(hwndDlg, IDC_STC_SMP_INFO, buff);
+
+ SetDlgItemText(hwndDlg, IDC_EDT_SMP_FIELD1, _T(""));
+ SendDlgItemMessage(hwndDlg, IDC_EDT_SMP_FIELD1, EM_SETREADONLY, TRUE, 0);
+ SetDlgItemText(hwndDlg, IDC_STC_SMP_FIELD1, _T(""));
+
+ SetDlgItemText(hwndDlg, IDC_EDT_SMP_FIELD2, _T(""));
+ SendDlgItemMessage(hwndDlg, IDC_EDT_SMP_FIELD2, EM_SETREADONLY, FALSE, 0);
+ SetDlgItemText(hwndDlg, IDC_STC_SMP_FIELD2, TranslateT(LANG_SMP_PASSWORD));
+
+
+ ShowWindow(GetDlgItem(hwndDlg, IDOK), SW_SHOWNA);
+ ShowWindow(GetDlgItem(hwndDlg, IDYES), SW_HIDE);
+ ShowWindow(GetDlgItem(hwndDlg, IDNO), SW_HIDE);
+ }
+ else if (_tcsncmp(buff, TranslateT(LANG_SMPTYPE_FINGERPRINT), 255) == 0) {
+ if (trusted)
+ mir_sntprintf(buff, TranslateT(LANG_OTR_FPVERIFIED_DESC), contact_get_nameT(hContact));
+ else
+ mir_sntprintf(buff, TranslateT(LANG_OTR_FPVERIFY_DESC), contact_get_nameT(hContact));
+
+ SetDlgItemText(hwndDlg, IDC_STC_SMP_INFO, buff);
+
+ unsigned char hash[20];
+ lib_cs_lock();
+ if (!otrl_privkey_fingerprint_raw(otr_user_state, hash, context->accountname, context->protocol)) {
+ DestroyWindow(hwndDlg);
+ return FALSE;
+ }
+ otrl_privkey_hash_to_humanT(buff, hash);
+ SetDlgItemText(hwndDlg, IDC_EDT_SMP_FIELD1, buff);
+ SendDlgItemMessage(hwndDlg, IDC_EDT_SMP_FIELD1, EM_SETREADONLY, TRUE, 0);
+ SetDlgItemText(hwndDlg, IDC_STC_SMP_FIELD1, TranslateT(LANG_YOUR_PRIVKEY));
+
+ otrl_privkey_hash_to_humanT(buff, fp->fingerprint);
+ SetDlgItemText(hwndDlg, IDC_EDT_SMP_FIELD2, buff);
+ SendDlgItemMessage(hwndDlg, IDC_EDT_SMP_FIELD2, EM_SETREADONLY, TRUE, 0);
+ SetDlgItemText(hwndDlg, IDC_STC_SMP_FIELD2, TranslateT(LANG_CONTACT_FINGERPRINT));
+
+ ShowWindow(GetDlgItem(hwndDlg, IDOK), SW_HIDE);
+ ShowWindow(GetDlgItem(hwndDlg, IDYES), SW_SHOWNA);
+ ShowWindow(GetDlgItem(hwndDlg, IDNO), SW_SHOWNA);
+
+ }
+ }break;
+ }
}
break;
@@ -564,19 +571,21 @@ INT_PTR CALLBACK DlgProcSMPInitProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
return FALSE;
}
-void SMPInitDialog(ConnContext *context) {
+void SMPInitDialog(ConnContext *context)
+{
if (context)
- CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_SMP_INPUT), 0, DlgProcSMPInitProc, (LPARAM) context);
+ CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_SMP_INPUT), 0, DlgProcSMPInitProc, (LPARAM)context);
}
-void SMPDialogUpdate(ConnContext *context, int percent) {
+void SMPDialogUpdate(ConnContext *context, int percent)
+{
if (!context) return;
SmpForContactMap::iterator it = smp_for_contact.find(context->app_data);
if (it == smp_for_contact.end()) return;
if (it->second.dialog) PostMessage(it->second.dialog, WMU_REFRESHSMP, percent, 0);
TrustLevel level = otr_context_get_trust(context);
if (!it->second.responder && it->second.oldlevel != level) {
- if (level == TRUST_PRIVATE)
+ if (level == TRUST_PRIVATE)
VerifyFingerprintMessage(context, true);
else if (level == TRUST_UNVERIFIED)
VerifyFingerprintMessage(context, false);
@@ -597,13 +606,14 @@ void SMPDialogUpdate(ConnContext *context, int percent) {
}
*/
}
-void SMPDialogReply(ConnContext *context, const char* question){
+void SMPDialogReply(ConnContext *context, const char* question)
+{
SmpData *data = (SmpData*)mir_calloc(sizeof(SmpData));
data->context = context;
data->oldlevel = TRUST_NOT_PRIVATE;
data->responder = true;
data->question = (question) ? mir_utf8decodeT(question) : NULL;
- CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_SMP_INPUT), 0, DlgSMPResponseProc, (LPARAM) data);
+ CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_SMP_INPUT), 0, DlgSMPResponseProc, (LPARAM)data);
/*
ShowError(_T("SMP requires user password (NOT IMPL YET)"));
otr_abort_smp(context);
@@ -612,15 +622,16 @@ void SMPDialogReply(ConnContext *context, const char* question){
}
unsigned int CALLBACK verify_context_thread(void *param);
-void VerifyContextDialog(ConnContext* context) {
+void VerifyContextDialog(ConnContext* context)
+{
if (!context) return;
CloseHandle((HANDLE)_beginthreadex(0, 0, verify_context_thread, context, 0, 0));
}
INT_PTR CALLBACK DlgBoxProcVerifyContext(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- switch ( msg ) {
- case WM_INITDIALOG:
+ switch (msg) {
+ case WM_INITDIALOG:
{
if (!lParam) {
EndDialog(hwndDlg, IDCANCEL);
@@ -628,43 +639,42 @@ INT_PTR CALLBACK DlgBoxProcVerifyContext(HWND hwndDlg, UINT msg, WPARAM wParam,
}
SetWindowText(hwndDlg, _T(LANG_OTR_FPVERIFY_TITLE));
SetDlgItemText(hwndDlg, IDC_STC_SMP_HEAD, _T(LANG_OTR_FPVERIFY_TITLE));
- TranslateDialogDefault( hwndDlg );
+ TranslateDialogDefault(hwndDlg);
SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
// Move window to screen center
// Get the owner window and dialog box rectangles.
HWND hwndOwner; RECT rcOwner, rcDlg, rc;
- if ((hwndOwner = GetParent(hwndDlg)) == NULL)
- {
- hwndOwner = GetDesktopWindow();
+ if ((hwndOwner = GetParent(hwndDlg)) == NULL) {
+ hwndOwner = GetDesktopWindow();
}
- GetWindowRect(hwndOwner, &rcOwner);
- GetWindowRect(hwndDlg, &rcDlg);
- CopyRect(&rc, &rcOwner);
+ GetWindowRect(hwndOwner, &rcOwner);
+ GetWindowRect(hwndDlg, &rcDlg);
+ CopyRect(&rc, &rcOwner);
// Offset the owner and dialog box rectangles so that right and bottom
// values represent the width and height, and then offset the owner again
// to discard space taken up by the dialog box.
- OffsetRect(&rcDlg, -rcDlg.left, -rcDlg.top);
- OffsetRect(&rc, -rc.left, -rc.top);
- OffsetRect(&rc, -rcDlg.right, -rcDlg.bottom);
+ OffsetRect(&rcDlg, -rcDlg.left, -rcDlg.top);
+ OffsetRect(&rc, -rc.left, -rc.top);
+ OffsetRect(&rc, -rcDlg.right, -rcDlg.bottom);
// The new position is the sum of half the remaining space and the owner's
// original position.
- SetWindowPos(hwndDlg,
- HWND_TOP,
- rcOwner.left + (rc.right / 2),
- rcOwner.top + (rc.bottom / 2),
+ SetWindowPos(hwndDlg,
+ HWND_TOP,
+ rcOwner.left + (rc.right / 2),
+ rcOwner.top + (rc.bottom / 2),
0, 0, // Ignores size arguments.
- SWP_NOSIZE);
+ SWP_NOSIZE);
// end center dialog
ConnContext *context = (ConnContext*)lParam;
- MCONTACT hContact = (MCONTACT) context->app_data;
+ MCONTACT hContact = (UINT_PTR)context->app_data;
Fingerprint *fp = context->active_fingerprint;
if (!fp) {
EndDialog(hwndDlg, IDCANCEL);
@@ -688,7 +698,7 @@ INT_PTR CALLBACK DlgBoxProcVerifyContext(HWND hwndDlg, UINT msg, WPARAM wParam,
SetDlgItemText(hwndDlg, IDC_EDT_SMP_FIELD1, buff);
SendDlgItemMessage(hwndDlg, IDC_EDT_SMP_FIELD1, EM_SETREADONLY, TRUE, 0);
SetDlgItemText(hwndDlg, IDC_STC_SMP_FIELD1, TranslateT(LANG_YOUR_PRIVKEY));
-
+
otrl_privkey_hash_to_humanT(buff, fp->fingerprint);
SetDlgItemText(hwndDlg, IDC_EDT_SMP_FIELD2, buff);
SendDlgItemMessage(hwndDlg, IDC_EDT_SMP_FIELD2, EM_SETREADONLY, TRUE, 0);
@@ -700,21 +710,20 @@ INT_PTR CALLBACK DlgBoxProcVerifyContext(HWND hwndDlg, UINT msg, WPARAM wParam,
ShowWindow(GetDlgItem(hwndDlg, IDYES), SW_SHOWNA);
ShowWindow(GetDlgItem(hwndDlg, IDNO), SW_SHOWNA);
SetFocus(GetDlgItem(hwndDlg, IDCANCEL));
-
- return FALSE;
}
+ return FALSE;
- case WM_COMMAND:
- switch ( HIWORD( wParam )) {
- case BN_CLICKED:
- switch ( LOWORD( wParam )) {
- case IDYES:
- case IDNO:
- case IDCANCEL:
- case IDOK:
- EndDialog(hwndDlg, LOWORD( wParam ));
- break;
- }
+ case WM_COMMAND:
+ switch (HIWORD(wParam)) {
+ case BN_CLICKED:
+ switch (LOWORD(wParam)) {
+ case IDYES:
+ case IDNO:
+ case IDCANCEL:
+ case IDOK:
+ EndDialog(hwndDlg, LOWORD(wParam));
+ break;
+ }
}
break;
@@ -725,33 +734,34 @@ INT_PTR CALLBACK DlgBoxProcVerifyContext(HWND hwndDlg, UINT msg, WPARAM wParam,
unsigned int CALLBACK verify_context_thread(void *param)
{
- Thread_Push( 0 );
+ Thread_Push(0);
if (param) {
ConnContext *context = (ConnContext *)param;
- MCONTACT hContact = (MCONTACT)context->app_data;
+ MCONTACT hContact = (UINT_PTR)context->app_data;
TCHAR msg[1024];
- switch ( DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_SMP_INPUT), 0, DlgBoxProcVerifyContext, (LPARAM)param) ) {
- case IDOK:
- case IDYES:
- lib_cs_lock();
- otrl_context_set_trust(context->active_fingerprint, "verified");
- otrl_privkey_write_fingerprints(otr_user_state, _T2A(g_fingerprint_store_filename));
- mir_sntprintf(msg, _countof(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, _T2A(g_fingerprint_store_filename));
- mir_sntprintf(msg, _countof(msg), TranslateT(LANG_FINGERPRINT_NOT_VERIFIED), contact_get_nameT(hContact));
- ShowMessage(hContact, msg);
- SetEncryptionStatus(hContact, otr_context_get_trust(context));
- break;
+ switch (DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_SMP_INPUT), 0, DlgBoxProcVerifyContext, (LPARAM)param)) {
+ case IDOK:
+ case IDYES:
+ lib_cs_lock();
+ otrl_context_set_trust(context->active_fingerprint, "verified");
+ otrl_privkey_write_fingerprints(otr_user_state, _T2A(g_fingerprint_store_filename));
+ mir_sntprintf(msg, _countof(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, _T2A(g_fingerprint_store_filename));
+ mir_sntprintf(msg, _countof(msg), TranslateT(LANG_FINGERPRINT_NOT_VERIFIED), contact_get_nameT(hContact));
+ ShowMessage(hContact, msg);
+ SetEncryptionStatus(hContact, otr_context_get_trust(context));
+ break;
}
}
Thread_Pop();
- return 0;
+ return 0;
}
diff --git a/plugins/MirOTR/src/options.cpp b/plugins/MirOTR/src/options.cpp
index ef55726f0c..2c727f9fbb 100644
--- a/plugins/MirOTR/src/options.cpp
+++ b/plugins/MirOTR/src/options.cpp
@@ -681,7 +681,7 @@ static INT_PTR CALLBACK DlgProcMirOTROptsFinger(HWND hwndDlg, UINT msg, WPARAM w
TCHAR *user, hash[45] = { 0 };
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);
+ user = (TCHAR*)contact_get_nameT((UINT_PTR)context->app_data);
if (user) {
PROTOACCOUNT *pa = Proto_GetAccount(context->protocol);
@@ -746,7 +746,7 @@ 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;
+ MCONTACT hContact = (UINT_PTR)fp->context->app_data;
TCHAR buff[1024], hash[45];
otrl_privkey_hash_to_humanT(hash, fp->fingerprint);
PROTOACCOUNT *pa = Proto_GetAccount(GetContactProto(hContact));
@@ -777,7 +777,7 @@ 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;
+ MCONTACT hContact = (UINT_PTR)it->first->context->app_data;
TCHAR buff[1024], hash[45];
otrl_privkey_hash_to_humanT(hash, it->first->fingerprint);
PROTOACCOUNT *pa = Proto_GetAccount(GetContactProto(hContact));
diff --git a/plugins/MirOTR/src/otr.cpp b/plugins/MirOTR/src/otr.cpp
index 26a4a9423d..1b6ff83f83 100644
--- a/plugins/MirOTR/src/otr.cpp
+++ b/plugins/MirOTR/src/otr.cpp
@@ -81,7 +81,7 @@ extern "C" {
/* Return the OTR policy for the given context. */
OtrlPolicy otr_gui_policy(void *opdata, ConnContext *context) {
DEBUGOUT_T("OTR_GUI_POLICY\n");
- MCONTACT hContact = (MCONTACT)opdata;
+ MCONTACT hContact = (UINT_PTR)opdata;
DWORD pol;
if (hContact) {
pol = db_get_dw(hContact, MODULENAME, "Policy", CONTACT_DEFAULT_POLICY);
@@ -106,7 +106,7 @@ extern "C" {
DEBUGOUT_T("OTR_GUI_CREATE_PRIVKEY\n");
if (opdata) {
mir_free((char*)protocol);
- protocol = mir_strdup(GetContactProto((MCONTACT)opdata));
+ protocol = mir_strdup(GetContactProto((UINT_PTR)opdata));
}
if (!protocol) return;
DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_GENKEYNOTIFY), 0, GenKeyDlgBoxProc, (LPARAM)protocol);
@@ -121,7 +121,7 @@ extern "C" {
* logged in" errors if you're wrong. */
int otr_gui_is_logged_in(void *opdata, const char *accountname, const char *protocol, const char *recipient) {
DEBUGOUT_T("OTR_GUI_IS_LOGGED_IN\n");
- MCONTACT hContact = (MCONTACT)opdata;
+ MCONTACT hContact = (UINT_PTR)opdata;
if (hContact) {
WORD status = db_get_w(hContact, GetContactProto(hContact), "Status", ID_STATUS_OFFLINE);
if (status == ID_STATUS_OFFLINE) return 0;
@@ -135,7 +135,7 @@ extern "C" {
* accountname/protocol. */
void otr_gui_inject_message(void *opdata, const char *accountname, const char *protocol, const char *recipient, const char *message) {
DEBUGOUT_T("OTR_GUI_INJECT_MESSAGE\n");
- MCONTACT hContact = (MCONTACT)opdata;
+ MCONTACT hContact = (UINT_PTR)opdata;
if (db_get_w(hContact, protocol, "Status", ID_STATUS_OFFLINE) != ID_STATUS_OFFLINE)
CallContactService(hContact, PSS_MESSAGE, PREF_BYPASS_OTR, (LPARAM)message);
}
@@ -169,7 +169,7 @@ extern "C" {
/* A ConnContext has entered a secure state. */
void otr_gui_gone_secure(void *opdata, ConnContext *context) {
DEBUGOUT_T("OTR_GUI_GONE_SECURE\n");
- MCONTACT hContact = (MCONTACT)opdata;
+ MCONTACT hContact = (UINT_PTR)opdata;
TrustLevel trusted = otr_context_get_trust(context);
SetEncryptionStatus(hContact, trusted);
TCHAR buff[512];
@@ -195,7 +195,7 @@ extern "C" {
/* A ConnContext has left a secure state. */
void otr_gui_gone_insecure(void *opdata, ConnContext *context) {
- MCONTACT hContact = (MCONTACT)opdata;
+ MCONTACT hContact = (UINT_PTR)opdata;
DEBUGOUT_T("OTR_GUI_GONE_INSECURE\n");
TCHAR buff[512];
mir_sntprintf(buff, TranslateT(LANG_SESSION_TERMINATED_BY_OTR), contact_get_nameT(hContact));
@@ -211,7 +211,7 @@ extern "C" {
/* 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;
+ MCONTACT hContact = (UINT_PTR)opdata;
DEBUGOUT_T("OTR_GUI_STILL_SECURE\n");
TrustLevel trusted = otr_context_get_trust(context);
SetEncryptionStatus(hContact, trusted);
@@ -250,7 +250,7 @@ extern "C" {
if (context && context->protocol)
proto = context->protocol;
else
- proto = GetContactProto((MCONTACT)opdata);
+ proto = GetContactProto((UINT_PTR)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 (mir_strcmp("ICQ", proto) == 0 || strncmp("ICQ_", proto, 4) == 0)
@@ -302,7 +302,7 @@ extern "C" {
void handle_msg_event(void *opdata, OtrlMessageEvent msg_event, ConnContext *context, const char *message, gcry_error_t err) {
DEBUGOUTA("HANDLE_MSG_EVENT\n");
- MCONTACT hContact = (MCONTACT)opdata;
+ MCONTACT hContact = (UINT_PTR)opdata;
const TCHAR* contact = contact_get_nameT(hContact);
typedef void(*msgfunc_t)(const MCONTACT, const TCHAR*);
diff --git a/plugins/MirOTR/src/utils.cpp b/plugins/MirOTR/src/utils.cpp
index ffdb5e33ec..94f2dc0919 100644
--- a/plugins/MirOTR/src/utils.cpp
+++ b/plugins/MirOTR/src/utils.cpp
@@ -65,7 +65,7 @@ void VerifyFingerprint(ConnContext *context, bool verify) {
}
void VerifyFingerprintMessage(ConnContext *context, bool verify) {
- MCONTACT hContact = (MCONTACT)context->app_data;
+ MCONTACT hContact = (UINT_PTR)context->app_data;
TCHAR msg[1024];
mir_sntprintf(msg, _countof(msg), (verify)?TranslateT(LANG_FINGERPRINT_VERIFIED):TranslateT(LANG_FINGERPRINT_NOT_VERIFIED), contact_get_nameT(hContact));