31 |
#include "wptGPG.h" |
#include "wptGPG.h" |
32 |
#include "wptNLS.h" |
#include "wptNLS.h" |
33 |
#include "resource.h" |
#include "resource.h" |
34 |
|
#include "wptCommonCtl.h" |
35 |
|
#include "wptContext.h" |
36 |
|
#include "wptKeylist.h" |
37 |
|
|
38 |
#ifdef _MSC_VER |
#ifdef _MSC_VER |
39 |
#include "winpt_header.h" |
#include "winpt_header.h" |
49 |
|
|
50 |
|
|
51 |
/* Load the clipboard contents into the text field in @dlg. |
/* Load the clipboard contents into the text field in @dlg. |
52 |
|
Optinally @header and @footer can be used to set a header and footer. |
53 |
Return value: 0 on success. */ |
Return value: 0 on success. */ |
54 |
static int |
static int |
55 |
load_clipboard (HWND dlg) |
load_clipboard (HWND dlg, |
56 |
|
const char *header, const char *footer) |
57 |
{ |
{ |
58 |
HANDLE clipmem; |
HANDLE clipmem; |
59 |
char *cliptext; |
char *cliptext; |
60 |
char *p; |
char *p, *pp; |
61 |
|
|
62 |
CloseClipboard (); /* make sure it is closed. */ |
CloseClipboard (); /* make sure it is closed. */ |
63 |
if (OpenClipboard (NULL) == FALSE) { |
if (OpenClipboard (NULL) == FALSE) { |
83 |
|
|
84 |
GlobalUnlock (clipmem); |
GlobalUnlock (clipmem); |
85 |
CloseClipboard (); |
CloseClipboard (); |
86 |
SetDlgItemText (dlg, IDC_CLIPEDIT_CLIPTEXT2, p); |
|
87 |
|
if (header && footer) { |
88 |
|
const char *fmt = "%s\r\n%s\r\n%s"; |
89 |
|
int len = strlen (header) + strlen (footer) + strlen (fmt) + strlen (p); |
90 |
|
|
91 |
|
pp = new char[len + 1]; |
92 |
|
if (!pp) |
93 |
|
BUG (0); |
94 |
|
_snprintf (pp, len, fmt, header, p, footer); |
95 |
|
SetDlgItemText (dlg, IDC_CLIPEDIT_CLIPTEXT2, pp); |
96 |
|
free_if_alloc (pp); |
97 |
|
} |
98 |
|
else |
99 |
|
SetDlgItemText (dlg, IDC_CLIPEDIT_CLIPTEXT2, p); |
100 |
free_if_alloc (p); |
free_if_alloc (p); |
|
|
|
101 |
return 0; |
return 0; |
102 |
} |
} |
103 |
|
|
203 |
} |
} |
204 |
|
|
205 |
|
|
206 |
|
void verify_get_clip_info (gpgme_signature_t sig, |
207 |
|
char **r_header, char **r_footer); |
208 |
|
|
209 |
/* Dialog box procedure for the clipboard editor. */ |
/* Dialog box procedure for the clipboard editor. */ |
210 |
BOOL CALLBACK |
BOOL CALLBACK |
211 |
clip_edit_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam) |
clip_edit_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam) |
212 |
{ |
{ |
213 |
|
char *head=NULL, *foot=NULL; |
214 |
|
|
215 |
switch (msg) { |
switch (msg) { |
216 |
case WM_INITDIALOG: |
case WM_INITDIALOG: |
217 |
SetWindowText (dlg, _("Clipboard Editor")); |
SetWindowText (dlg, _("Clipboard Editor")); |
221 |
SetDlgItemText (dlg, IDC_CLIPEDIT_SAVE, _("&Save")); |
SetDlgItemText (dlg, IDC_CLIPEDIT_SAVE, _("&Save")); |
222 |
SetDlgItemText (dlg, IDC_CLIPEDIT_QUOTE, _("Add quotes")); |
SetDlgItemText (dlg, IDC_CLIPEDIT_QUOTE, _("Add quotes")); |
223 |
SetDlgItemText (dlg, IDOK, _("&Close")); |
SetDlgItemText (dlg, IDOK, _("&Close")); |
224 |
|
/* If there is a param, we expect a signature and initialize |
225 |
load_clipboard (dlg); |
the header and footer variable accordingly. */ |
226 |
|
if (lparam) |
227 |
|
verify_get_clip_info ((gpgme_signature_t)lparam, &head, &foot); |
228 |
|
load_clipboard (dlg, head, foot); |
229 |
|
free_if_alloc (head); |
230 |
|
free_if_alloc (foot); |
231 |
center_window (dlg, NULL); |
center_window (dlg, NULL); |
232 |
SetForegroundWindow (dlg); |
SetForegroundWindow (dlg); |
233 |
return TRUE; |
return TRUE; |