1 |
/* wptKeyRevokeDlg.cpp - Key revocation dialog |
/* wptKeyRevokeDlg.cpp - Key revocation dialog |
2 |
* Copyright (C) 2001, 2002, 2003, 2005 Timo Schulz |
* Copyright (C) 2001, 2002, 2003, 2005, 2006 Timo Schulz |
3 |
* Copyright (C) 2005 g10 Code GmbH |
* Copyright (C) 2005 g10 Code GmbH |
4 |
* |
* |
5 |
* This file is part of WinPT. |
* This file is part of WinPT. |
141 |
switch( msg ) { |
switch( msg ) { |
142 |
case WM_INITDIALOG: |
case WM_INITDIALOG: |
143 |
if (!lparam) |
if (!lparam) |
144 |
dlg_fatal_error (dlg, "Could not get dialog param!"); |
BUG (0); |
145 |
k = (winpt_key_t)lparam; |
k = (winpt_key_t)lparam; |
146 |
on_init_dialog (dlg); |
on_init_dialog (dlg); |
147 |
return TRUE; |
return TRUE; |
148 |
|
|
|
case WM_SYSCOMMAND: |
|
|
if (LOWORD (wparam) == SC_CLOSE) |
|
|
EndDialog (dlg, FALSE); |
|
|
return FALSE; |
|
|
|
|
149 |
case WM_COMMAND: |
case WM_COMMAND: |
150 |
switch (LOWORD (wparam)) { |
switch (LOWORD (wparam)) { |
151 |
case IDC_KEYREVOKE_CHOOSE: |
case IDC_KEYREVOKE_CHOOSE: |
160 |
list = GetDlgItem (dlg, IDC_KEYREVOKE_REASON); |
list = GetDlgItem (dlg, IDC_KEYREVOKE_REASON); |
161 |
idx = SendMessage (list, LB_GETCURSEL, 0, 0); |
idx = SendMessage (list, LB_GETCURSEL, 0, 0); |
162 |
if (idx < 0 || idx > 3) { |
if (idx < 0 || idx > 3) { |
163 |
msg_box (dlg, _("Please select a reason."), |
msg_box (dlg, _("Please select a reason."), |
164 |
_("Key Revocation Cert"), MB_ERR); |
_("Key Revocation Cert"), MB_ERR); |
165 |
return TRUE; |
return TRUE; |
166 |
} |
} |
167 |
if (!GetDlgItemText (dlg, IDC_KEYREVOKE_FILE, file, sizeof (file)-1)) { |
if (!GetDlgItemText (dlg, IDC_KEYREVOKE_FILE, file, sizeof (file)-1)) { |
168 |
msg_box (dlg, _("Please enter a file name."), |
msg_box (dlg, _("Please enter a file name."), |
169 |
_("Key Revocation Cert"), MB_ERR); |
_("Key Revocation Cert"), MB_ERR); |
170 |
return TRUE; |
return TRUE; |
171 |
} |
} |
180 |
|
|
181 |
inp_data = generate_revoke_input (idx, desc, pwd); |
inp_data = generate_revoke_input (idx, desc, pwd); |
182 |
err = gpg_revoke_cert (k->internal, inp_data, k->keyid, &revcert); |
err = gpg_revoke_cert (k->internal, inp_data, k->keyid, &revcert); |
183 |
wipememory (pwd, sizeof (pwd)); |
sfree_if_alloc (inp_data); |
184 |
wipememory (inp_data, strlen (inp_data)); |
sfree_if_alloc (desc); |
185 |
if (err) { |
if (err) { |
186 |
msg_box (dlg, gpgme_strerror (err), _("Key Revocation Cert"), MB_ERR); |
msg_box (dlg, gpgme_strerror (err), _("Key Revocation Cert"), MB_ERR); |
187 |
safe_free (revcert); |
safe_free (revcert); |
188 |
|
return TRUE; |
189 |
} |
} |
190 |
else { |
else { |
191 |
show_msg (dlg, 1000, _("Revocation certificate generated.")); |
show_msg (dlg, 1000, _("Revocation certificate generated.")); |
192 |
msg_box (dlg, warning, _("Key Revocation Cert"), MB_INFO); |
msg_box (dlg, warning, _("Key Revocation Cert"), MB_INFO); |
193 |
release_cert_as_file (revcert, file); |
release_cert_as_file (revcert, file); |
194 |
|
EndDialog (dlg, TRUE); |
195 |
} |
} |
|
free_if_alloc (inp_data); |
|
|
free_if_alloc (desc); |
|
|
EndDialog (dlg, TRUE); |
|
196 |
return TRUE; |
return TRUE; |
197 |
|
|
198 |
case IDCANCEL: |
case IDCANCEL: |