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