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

Contents of /trunk/Src/wptCommonDlg.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 32 - (show annotations)
Mon Oct 24 08:03:48 2005 UTC (19 years, 4 months ago) by twoaday
File size: 3465 byte(s)
2005-10-23  Timo Schulz  <twoaday@g10code.com>
 
        * wptFileManager.cpp (fm_get_file_type): Detect detached sigs.
        * wptKeyList.cpp (keylist_cmp_cb): Take care of expired/revoked keys.
        (get_ext_validity): New.
        * wptFileVerifyDlg.cpp (file_verify_dlg_proc): Several cleanups.
        * wptClipEditDlg.cpp (load_clipboard): Factored out some code into
        this function.
        (load_clipboard_from_file): Likewise.
        (save_clipboard_to_file): New.
        * wptKeyManagerDlg.cpp (keyprops_dlg_proc): Fix stack overflow.

For complete details, see the ChangeLog files.

1 /* wptCommonDlg.cpp
2 * Copyright (C) 2004, 2005 Timo Schulz
3 *
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
25 #include "wptTypes.h"
26 #include "wptW32API.h"
27 #include "wptVersion.h"
28 #include "wptGPG.h"
29 #include "wptCommonCtl.h"
30 #include "wptContext.h"
31
32
33 /* check if the given buf contains a valid URL. */
34 static int
35 check_URL (const char *buf)
36 {
37 /* XXX: be more strict */
38 if (!strchr (buf, ':'))
39 return -1;
40 if (!strstr (buf, "//"))
41 return -1;
42 return 0;
43 }
44
45
46 static BOOL CALLBACK
47 http_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)
48 {
49 static struct URL_ctx_s * ctx;
50 int n;
51
52 switch (msg) {
53 case WM_INITDIALOG:
54 ctx = (struct URL_ctx_s*)lparam;
55 if (!ctx)
56 BUG (0);
57 if (ctx->desc != NULL)
58 SetWindowText (dlg, ctx->desc);
59 if (ctx->title != NULL)
60 SetDlgItemText (dlg, IDC_HTTP_TITLE, ctx->title);
61 SetForegroundWindow (dlg);
62 break;
63
64 case WM_COMMAND:
65 switch (LOWORD (wparam)) {
66 case IDOK:
67 n = GetDlgItemText (dlg, IDC_HTTP_URL, ctx->url, DIM (ctx->url)-1);
68 if (ctx->check && (!n || check_URL (ctx->url))) {
69 msg_box (dlg, _("Please enter a valid URL."), "HTTP", MB_ERR);
70 return FALSE;
71 }
72 ctx->cancel = 0;
73 EndDialog (dlg, TRUE);
74 break;
75
76 case IDCANCEL:
77 ctx->cancel = 1;
78 EndDialog (dlg, FALSE);
79 break;
80 }
81 }
82
83 return FALSE;
84 }
85
86
87 /* Common dialog to request a URL from the user.
88 Return value is the URL context. */
89 void*
90 get_http_file_dlg (HWND root)
91 {
92 struct URL_ctx_s *ctx;
93
94 ctx = new URL_ctx_s;
95 if (!ctx)
96 BUG (0);
97 memset (ctx, 0, sizeof *ctx);
98 ctx->check = 1;
99 DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_HTTP, root,
100 http_dlg_proc, (LPARAM)ctx);
101 return ctx;
102 }
103
104 /* Wrapper to request a preferred keyserver from the user.
105 Return value is the URL context. */
106 void*
107 get_keyserver_URL_dlg (HWND root)
108 {
109 struct URL_ctx_s *ctx;
110
111 ctx = new URL_ctx_s;
112 if (!ctx)
113 BUG (0);
114 memset (ctx, 0, sizeof *ctx);
115 ctx->check = 1;
116 ctx->desc = _("Key Edit");
117 ctx->title = _("Enter preferred keyserver URL");
118 DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_HTTP, root,
119 http_dlg_proc, (LPARAM)ctx);
120 return ctx;
121 }
122
123
124 /* Generic text input dialog. */
125 char*
126 get_input_dialog (HWND root, const char *title, const char *desc)
127 {
128 struct URL_ctx_s ctx;
129
130 memset (&ctx, 0, sizeof (ctx));
131 ctx.title = title;
132 ctx.desc = desc;
133 DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_HTTP, root,
134 http_dlg_proc, (LPARAM)&ctx);
135 if (ctx.cancel || strlen (ctx.url) == 0)
136 return NULL;
137 return m_strdup (ctx.url);
138 }

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26