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

Contents of /trunk/Src/wptCommonDlg.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 22 - (show annotations)
Wed Aug 10 11:33:35 2005 UTC (19 years, 6 months ago) by twoaday
File size: 3181 byte(s)
2005-08-06  Timo Schulz  <twoaday@freakmail.de>
 
        * wptGPGME.cpp (keycache_update): Reload OpenPGP parts
        of the secret key.
        (keycache_init): cache name of secret keyring.
        * wptKeyList.cpp (keylist_upd_key): Do not add long keyid.
        (get_key_type): Do not assume 'ultimate' means key pair.
        * wptKeyEditDlgs.cpp (diff_time): New.
        (keyedit_addsubkey_dlg_proc): Changed design and use
        diff_time. Drop checks for invalid keylength (< 1024, > 4096)
        because the combo box automatically handles this.
        * wptKeyManager.cpp (km_set_implicit_trust): Return error code.
        * wptGPG.cpp (get_backup_name): New.
        (gnupg_backup_keyrings): Rotate backup names, from 0..3.
        * wptClipImportDialog.cpp (clip_import_dlg_proc): Free memory.
        * wptKeyManagerDlg.cpp (keymanager_dlg_proc): Use 0x short keyid and
        not the long keyid.


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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26