1 |
werner |
36 |
/* wptKeyEditOwnertrustDlg.cpp - Key onwertrust dialog |
2 |
twoaday |
328 |
* Copyright (C) 2000-2006, 2009 Timo Schulz |
3 |
werner |
36 |
* |
4 |
|
|
* This file is part of WinPT. |
5 |
|
|
* |
6 |
|
|
* WinPT is free software; you can redistribute it and/or modify |
7 |
|
|
* it under the terms of the GNU General Public License as published by |
8 |
|
|
* the Free Software Foundation; either version 2 of the License, or |
9 |
|
|
* (at your option) any later version. |
10 |
|
|
* |
11 |
|
|
* WinPT is distributed in the hope that it will be useful, |
12 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 |
|
|
* GNU General Public License for more details. |
15 |
|
|
*/ |
16 |
|
|
#ifdef HAVE_CONFIG_H |
17 |
|
|
#include <config.h> |
18 |
|
|
#endif |
19 |
|
|
|
20 |
|
|
#include <windows.h> |
21 |
|
|
|
22 |
werner |
47 |
#include "resource.h" |
23 |
werner |
36 |
#include "wptErrors.h" |
24 |
|
|
#include "wptW32API.h" |
25 |
|
|
#include "wptVersion.h" |
26 |
|
|
#include "wptTypes.h" |
27 |
|
|
#include "wptNLS.h" |
28 |
|
|
#include "wptGPG.h" |
29 |
|
|
#include "wptCommonCtl.h" |
30 |
|
|
#include "wptContext.h" /* for passphrase_s */ |
31 |
|
|
#include "wptDlgs.h" |
32 |
|
|
#include "wptKeyEdit.h" |
33 |
|
|
|
34 |
|
|
|
35 |
|
|
/* Dialog box procedure to set the ownertrust. */ |
36 |
|
|
BOOL CALLBACK |
37 |
|
|
keyedit_ownertrust_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam) |
38 |
|
|
{ |
39 |
|
|
static winpt_key_t k; |
40 |
|
|
gpgme_error_t err; |
41 |
|
|
gpgme_key_t key=NULL; |
42 |
twoaday |
304 |
GpgKeyEdit ek; |
43 |
werner |
36 |
HWND lb; |
44 |
|
|
int index, id = 0; |
45 |
|
|
|
46 |
twoaday |
225 |
switch (msg) { |
47 |
werner |
36 |
case WM_INITDIALOG: |
48 |
|
|
k = (winpt_key_t)lparam; |
49 |
twoaday |
225 |
if (!k) |
50 |
|
|
BUG (0); |
51 |
twoaday |
105 |
SetWindowText (dlg, _("Change Ownertrust")); |
52 |
twoaday |
225 |
lb = GetDlgItem (dlg, IDC_KEYTRUST_TRUST); |
53 |
|
|
listbox_add_string (lb, _("Don't know") ); |
54 |
|
|
listbox_add_string (lb, _("I do NOT trust")); |
55 |
|
|
listbox_add_string (lb, _("I trust marginally")); |
56 |
|
|
listbox_add_string (lb, _("I trust fully")); |
57 |
|
|
listbox_add_string (lb, _("I trust ultimately")); |
58 |
|
|
SetDlgItemText (dlg, IDC_KEYTRUST_INF, |
59 |
werner |
36 |
_("Please decide how far you trust this user to " |
60 |
|
|
"correctly verify other users' keys (by looking " |
61 |
|
|
"at passports, checking fingerprint from " |
62 |
twoaday |
248 |
"different sources...)?")); |
63 |
twoaday |
105 |
SetDlgItemText (dlg, IDCANCEL, _("&Cancel")); |
64 |
werner |
36 |
center_window (dlg, NULL); |
65 |
|
|
SetForegroundWindow (dlg); |
66 |
|
|
return TRUE; |
67 |
|
|
|
68 |
twoaday |
328 |
case WM_DESTROY: |
69 |
|
|
balloon_msg_disable (); |
70 |
|
|
break; |
71 |
|
|
|
72 |
werner |
36 |
case WM_COMMAND: |
73 |
twoaday |
225 |
switch (LOWORD (wparam)) { |
74 |
werner |
36 |
case IDCANCEL: |
75 |
|
|
EndDialog (dlg, FALSE); |
76 |
|
|
return TRUE; |
77 |
|
|
|
78 |
twoaday |
225 |
case IDOK: |
79 |
werner |
36 |
lb = GetDlgItem (dlg, IDC_KEYTRUST_TRUST); |
80 |
|
|
index = listbox_get_cursel (lb) + 1; |
81 |
|
|
if (index < 1 || index > 5) { |
82 |
twoaday |
328 |
show_balloon_msg (GetDlgItem (dlg, IDC_KEYTRUST_TRUST), |
83 |
|
|
_("Please choose one entry."), IDI_ERROR); |
84 |
werner |
36 |
return TRUE; |
85 |
|
|
} |
86 |
|
|
/* check if there is a corresponding secret key for the public key. */ |
87 |
twoaday |
225 |
if (index == 5 && get_seckey (k->keyid, &key)) { |
88 |
werner |
36 |
id = msg_box (dlg, _("Do you really want to set this key to ultimate trust?"), |
89 |
|
|
_("Ownertrust"), MB_YESNO); |
90 |
|
|
if (id == IDNO) |
91 |
|
|
return TRUE; |
92 |
|
|
} |
93 |
|
|
k->callback.new_val = index; |
94 |
twoaday |
304 |
ek.setKeyID (k->keyid); |
95 |
|
|
err = ek.setTrust ((gpgme_validity_t)index); |
96 |
twoaday |
256 |
if (err) |
97 |
werner |
36 |
msg_box (dlg, gpgme_strerror (err), _("Ownertrust"), MB_ERR); |
98 |
twoaday |
256 |
else |
99 |
|
|
EndDialog (dlg, TRUE); |
100 |
werner |
36 |
return TRUE; |
101 |
|
|
} |
102 |
|
|
break; |
103 |
|
|
} |
104 |
|
|
return FALSE; |
105 |
|
|
} |