2 * Copyright (c) 2000, Red Hat, Inc.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * A copy of the GNU General Public License can be found at
12 * Written by DJ Delorie <dj@cygnus.com>
16 /* The purpose of this file is to coordinate the various access
17 methods known to setup. To add a new method, create a pair of
18 nio-*.[ch] files and add the logic to NetIO::open here */
38 NetIO::NetIO (char *Purl)
56 NetIO::set_url (char *Purl)
68 ep = strstr (bp, "://");
80 ep = bp + strcspn (bp, ":/");
89 ep = strchr (ep, '/');
103 NetIO::read (char *buf, int nbytes)
109 NetIO::open (char *url)
112 enum {http, ftp, file} proto;
113 if (strncmp (url, "http://", 7) == 0)
115 else if (strncmp (url, "ftp://", 6) == 0)
121 rv = new NetIO_File (url);
122 else if (net_method == IDC_NET_IE5)
123 rv = new NetIO_IE5 (url);
124 else if (net_method == IDC_NET_PROXY)
125 rv = new NetIO_HTTP (url);
126 else if (net_method == IDC_NET_DIRECT)
131 rv = new NetIO_HTTP (url);
134 rv = new NetIO_FTP (url);
149 static char **user, **passwd;
150 static int loading = 0;
153 check_if_enable_ok (HWND h)
156 if (*user && *passwd)
158 EnableWindow (GetDlgItem (h, IDOK), e);
165 eset (h, IDC_NET_USER, *user);
166 eset (h, IDC_NET_PASSWD, *passwd);
167 check_if_enable_ok (h);
174 *user = eget (h, IDC_NET_USER, *user);
175 *passwd = eget (h, IDC_NET_PASSWD, *passwd);
179 auth_cmd (HWND h, int id, HWND hwndctl, UINT code)
186 if (code == EN_CHANGE && !loading)
189 check_if_enable_ok (h);
207 auth_proc (HWND h, UINT message, WPARAM wParam, LPARAM lParam)
215 return HANDLE_WM_COMMAND (h, wParam, lParam, auth_cmd);
221 auth_common (HINSTANCE h, int id)
223 return DialogBox (h, MAKEINTRESOURCE (id), 0, auth_proc);
230 passwd = &net_passwd;
231 return auth_common (hinstance, IDD_NET_AUTH);
235 NetIO::get_proxy_auth ()
237 user = &net_proxy_user;
238 passwd = &net_proxy_passwd;
239 return auth_common (hinstance, IDD_PROXY_AUTH);