1 |
werner |
36 |
/* wptKeyEditOwnertrustDlg.cpp - Key onwertrust dialog |
2 |
|
|
* Copyright (C) 2000-2005 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 |
|
|
* 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 |
|
|
|
21 |
|
|
#ifdef HAVE_CONFIG_H |
22 |
|
|
#include <config.h> |
23 |
|
|
#endif |
24 |
|
|
|
25 |
|
|
#include <windows.h> |
26 |
|
|
#include <windows.h> |
27 |
|
|
|
28 |
|
|
#include "../resource.h" |
29 |
|
|
#include "wptErrors.h" |
30 |
|
|
#include "wptW32API.h" |
31 |
|
|
#include "wptVersion.h" |
32 |
|
|
#include "wptTypes.h" |
33 |
|
|
#include "wptNLS.h" |
34 |
|
|
#include "wptGPG.h" |
35 |
|
|
#include "wptCommonCtl.h" |
36 |
|
|
#include "wptContext.h" /* for passphrase_s */ |
37 |
|
|
#include "wptDlgs.h" |
38 |
|
|
#include "wptKeyEdit.h" |
39 |
|
|
|
40 |
|
|
|
41 |
|
|
/* Dialog box procedure to set the ownertrust. */ |
42 |
|
|
BOOL CALLBACK |
43 |
|
|
keyedit_ownertrust_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam) |
44 |
|
|
{ |
45 |
|
|
static winpt_key_t k; |
46 |
|
|
gpgme_error_t err; |
47 |
|
|
gpgme_key_t key=NULL; |
48 |
|
|
GpgKeyEdit *ek; |
49 |
|
|
HWND lb; |
50 |
|
|
int index, id = 0; |
51 |
|
|
|
52 |
|
|
switch( msg ) { |
53 |
|
|
case WM_INITDIALOG: |
54 |
|
|
k = (winpt_key_t)lparam; |
55 |
|
|
if (k == NULL) |
56 |
|
|
dlg_fatal_error( dlg, "Could not get dialog param!" ); |
57 |
|
|
#ifndef LANG_DE |
58 |
|
|
SetWindowText( dlg, _("Change Ownertrust") ); |
59 |
|
|
#endif |
60 |
|
|
lb = GetDlgItem( dlg, IDC_KEYTRUST_TRUST ); |
61 |
|
|
listbox_add_string( lb, _("Don't know") ); |
62 |
|
|
listbox_add_string( lb, _("I do NOT trust") ); |
63 |
|
|
listbox_add_string( lb, _("I trust marginally") ); |
64 |
|
|
listbox_add_string( lb, _("I trust fully") ); |
65 |
|
|
listbox_add_string( lb, _("I trust ultimately") ); |
66 |
|
|
SetDlgItemText (dlg, IDC_KEYTRUST_INF, |
67 |
|
|
_("Please decide how far you trust this user to " |
68 |
|
|
"correctly verify other users' keys (by looking " |
69 |
|
|
"at passports, checking fingerprint from " |
70 |
|
|
"different source...)?")); |
71 |
|
|
center_window (dlg, NULL); |
72 |
|
|
SetForegroundWindow (dlg); |
73 |
|
|
return TRUE; |
74 |
|
|
|
75 |
|
|
case WM_SYSCOMMAND: |
76 |
|
|
if (LOWORD (wparam) == SC_CLOSE) |
77 |
|
|
EndDialog(dlg, TRUE); |
78 |
|
|
return FALSE; |
79 |
|
|
|
80 |
|
|
case WM_COMMAND: |
81 |
|
|
switch( LOWORD( wparam ) ) { |
82 |
|
|
case IDCANCEL: |
83 |
|
|
k->callback.new_val = -1; |
84 |
|
|
EndDialog (dlg, FALSE); |
85 |
|
|
return TRUE; |
86 |
|
|
|
87 |
|
|
case IDOK: |
88 |
|
|
lb = GetDlgItem (dlg, IDC_KEYTRUST_TRUST); |
89 |
|
|
index = listbox_get_cursel (lb) + 1; |
90 |
|
|
if (index < 1 || index > 5) { |
91 |
|
|
msg_box( dlg, _("Please choose one entry."), _("Ownertrust"), MB_ERR ); |
92 |
|
|
return TRUE; |
93 |
|
|
} |
94 |
|
|
/* check if there is a corresponding secret key for the public key. */ |
95 |
|
|
get_seckey (k->keyid, &key); |
96 |
|
|
if (index == 5 && !key) { |
97 |
|
|
id = msg_box (dlg, _("Do you really want to set this key to ultimate trust?"), |
98 |
|
|
_("Ownertrust"), MB_YESNO); |
99 |
|
|
if (id == IDNO) |
100 |
|
|
return TRUE; |
101 |
|
|
} |
102 |
|
|
k->callback.new_val = index; |
103 |
|
|
ek = new GpgKeyEdit (k->keyid); |
104 |
|
|
err = ek->setTrust ((gpgme_validity_t)index); |
105 |
|
|
delete ek; |
106 |
|
|
if (err) { |
107 |
|
|
msg_box (dlg, gpgme_strerror (err), _("Ownertrust"), MB_ERR); |
108 |
|
|
return TRUE; |
109 |
|
|
} |
110 |
|
|
EndDialog (dlg, TRUE); |
111 |
|
|
return TRUE; |
112 |
|
|
} |
113 |
|
|
break; |
114 |
|
|
} |
115 |
|
|
return FALSE; |
116 |
|
|
} |