]>
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 */
21 static const char *cvsid
=
27 #include "LogSingleton.h"
42 int NetIO::net_method
;
43 char *NetIO::net_proxy_host
;
44 int NetIO::net_proxy_port
;
46 char *NetIO::net_user
;
47 char *NetIO::net_passwd
;
48 char *NetIO::net_proxy_user
;
49 char *NetIO::net_proxy_passwd
;
50 char *NetIO::net_ftp_user
;
51 char *NetIO::net_ftp_passwd
;
53 NetIO::NetIO (char const *Purl
)
71 NetIO::set_url (char const *Purl
)
76 url
= new char[strlen (Purl
) + 1];
84 ep
= strstr (bp
, "://");
92 proto
= new char [strlen (bp
)+1];
97 ep
= bp
+ strcspn (bp
, ":/");
100 host
= new char [strlen (bp
) + 1];
106 port
= atoi (ep
+ 1);
107 ep
= strchr (ep
, '/');
112 path
= new char [strlen (ep
)+1];
124 NetIO::read (char *buf
, int nbytes
)
130 NetIO::open (char const *url
)
136 if (strncmp (url
, "http://", 7) == 0)
138 else if (strncmp (url
, "ftp://", 6) == 0)
144 rv
= new NetIO_File (url
);
145 else if (net_method
== IDC_NET_IE5
)
146 rv
= new NetIO_IE5 (url
);
147 else if (net_method
== IDC_NET_PROXY
)
148 rv
= new NetIO_HTTP (url
);
149 else if (net_method
== IDC_NET_DIRECT
)
154 rv
= new NetIO_HTTP (url
);
157 rv
= new NetIO_FTP (url
);
160 rv
= new NetIO_File (url
);
175 static char **user
, **passwd
;
176 static int loading
= 0;
179 check_if_enable_ok (HWND h
)
184 EnableWindow (GetDlgItem (h
, IDOK
), e
);
191 eset (h
, IDC_NET_USER
, *user
);
192 eset (h
, IDC_NET_PASSWD
, *passwd
);
193 check_if_enable_ok (h
);
200 *user
= eget (h
, IDC_NET_USER
, *user
);
201 *passwd
= eget (h
, IDC_NET_PASSWD
, *passwd
);
203 *passwd
= new char[1];
209 auth_cmd (HWND h
, int id
, HWND hwndctl
, UINT code
)
216 if (code
== EN_CHANGE
&& !loading
)
219 check_if_enable_ok (h
);
230 LogSingleton::GetInstance().exit (1);
237 auth_proc (HWND h
, UINT message
, WPARAM wParam
, LPARAM lParam
)
245 auth_cmd (h
, LOWORD(wParam
), (HWND
)lParam
, HIWORD(wParam
));
252 auth_common (HINSTANCE h
, int id
, HWND owner
)
254 return DialogBox (h
, MAKEINTRESOURCE (id
), owner
, auth_proc
);
258 NetIO::get_auth (HWND owner
)
261 passwd
= &net_passwd
;
262 return auth_common (hinstance
, IDD_NET_AUTH
, owner
);
266 NetIO::get_proxy_auth (HWND owner
)
268 user
= &net_proxy_user
;
269 passwd
= &net_proxy_passwd
;
270 return auth_common (hinstance
, IDD_PROXY_AUTH
, owner
);
274 NetIO::get_ftp_auth (HWND owner
)
278 delete[] net_ftp_user
;
283 delete[] net_ftp_passwd
;
284 net_ftp_passwd
= NULL
;
288 user
= &net_ftp_user
;
289 passwd
= &net_ftp_passwd
;
290 return auth_common (hinstance
, IDD_FTP_AUTH
, owner
);
This page took 0.047153 seconds and 5 git commands to generate.