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

Diff of /trunk/Src/wptCommonDlg.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 19 by twoaday, Mon Jan 31 11:02:21 2005 UTC revision 20 by twoaday, Wed Jul 27 11:17:22 2005 UTC
# Line 30  Line 30 
30  #include "wptContext.h"  #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  static BOOL CALLBACK
46  http_file_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)  http_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)
47  {  {
48      static http_file_s * ctx;      static struct URL_ctx_s * ctx;
49    
50      switch (msg) {      switch (msg) {
51      case WM_INITDIALOG:      case WM_INITDIALOG:
52          ctx = (struct http_file_s*)lparam;          ctx = (struct URL_ctx_s*)lparam;
53          if (!ctx)          if (!ctx)
54              BUG (0);              BUG (0);
55            if (ctx->desc != NULL)
56                SetWindowText (dlg, ctx->desc);
57            if (ctx->title != NULL)
58                SetDlgItemText (dlg, IDC_HTTP_TITLE, ctx->title);
59          SetForegroundWindow (dlg);          SetForegroundWindow (dlg);
60          break;          break;
61    
62      case WM_COMMAND:      case WM_COMMAND:
63          switch (LOWORD (wparam)) {          switch (LOWORD (wparam)) {
64          case IDOK:          case IDOK:
65              if (!GetDlgItemText (dlg, IDC_HTTP_URL, ctx->url, sizeof ctx->url-1)) {              if (!GetDlgItemText (dlg, IDC_HTTP_URL, ctx->url, DIM (ctx->url)-1) ||
66                  msg_box (dlg, _("Please enter an URL."), _("HTTP"), MB_ERR);                  check_URL (ctx->url)) {
67                    msg_box (dlg, _("Please enter a valid URL."), _("HTTP"), MB_ERR);
68                  return FALSE;                  return FALSE;
69              }              }
70              ctx->cancel = 0;              ctx->cancel = 0;
# Line 65  http_file_dlg_proc (HWND dlg, UINT msg, Line 82  http_file_dlg_proc (HWND dlg, UINT msg,
82  }  }
83    
84    
85  void *  void*
86  get_http_file_dlg (HWND root)  get_http_file_dlg (HWND root)
87  {  {
88      http_file_s * ctx;      struct URL_ctx_s *ctx;
89    
90      ctx = new http_file_s;      ctx = new URL_ctx_s;
91      if (!ctx)      if (!ctx)
92          BUG (0);          BUG (0);
93      memset (ctx, 0, sizeof *ctx);      memset (ctx, 0, sizeof *ctx);
94      DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_HTTP, root,      DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_HTTP, root,
95                      http_file_dlg_proc, (LPARAM)ctx);                      http_dlg_proc, (LPARAM)ctx);
96    
97        return ctx;
98    }
99    
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;      return ctx;
115  }  }

Legend:
Removed from v.19  
changed lines
  Added in v.20

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26