35 |
#include "wptContext.h" |
#include "wptContext.h" |
36 |
#include "wptKeylist.h" |
#include "wptKeylist.h" |
37 |
|
|
|
#ifdef _MSC_VER |
|
|
#include "winpt_header.h" |
|
|
|
|
|
static DWORD help_arr[] = { |
|
|
IDC_CLIPEDIT_SEND, WPT_CLIPEDIT_COPY, |
|
|
IDC_CLIPEDIT_CLEAR, WPT_CLIPEDIT_CLEAR, |
|
|
IDC_CLIPEDIT_LOAD, WPT_CLIPEDIT_LOAD, |
|
|
IDC_CLIPEDIT_SAVE, WPT_CLIPEDIT_SAVE, |
|
|
IDC_CLIPEDIT_QUOTE, WPT_CLIPEDIT_QUOTE, |
|
|
0, 0}; |
|
|
#endif |
|
38 |
|
|
39 |
|
/* XXX: it would be really nice to have tempest prevention fonts. */ |
40 |
|
|
41 |
void verify_get_clip_info (gpgme_signature_t sig, |
void verify_get_clip_info (gpgme_signature_t sig, |
42 |
char **r_header, char **r_footer); |
char **r_header, char **r_footer); |
46 |
Optinally @header and @footer can be used to set a header and footer. |
Optinally @header and @footer can be used to set a header and footer. |
47 |
Return value: 0 on success. */ |
Return value: 0 on success. */ |
48 |
static int |
static int |
49 |
load_clipboard (HWND dlg, |
load_clipboard (HWND dlg, const char *header, const char *footer) |
|
const char *header, const char *footer) |
|
50 |
{ |
{ |
51 |
HANDLE clipmem; |
HANDLE clipmem; |
52 |
char *cliptext; |
char *cliptext; |
103 |
OPENFILENAME open; |
OPENFILENAME open; |
104 |
FILE *fp; |
FILE *fp; |
105 |
char *p; |
char *p; |
106 |
char file[300] = ""; |
char file[MAX_PATH+64] = ""; |
107 |
DWORD size; |
DWORD size; |
108 |
int id; |
int id; |
109 |
|
|
153 |
char *p=NULL; |
char *p=NULL; |
154 |
char file[300] = ""; |
char file[300] = ""; |
155 |
DWORD nbytes; |
DWORD nbytes; |
|
int id; |
|
156 |
|
|
157 |
memset (&save, 0, sizeof (save)); |
memset (&save, 0, sizeof (save)); |
158 |
save.lStructSize = sizeof (OPENFILENAME); |
save.lStructSize = sizeof (OPENFILENAME); |
165 |
save.Flags = OFN_OVERWRITEPROMPT; |
save.Flags = OFN_OVERWRITEPROMPT; |
166 |
|
|
167 |
if (GetSaveFileName (&save)) { |
if (GetSaveFileName (&save)) { |
|
if (file_exist_check (file) == 0) { |
|
|
id = log_box (_("Clipboard"), MB_YESNO, |
|
|
_("\"%s\" already exists.\n" |
|
|
"Replace existing file?"), file); |
|
|
if (id == IDNO) |
|
|
return -1; |
|
|
} |
|
168 |
fp = fopen (file, "wb"); |
fp = fopen (file, "wb"); |
169 |
if (!fp) { |
if (!fp) { |
170 |
msg_box (dlg, winpt_strerror (WPTERR_FILE_CREAT), |
msg_box (dlg, winpt_strerror (WPTERR_FILE_CREAT), |
183 |
} |
} |
184 |
fclose (fp); |
fclose (fp); |
185 |
free_if_alloc (p); |
free_if_alloc (p); |
186 |
|
msg_box (dlg, _("Data successfully written to file."), |
187 |
|
_("Clipboard"), MB_OK); |
188 |
} |
} |
189 |
return 0; |
return 0; |
190 |
} |
} |
194 |
BOOL CALLBACK |
BOOL CALLBACK |
195 |
clip_edit_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam) |
clip_edit_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam) |
196 |
{ |
{ |
197 |
|
HMENU menu; |
198 |
char *head=NULL, *foot=NULL; |
char *head=NULL, *foot=NULL; |
199 |
gpgme_data_t txt; |
gpgme_data_t txt; |
200 |
|
|
201 |
switch (msg) { |
switch (msg) { |
202 |
case WM_INITDIALOG: |
case WM_INITDIALOG: |
|
/* XXX: it would be really nice to have tempest prevention fonts. */ |
|
|
SetWindowText (dlg, _("Clipboard Editor")); |
|
|
SetDlgItemText (dlg, IDC_CLIPEDIT_SEND, _("&Copy")); |
|
|
SetDlgItemText (dlg, IDC_CLIPEDIT_CLEAR, _("Clea&r")); |
|
|
SetDlgItemText (dlg, IDC_CLIPEDIT_LOAD, _("&Load")); |
|
|
SetDlgItemText (dlg, IDC_CLIPEDIT_SAVE, _("&Save")); |
|
|
SetDlgItemText (dlg, IDC_CLIPEDIT_QUOTE, _("&Quote")); |
|
|
SetDlgItemText (dlg, IDOK, _("&Close")); |
|
|
|
|
203 |
/* If there is a param, we expect a signature and initialize |
/* If there is a param, we expect a signature and initialize |
204 |
the header and footer variable accordingly. */ |
the header and footer variable accordingly. */ |
205 |
if (lparam) |
if (lparam) |
207 |
load_clipboard (dlg, head, foot); |
load_clipboard (dlg, head, foot); |
208 |
free_if_alloc (head); |
free_if_alloc (head); |
209 |
free_if_alloc (foot); |
free_if_alloc (foot); |
210 |
|
|
211 |
|
menu = LoadMenu (glob_hinst, (LPCTSTR)IDR_WINPT_CLIPEDIT); |
212 |
|
set_menu_text (menu, ID_CLIPEDIT_SEND, _("&Copy")); |
213 |
|
set_menu_text (menu, ID_CLIPEDIT_CLEAR, _("Clea&r")); |
214 |
|
set_menu_text (menu, ID_CLIPEDIT_QUOTE, _("&Quote")); |
215 |
|
set_menu_text (menu, ID_CLIPEDIT_OPEN, _("&Open...")); |
216 |
|
set_menu_text (menu, ID_CLIPEDIT_SAVE, _("&Save...")); |
217 |
|
set_menu_text (menu, ID_CLIPEDIT_PASTE, _("&Paste")); |
218 |
|
set_menu_text (menu, ID_CLIPEDIT_ENC, _("&Encrypt")); |
219 |
|
set_menu_text (menu, ID_CLIPEDIT_DEC, _("&Decrypt")); |
220 |
|
SetMenu (dlg, menu); |
221 |
|
SetWindowText (dlg, _("Clipboard Editor")); |
222 |
|
SetDlgItemText (dlg, IDC_CLIPEDIT_SEND, _("&Copy")); |
223 |
center_window (dlg, NULL); |
center_window (dlg, NULL); |
224 |
SetForegroundWindow (dlg); |
SetForegroundWindow (dlg); |
225 |
return TRUE; |
return TRUE; |
|
|
|
|
case WM_HELP: |
|
|
html_help_dispatch (lparam, "winpt.chm::winpt_texts.txt", help_arr); |
|
|
break; |
|
226 |
|
|
227 |
case WM_COMMAND: |
case WM_COMMAND: |
228 |
switch (LOWORD (wparam)) { |
switch (LOWORD (wparam)) { |
230 |
EndDialog (dlg, FALSE); |
EndDialog (dlg, FALSE); |
231 |
return TRUE; |
return TRUE; |
232 |
|
|
233 |
case IDOK: |
case IDOK: |
234 |
|
case ID_CLIPEDIT_QUIT: |
235 |
EndDialog (dlg, TRUE); |
EndDialog (dlg, TRUE); |
236 |
return TRUE; |
return TRUE; |
237 |
|
|
238 |
case IDC_CLIPEDIT_QUOTE: |
case ID_CLIPEDIT_QUOTE: |
239 |
|
SendMessage (dlg, WM_COMMAND, ID_CLIPEDIT_COPY, 0); |
240 |
if (gpg_data_new_from_clipboard (&txt, 0)) |
if (gpg_data_new_from_clipboard (&txt, 0)) |
241 |
return TRUE; |
return TRUE; |
242 |
gpg_data_mail_quote (&txt); |
gpg_data_mail_quote (&txt); |
244 |
load_clipboard (dlg, head, foot); |
load_clipboard (dlg, head, foot); |
245 |
return TRUE; |
return TRUE; |
246 |
|
|
247 |
|
case ID_CLIPEDIT_COPY: |
248 |
case IDC_CLIPEDIT_SEND: |
case IDC_CLIPEDIT_SEND: |
249 |
SendDlgItemMessage (dlg, IDC_CLIPEDIT_CLIPTEXT2, EM_SETSEL, 0, -1); |
SendDlgItemMessage (dlg, IDC_CLIPEDIT_CLIPTEXT2, EM_SETSEL, 0, -1); |
250 |
SendDlgItemMessage (dlg, IDC_CLIPEDIT_CLIPTEXT2, WM_COPY, 0, 0); |
SendDlgItemMessage (dlg, IDC_CLIPEDIT_CLIPTEXT2, WM_COPY, 0, 0); |
251 |
|
SendDlgItemMessage (dlg, IDC_CLIPEDIT_CLIPTEXT2, EM_SETSEL, -1, 0); |
252 |
return TRUE; |
return TRUE; |
253 |
|
|
254 |
case IDC_CLIPEDIT_CLEAR: |
case ID_CLIPEDIT_CLEAR: |
255 |
if (OpenClipboard (NULL) == FALSE) { |
if (OpenClipboard (NULL) == FALSE) { |
256 |
msg_box (dlg, winpt_strerror (WPTERR_CLIP_OPEN), |
msg_box (dlg, winpt_strerror (WPTERR_CLIP_OPEN), |
257 |
_("Clipboard"), MB_ERR); |
_("Clipboard"), MB_ERR); |
264 |
SetDlgItemText (dlg, IDC_CLIPEDIT_CLIPTEXT2, ""); |
SetDlgItemText (dlg, IDC_CLIPEDIT_CLIPTEXT2, ""); |
265 |
CloseClipboard (); |
CloseClipboard (); |
266 |
return TRUE; |
return TRUE; |
267 |
|
|
268 |
|
case ID_CLIPEDIT_PASTE: |
269 |
|
load_clipboard (dlg, NULL, NULL); |
270 |
|
break; |
271 |
|
|
272 |
case IDC_CLIPEDIT_LOAD: |
case ID_CLIPEDIT_OPEN: |
273 |
if (!load_clipboard_from_file (dlg)) |
if (!load_clipboard_from_file (dlg)) |
274 |
PostMessage (dlg, WM_COMMAND, MAKEWPARAM (IDC_CLIPEDIT_SEND, 0), 0); |
PostMessage (dlg, WM_COMMAND, MAKEWPARAM (IDC_CLIPEDIT_SEND, 0), 0); |
275 |
return TRUE; |
return TRUE; |
276 |
|
|
277 |
case IDC_CLIPEDIT_SAVE: |
case ID_CLIPEDIT_SAVE: |
278 |
save_clipboard_to_file (dlg); |
save_clipboard_to_file (dlg); |
279 |
return TRUE; |
return TRUE; |
280 |
|
|
281 |
|
case ID_CLIPEDIT_ENC: |
282 |
|
SendMessage (dlg, WM_COMMAND, ID_CLIPEDIT_COPY, 0); |
283 |
|
SendMessage (glob_hwnd, WM_COMMAND, ID_WINPT_ENCRYPT, 0); |
284 |
|
load_clipboard (dlg, NULL, NULL); |
285 |
|
SetForegroundWindow (dlg); |
286 |
|
break; |
287 |
|
|
288 |
|
case ID_CLIPEDIT_DEC: |
289 |
|
SendMessage (glob_hwnd, WM_COMMAND, ID_WINPT_DECRYPT_VERIFY, 0); |
290 |
|
load_clipboard (dlg, NULL, NULL); |
291 |
|
SetForegroundWindow (dlg); |
292 |
|
break; |
293 |
} |
} |
294 |
break; |
break; |
295 |
} |
} |