/[winpt]/trunk/Src/wptKeyEditOwnertrustDlg.cpp
ViewVC logotype

Annotation of /trunk/Src/wptKeyEditOwnertrustDlg.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 23 - (hide annotations)
Fri Sep 30 10:10:16 2005 UTC (19 years, 5 months ago) by twoaday
File size: 3699 byte(s)
Almost finished phase 1 of the WinPT GPGME port.
Still need more cleanup, comments and tests.


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 23 static GpgKeyEdit *ek;
41     gpgme_error_t err;
42     gpgme_key_t key=NULL;
43 twoaday 2 HWND lb;
44     int index, id = 0;
45    
46     switch( msg ) {
47     case WM_INITDIALOG:
48 twoaday 23 ek = (GpgKeyEdit *)lparam;
49     if (ek == NULL)
50 twoaday 2 dlg_fatal_error( dlg, "Could not get dialog param!" );
51 twoaday 23 #ifndef LANG_DE
52 twoaday 2 SetWindowText( dlg, _("Change Ownertrust") );
53 twoaday 23 #endif
54 twoaday 2 lb = GetDlgItem( dlg, IDC_KEYTRUST_TRUST );
55     listbox_add_string( lb, _("Don't know") );
56     listbox_add_string( lb, _("I do NOT trust") );
57     listbox_add_string( lb, _("I trust marginally") );
58     listbox_add_string( lb, _("I trust fully") );
59     listbox_add_string( lb, _("I trust ultimately") );
60 twoaday 23 SetDlgItemText (dlg, IDC_KEYTRUST_INF,
61     _("Please decide how far you trust this user to "
62     "correctly verify other users' keys (by looking "
63     "at passports, checking fingerprint from "
64     "different source...)?"));
65     center_window (dlg, NULL);
66 twoaday 2 SetForegroundWindow (dlg);
67     return TRUE;
68    
69     case WM_SYSCOMMAND:
70 twoaday 23 if (LOWORD (wparam) == SC_CLOSE)
71 twoaday 2 EndDialog(dlg, TRUE);
72     return FALSE;
73    
74     case WM_COMMAND:
75     switch( LOWORD( wparam ) ) {
76     case IDCANCEL:
77 twoaday 23 EndDialog (dlg, FALSE);
78     return TRUE;
79 twoaday 2
80     case IDOK:
81 twoaday 23 lb = GetDlgItem (dlg, IDC_KEYTRUST_TRUST);
82     index = listbox_get_cursel (lb) + 1;
83     if (index < 1 || index > 5) {
84 twoaday 2 msg_box( dlg, _("Please choose one entry."), _("Ownertrust"), MB_ERR );
85 twoaday 23 return TRUE;
86 twoaday 2 }
87 twoaday 23 /* check if there is a corresponding secret key for the public key. */
88     get_seckey (ek->getKey ()->subkeys->keyid, &key);
89     if (index == 5 && !key) {
90 twoaday 2 id = msg_box( dlg, _("Do you really want to set this key to ultimate trust?"),
91     _("Ownertrust"), MB_YESNO );
92 twoaday 23 if( id == IDNO)
93     return TRUE;
94 twoaday 2 }
95 twoaday 23
96     err = ek->setTrust ((gpgme_validity_t)index);
97     if (err) {
98     msg_box (dlg, gpgme_strerror (err), _("Ownertrust"), MB_ERR);
99     return TRUE;
100     }
101    
102     EndDialog (dlg, TRUE);
103 twoaday 2 return TRUE;
104     }
105     break;
106     }
107     return FALSE;
108 twoaday 23 }

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26