1 |
/* wptClipSignDlg.cpp - WinPT clipboard sign dialog |
/* wptClipSignDlg.cpp - WinPT clipboard sign dialog |
2 |
* Copyright (C) 2000-2006 Timo Schulz |
* Copyright (C) 2000-2006, 2009 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. |
13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 |
* GNU General Public License for more details. |
* GNU General Public License for more details. |
|
* |
|
|
* You should have received a copy of the GNU General Public License |
|
|
* along with WinPT; if not, write to the Free Software Foundation, |
|
|
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
|
16 |
*/ |
*/ |
17 |
|
|
18 |
#ifdef HAVE_CONFIG_H |
#ifdef HAVE_CONFIG_H |
52 |
return gpg_error (GPG_ERR_INV_ARG); |
return gpg_error (GPG_ERR_INV_ARG); |
53 |
|
|
54 |
gpgme_set_armor (ctx, 1); |
gpgme_set_armor (ctx, 1); |
55 |
err = gpg_data_new_from_clipboard (&plain, wraplen); |
err = gpg_data_utf8_new_from_clipboard (&plain, wraplen, NULL); |
56 |
if (err) |
if (err) |
57 |
return err; |
return err; |
58 |
err = get_pubkey (keyid, &key); |
err = get_pubkey (keyid, &key); |
68 |
if (err) |
if (err) |
69 |
goto leave; |
goto leave; |
70 |
|
|
71 |
gpg_data_release_and_set_clipboard (sig, 1); |
gpg_data_release_to_clipboard (sig, 1); |
72 |
sig = NULL; |
sig = NULL; |
73 |
|
|
74 |
leave: |
leave: |
136 |
} |
} |
137 |
|
|
138 |
|
|
139 |
static listview_ctrl_t |
static keylist_ctrl_t |
140 |
on_init_dialog (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam) |
on_init_dialog (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam) |
141 |
{ |
{ |
142 |
listview_ctrl_t lv; |
keylist_ctrl_t kl; |
143 |
gpg_keycache_t kc, sec_kc; |
gpg_keycache_t kc, sec_kc; |
144 |
int nkeys; |
int nkeys; |
145 |
|
|
156 |
one_key_proc (dlg); |
one_key_proc (dlg); |
157 |
return NULL; |
return NULL; |
158 |
} |
} |
159 |
lv = keylist_load (GetDlgItem (dlg, IDC_SIGN_KEYLIST), kc, sec_kc, |
kl = keylist_load (GetDlgItem (dlg, IDC_SIGN_KEYLIST), kc, sec_kc, |
160 |
KEYLIST_SIGN, KEY_SORT_USERID); |
KEYLIST_SIGN, KEY_SORT_USERID); |
161 |
center_window (dlg, NULL); |
center_window (dlg, NULL); |
162 |
SetForegroundWindow (dlg); |
SetForegroundWindow (dlg); |
163 |
return lv; |
return kl; |
164 |
} |
} |
165 |
|
|
166 |
|
|
180 |
BOOL CALLBACK |
BOOL CALLBACK |
181 |
clip_sign_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam) |
clip_sign_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam) |
182 |
{ |
{ |
183 |
static listview_ctrl_t lv = NULL; |
static keylist_ctrl_t kl = NULL; |
184 |
gpgme_ctx_t ctx; |
gpgme_ctx_t ctx; |
185 |
gpgme_error_t err; |
gpgme_error_t err; |
186 |
passphrase_cb_s pwd; |
passphrase_cb_s pwd; |
190 |
|
|
191 |
switch (msg) { |
switch (msg) { |
192 |
case WM_INITDIALOG: |
case WM_INITDIALOG: |
193 |
lv = on_init_dialog (dlg, msg, wparam, lparam); |
kl = on_init_dialog (dlg, msg, wparam, lparam); |
194 |
if (!lv) |
if (!kl) |
195 |
EndDialog (dlg, TRUE); |
EndDialog (dlg, TRUE); |
196 |
return FALSE; |
return FALSE; |
197 |
|
|
198 |
case WM_DESTROY: |
case WM_DESTROY: |
199 |
if (lv) { |
if (kl) { |
200 |
keylist_delete (lv); |
keylist_delete (kl); |
201 |
lv = NULL; |
kl = NULL; |
202 |
} |
} |
203 |
return FALSE; |
return FALSE; |
204 |
|
|
220 |
_("Signing"), MB_ERR); |
_("Signing"), MB_ERR); |
221 |
return FALSE; |
return FALSE; |
222 |
} |
} |
223 |
else if ((lv_idx = listview_get_selected_item (lv)) == -1) { |
else if ((lv_idx = listview_get_selected_item (kl->lv)) == -1) { |
224 |
rc = log_box (_("Signing"), MB_YESNO, |
rc = log_box (_("Signing"), MB_YESNO, |
225 |
_("No key was chosen.\n" |
_("No key was chosen.\n" |
226 |
"Use the GPG default key '%s'?"), |
"Use the GPG default key '%s'?"), |
236 |
signer = new char[32+1]; |
signer = new char[32+1]; |
237 |
if (!signer) |
if (!signer) |
238 |
BUG (NULL); |
BUG (NULL); |
239 |
listview_get_item_text (lv, lv_idx, KM_COL_KEYID, signer, 32); |
listview_get_item_text (kl->lv, lv_idx, KM_COL_KEYID, signer, 32); |
240 |
} |
} |
241 |
err = gpgme_new (&ctx); |
err = gpgme_new (&ctx); |
242 |
if (err) |
if (err) |