]> cygwin.com Git - cygwin-apps/setup.git/commitdiff
* nio-ie5.cc (NetIO_IE5): Fix authentication logic
authorDJ Delorie <dj@redhat.com>
Thu, 24 Aug 2000 02:48:14 +0000 (02:48 +0000)
committerDJ Delorie <dj@redhat.com>
Thu, 24 Aug 2000 02:48:14 +0000 (02:48 +0000)
* nio-ie5.h (flush_io): new
* netio.cc (load_dialog): note when we're initializing the dialog
box, and ignore changes to the edit fields then.

ChangeLog
netio.cc
nio-ie5.cc
nio-ie5.h

index ecec968f4ba6886db299f46470a4ef29d7f76030..dbd19a343f2044993d47b6f680c6e5b347533379 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2000-08-23  DJ Delorie  <dj@redhat.com>
+
+       * nio-ie5.cc (NetIO_IE5): Fix authentication logic
+       * nio-ie5.h (flush_io): new
+       * netio.cc (load_dialog): note when we're initializing the dialog
+       box, and ignore changes to the edit fields then.
+
 2000-08-21  DJ Delorie  <dj@redhat.com>
 
        * README: Update
index 4f37cb1ff37cd66d7a4e2e4894ebd3270891a318..8791be41406d13be45cd5e006e995c04019f5a21 100644 (file)
--- a/netio.cc
+++ b/netio.cc
@@ -132,12 +132,12 @@ NetIO::open (char *url)
 
 
 static char **user, **passwd;
+static int loading = 0;
 
 static void
 check_if_enable_ok (HWND h)
 {
   int e = 0;
-  msg ("u = %p p = %p", *user, *passwd);
   if (*user && *passwd)
     e = 1;
   EnableWindow (GetDlgItem (h, IDOK), e);
@@ -146,9 +146,11 @@ check_if_enable_ok (HWND h)
 static void
 load_dialog (HWND h)
 {
+  loading = 1;
   eset (h, IDC_NET_USER, *user);
   eset (h, IDC_NET_PASSWD, *passwd);
   check_if_enable_ok (h);
+  loading = 0;
 }
 
 static void
@@ -166,8 +168,11 @@ auth_cmd (HWND h, int id, HWND hwndctl, UINT code)
 
     case IDC_NET_USER:
     case IDC_NET_PASSWD:
-      save_dialog (h);
-      check_if_enable_ok (h);
+      if (code == EN_CHANGE && !loading)
+       {
+         save_dialog (h);
+         check_if_enable_ok (h);
+       }
       break;
 
     case IDOK:
index 25b8d54e340d41ed3cf5e67f63d48cb283273619..1032ed9ecedf588fbdb6e14856ea2e30a5d5e1ef 100644 (file)
@@ -34,6 +34,8 @@ static HINTERNET internet = 0;
 NetIO_IE5::NetIO_IE5 (char *_url)
   : NetIO (_url)
 {
+  int resend = 0;
+
   if (internet == 0)
     internet = InternetOpen ("Cygwin Setup", INTERNET_OPEN_TYPE_PRECONFIG,
                             NULL, NULL, 0);
@@ -46,25 +48,29 @@ NetIO_IE5::NetIO_IE5 (char *_url)
     INTERNET_FLAG_EXISTING_CONNECT |
     INTERNET_FLAG_PASSIVE;
 
+  connection = InternetOpenUrl (internet, url, NULL, 0, flags, 0);
+
  try_again:
 
   if (net_user && net_passwd)
     {
-      InternetSetOption (internet, INTERNET_OPTION_USERNAME,
+      InternetSetOption (connection, INTERNET_OPTION_USERNAME,
                         net_user, strlen (net_user));
-      InternetSetOption (internet, INTERNET_OPTION_PASSWORD,
+      InternetSetOption (connection, INTERNET_OPTION_PASSWORD,
                         net_passwd, strlen (net_passwd));
     }
 
   if (net_proxy_user && net_proxy_passwd)
     {
-      InternetSetOption (internet, INTERNET_OPTION_PROXY_USERNAME,
+      InternetSetOption (connection, INTERNET_OPTION_PROXY_USERNAME,
                         net_proxy_user, strlen (net_proxy_user));
-      InternetSetOption (internet, INTERNET_OPTION_PROXY_PASSWORD,
+      InternetSetOption (connection, INTERNET_OPTION_PROXY_PASSWORD,
                         net_proxy_passwd, strlen (net_proxy_passwd));
     }
 
-  connection = InternetOpenUrl (internet, url, NULL, 0, flags, 0);
+  if (resend)
+    if (!HttpSendRequest (connection, 0, 0, 0, 0))
+      connection = 0;
 
   if (!connection)
     {
@@ -93,12 +99,16 @@ NetIO_IE5::NetIO_IE5 (char *_url)
        {
          if (type == 401) /* authorization required */
            {
+             flush_io();
              get_auth ();
+             resend = 1;
              goto try_again;
            }
          else if (type == 407) /* proxy authorization required */
            {
+             flush_io();
              get_proxy_auth ();
+             resend = 1;
              goto try_again;
            }
          else if (type >= 300)
@@ -110,6 +120,16 @@ NetIO_IE5::NetIO_IE5 (char *_url)
     }
 }
 
+void
+NetIO_IE5::flush_io ()
+{
+  DWORD actual = 0;
+  char buf[1024];
+  do {
+    InternetReadFile (connection, buf, 1024, &actual);
+  } while (actual > 0);
+}
+
 NetIO_IE5::~NetIO_IE5 ()
 {
   if (connection)
index 42593335c9613536a726ffd89b2d1710d0f4adcf..4cc71d5641920362ea1f22a760959d4ec4e6c0b5 100644 (file)
--- a/nio-ie5.h
+++ b/nio-ie5.h
@@ -22,4 +22,5 @@ public:
   ~NetIO_IE5 ();
   virtual int ok ();
   virtual int read (char *buf, int nbytes);
+  void flush_io();
 };
This page took 0.038255 seconds and 5 git commands to generate.