]>
cygwin.com Git - cygwin-apps/setup.git/blob - netio.cc
2 * Copyright (c) 2000, 2001, 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 */
36 int NetIO::net_method
;
37 char *NetIO::net_proxy_host
;
38 int NetIO::net_proxy_port
;
40 char *NetIO::net_user
;
41 char *NetIO::net_passwd
;
42 char *NetIO::net_proxy_user
;
43 char *NetIO::net_proxy_passwd
;
44 char *NetIO::net_ftp_user
;
45 char *NetIO::net_ftp_passwd
;
54 NetIO::read (char *buf
, int nbytes
)
60 NetIO::open (char const *url
, bool cachable
)
66 { http
, https
, ftp
, ftps
, file
}
68 if (strncmp (url
, "http://", 7) == 0)
70 else if (strncmp (url
, "https://", 8) == 0)
72 else if (strncmp (url
, "ftp://", 6) == 0)
74 else if (strncmp (url
, "ftps://", 7) == 0)
76 else if (strncmp (url
, "file://", 7) == 0)
80 // WinInet expects a 'legacy' file:// URL
81 // (i.e. a windows path with "file://" prepended)
82 // https://blogs.msdn.microsoft.com/freeassociations/2005/05/19/the-bizarre-and-unhappy-story-of-file-urls/
85 if (S_OK
== PathCreateFromUrl(url
, path
, &len
, 0))
87 file_url
= std::string("file://") + path
;
88 url
= file_url
.c_str();
92 // treat everything else as a windows path
95 file_url
= std::string("file://") + url
;
96 url
= file_url
.c_str();
99 rv
= new NetIO_IE5 (url
, proto
== file
? false : cachable
);
101 if (rv
&& !rv
->ok ())
111 static char **user
, **passwd
;
112 static int loading
= 0;
115 check_if_enable_ok (HWND h
)
120 EnableWindow (GetDlgItem (h
, IDOK
), e
);
127 eset (h
, IDC_NET_USER
, *user
);
128 eset (h
, IDC_NET_PASSWD
, *passwd
);
129 check_if_enable_ok (h
);
136 *user
= eget (h
, IDC_NET_USER
, *user
);
137 *passwd
= eget (h
, IDC_NET_PASSWD
, *passwd
);
139 *passwd
= new char[1];
145 auth_cmd (HWND h
, int id
, HWND hwndctl
, UINT code
)
152 if (code
== EN_CHANGE
&& !loading
)
155 check_if_enable_ok (h
);
172 static INT_PTR CALLBACK
173 auth_proc (HWND h
, UINT message
, WPARAM wParam
, LPARAM lParam
)
181 auth_cmd (h
, LOWORD(wParam
), (HWND
)lParam
, HIWORD(wParam
));
188 auth_common (HINSTANCE h
, int id
, HWND owner
)
190 return DialogBox (h
, MAKEINTRESOURCE (id
), owner
, auth_proc
);
194 NetIO::get_auth (HWND owner
)
197 passwd
= &net_passwd
;
198 return auth_common (hinstance
, IDD_NET_AUTH
, owner
);
202 NetIO::get_proxy_auth (HWND owner
)
204 user
= &net_proxy_user
;
205 passwd
= &net_proxy_passwd
;
206 return auth_common (hinstance
, IDD_PROXY_AUTH
, owner
);
210 NetIO::get_ftp_auth (HWND owner
)
214 delete[] net_ftp_user
;
219 delete[] net_ftp_passwd
;
220 net_ftp_passwd
= NULL
;
222 user
= &net_ftp_user
;
223 passwd
= &net_ftp_passwd
;
224 return auth_common (hinstance
, IDD_FTP_AUTH
, owner
);
228 NetIO::net_method_name ()
232 case IDC_NET_PRECONFIG
:
This page took 0.082044 seconds and 6 git commands to generate.