1 |
/* wptKeyEditOwnertrustDlg.cpp - Key onwertrust dialog |
2 |
* Copyright (C) 2000-2006, 2009 Timo Schulz |
3 |
* |
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 |
#include "resource.h" |
23 |
#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 |
GpgKeyEdit ek; |
43 |
HWND lb; |
44 |
int index, id = 0; |
45 |
|
46 |
switch (msg) { |
47 |
case WM_INITDIALOG: |
48 |
k = (winpt_key_t)lparam; |
49 |
if (!k) |
50 |
BUG (0); |
51 |
SetWindowText (dlg, _("Change Ownertrust")); |
52 |
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 |
_("Please decide how far you trust this user to " |
60 |
"correctly verify other users' keys (by looking " |
61 |
"at passports, checking fingerprint from " |
62 |
"different sources...)?")); |
63 |
SetDlgItemText (dlg, IDCANCEL, _("&Cancel")); |
64 |
center_window (dlg, NULL); |
65 |
SetForegroundWindow (dlg); |
66 |
return TRUE; |
67 |
|
68 |
case WM_DESTROY: |
69 |
balloon_msg_disable (); |
70 |
break; |
71 |
|
72 |
case WM_COMMAND: |
73 |
switch (LOWORD (wparam)) { |
74 |
case IDCANCEL: |
75 |
EndDialog (dlg, FALSE); |
76 |
return TRUE; |
77 |
|
78 |
case IDOK: |
79 |
lb = GetDlgItem (dlg, IDC_KEYTRUST_TRUST); |
80 |
index = listbox_get_cursel (lb) + 1; |
81 |
if (index < 1 || index > 5) { |
82 |
show_balloon_msg (GetDlgItem (dlg, IDC_KEYTRUST_TRUST), |
83 |
_("Please choose one entry."), IDI_ERROR); |
84 |
return TRUE; |
85 |
} |
86 |
/* check if there is a corresponding secret key for the public key. */ |
87 |
if (index == 5 && get_seckey (k->keyid, &key)) { |
88 |
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.setKeyID (k->keyid); |
95 |
err = ek.setTrust ((gpgme_validity_t)index); |
96 |
if (err) |
97 |
msg_box (dlg, gpgme_strerror (err), _("Ownertrust"), MB_ERR); |
98 |
else |
99 |
EndDialog (dlg, TRUE); |
100 |
return TRUE; |
101 |
} |
102 |
break; |
103 |
} |
104 |
return FALSE; |
105 |
} |