1 |
twoaday |
2 |
/* 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 |
twoaday |
20 |
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 |
twoaday |
2 |
static BOOL CALLBACK |
46 |
twoaday |
20 |
http_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam) |
47 |
twoaday |
2 |
{ |
48 |
twoaday |
20 |
static struct URL_ctx_s * ctx; |
49 |
twoaday |
2 |
|
50 |
|
|
switch (msg) { |
51 |
|
|
case WM_INITDIALOG: |
52 |
twoaday |
20 |
ctx = (struct URL_ctx_s*)lparam; |
53 |
twoaday |
2 |
if (!ctx) |
54 |
|
|
BUG (0); |
55 |
twoaday |
20 |
if (ctx->desc != NULL) |
56 |
|
|
SetWindowText (dlg, ctx->desc); |
57 |
|
|
if (ctx->title != NULL) |
58 |
|
|
SetDlgItemText (dlg, IDC_HTTP_TITLE, ctx->title); |
59 |
twoaday |
2 |
SetForegroundWindow (dlg); |
60 |
|
|
break; |
61 |
|
|
|
62 |
|
|
case WM_COMMAND: |
63 |
|
|
switch (LOWORD (wparam)) { |
64 |
|
|
case IDOK: |
65 |
twoaday |
20 |
if (!GetDlgItemText (dlg, IDC_HTTP_URL, ctx->url, DIM (ctx->url)-1) || |
66 |
|
|
check_URL (ctx->url)) { |
67 |
|
|
msg_box (dlg, _("Please enter a valid URL."), _("HTTP"), MB_ERR); |
68 |
twoaday |
2 |
return FALSE; |
69 |
|
|
} |
70 |
|
|
ctx->cancel = 0; |
71 |
|
|
EndDialog (dlg, TRUE); |
72 |
|
|
break; |
73 |
|
|
|
74 |
|
|
case IDCANCEL: |
75 |
|
|
ctx->cancel = 1; |
76 |
|
|
EndDialog (dlg, FALSE); |
77 |
|
|
break; |
78 |
|
|
} |
79 |
|
|
} |
80 |
|
|
|
81 |
|
|
return FALSE; |
82 |
|
|
} |
83 |
|
|
|
84 |
|
|
|
85 |
twoaday |
20 |
void* |
86 |
twoaday |
2 |
get_http_file_dlg (HWND root) |
87 |
|
|
{ |
88 |
twoaday |
20 |
struct URL_ctx_s *ctx; |
89 |
twoaday |
2 |
|
90 |
twoaday |
20 |
ctx = new URL_ctx_s; |
91 |
twoaday |
2 |
if (!ctx) |
92 |
|
|
BUG (0); |
93 |
|
|
memset (ctx, 0, sizeof *ctx); |
94 |
|
|
DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_HTTP, root, |
95 |
twoaday |
20 |
http_dlg_proc, (LPARAM)ctx); |
96 |
twoaday |
2 |
|
97 |
|
|
return ctx; |
98 |
|
|
} |
99 |
twoaday |
20 |
|
100 |
|
|
|
101 |
|
|
void* |
102 |
|
|
get_keyserver_URL_dlg (HWND root) |
103 |
|
|
{ |
104 |
|
|
struct URL_ctx_s *ctx; |
105 |
|
|
|
106 |
|
|
ctx = new URL_ctx_s; |
107 |
|
|
if (!ctx) |
108 |
|
|
BUG (0); |
109 |
|
|
memset (ctx, 0, sizeof *ctx); |
110 |
|
|
ctx->desc = "Key Edit"; |
111 |
|
|
ctx->title = "Enter preferred keyserver URL"; |
112 |
|
|
DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_HTTP, root, |
113 |
|
|
http_dlg_proc, (LPARAM)ctx); |
114 |
|
|
return ctx; |
115 |
|
|
} |