1 |
werner |
36 |
/* wptKeyEditOwnertrustDlg.cpp - Key onwertrust dialog |
2 |
twoaday |
225 |
* Copyright (C) 2000-2006 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 |
|
|
* You should have received a copy of the GNU General Public License |
17 |
|
|
* along with WinPT; if not, write to the Free Software Foundation, |
18 |
|
|
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
19 |
|
|
*/ |
20 |
|
|
#ifdef HAVE_CONFIG_H |
21 |
|
|
#include <config.h> |
22 |
|
|
#endif |
23 |
|
|
|
24 |
|
|
#include <windows.h> |
25 |
|
|
|
26 |
werner |
47 |
#include "resource.h" |
27 |
werner |
36 |
#include "wptErrors.h" |
28 |
|
|
#include "wptW32API.h" |
29 |
|
|
#include "wptVersion.h" |
30 |
|
|
#include "wptTypes.h" |
31 |
|
|
#include "wptNLS.h" |
32 |
|
|
#include "wptGPG.h" |
33 |
|
|
#include "wptCommonCtl.h" |
34 |
|
|
#include "wptContext.h" /* for passphrase_s */ |
35 |
|
|
#include "wptDlgs.h" |
36 |
|
|
#include "wptKeyEdit.h" |
37 |
|
|
|
38 |
|
|
|
39 |
|
|
/* Dialog box procedure to set the ownertrust. */ |
40 |
|
|
BOOL CALLBACK |
41 |
|
|
keyedit_ownertrust_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam) |
42 |
|
|
{ |
43 |
|
|
static winpt_key_t k; |
44 |
|
|
gpgme_error_t err; |
45 |
|
|
gpgme_key_t key=NULL; |
46 |
|
|
GpgKeyEdit *ek; |
47 |
|
|
HWND lb; |
48 |
|
|
int index, id = 0; |
49 |
|
|
|
50 |
twoaday |
225 |
switch (msg) { |
51 |
werner |
36 |
case WM_INITDIALOG: |
52 |
|
|
k = (winpt_key_t)lparam; |
53 |
twoaday |
225 |
if (!k) |
54 |
|
|
BUG (0); |
55 |
twoaday |
105 |
SetWindowText (dlg, _("Change Ownertrust")); |
56 |
twoaday |
225 |
lb = GetDlgItem (dlg, IDC_KEYTRUST_TRUST); |
57 |
|
|
listbox_add_string (lb, _("Don't know") ); |
58 |
|
|
listbox_add_string (lb, _("I do NOT trust")); |
59 |
|
|
listbox_add_string (lb, _("I trust marginally")); |
60 |
|
|
listbox_add_string (lb, _("I trust fully")); |
61 |
|
|
listbox_add_string (lb, _("I trust ultimately")); |
62 |
|
|
SetDlgItemText (dlg, IDC_KEYTRUST_INF, |
63 |
werner |
36 |
_("Please decide how far you trust this user to " |
64 |
|
|
"correctly verify other users' keys (by looking " |
65 |
|
|
"at passports, checking fingerprint from " |
66 |
|
|
"different source...)?")); |
67 |
twoaday |
105 |
SetDlgItemText (dlg, IDCANCEL, _("&Cancel")); |
68 |
werner |
36 |
center_window (dlg, NULL); |
69 |
|
|
SetForegroundWindow (dlg); |
70 |
|
|
return TRUE; |
71 |
|
|
|
72 |
|
|
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 |
225 |
msg_box (dlg, _("Please choose one entry."), |
83 |
|
|
_("Ownertrust"), MB_ERR); |
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 |
|
|
ek = new GpgKeyEdit (k->keyid); |
95 |
|
|
err = ek->setTrust ((gpgme_validity_t)index); |
96 |
|
|
delete ek; |
97 |
|
|
if (err) { |
98 |
|
|
msg_box (dlg, gpgme_strerror (err), _("Ownertrust"), MB_ERR); |
99 |
|
|
return TRUE; |
100 |
|
|
} |
101 |
|
|
EndDialog (dlg, TRUE); |
102 |
|
|
return TRUE; |
103 |
|
|
} |
104 |
|
|
break; |
105 |
|
|
} |
106 |
|
|
return FALSE; |
107 |
|
|
} |