Piotr Caban : wininet: Added INTERNET_OPTION_ERROR_MASK flag handling to InternetSetOptionW.

Alexandre Julliard julliard at winehq.org
Wed May 19 10:34:17 CDT 2010


Module: wine
Branch: master
Commit: ee72094ca8013853c224db73731489b6c2756272
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=ee72094ca8013853c224db73731489b6c2756272

Author: Piotr Caban <piotr at codeweavers.com>
Date:   Wed May 19 12:29:09 2010 +0200

wininet: Added INTERNET_OPTION_ERROR_MASK flag handling to InternetSetOptionW.

---

 dlls/wininet/internet.c       |   15 ++++++++-
 dlls/wininet/internet.h       |    1 +
 dlls/wininet/tests/internet.c |   65 ++++++++++++++++++++++++++++++++++++-----
 include/wininet.h             |    3 ++
 4 files changed, 74 insertions(+), 10 deletions(-)

diff --git a/dlls/wininet/internet.c b/dlls/wininet/internet.c
index eb3c8e2..9e32046 100644
--- a/dlls/wininet/internet.c
+++ b/dlls/wininet/internet.c
@@ -2484,8 +2484,19 @@ BOOL WINAPI InternetSetOptionW(HINTERNET hInternet, DWORD dwOption,
       break;
     case INTERNET_OPTION_ERROR_MASK:
       {
-        ULONG flags = *(ULONG *)lpBuffer;
-        FIXME("Option INTERNET_OPTION_ERROR_MASK(%d): STUB\n", flags);
+        if(!lpwhh) {
+            SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE);
+            return FALSE;
+        } else if(*(ULONG*)lpBuffer & (~(INTERNET_ERROR_MASK_INSERT_CDROM|
+                        INTERNET_ERROR_MASK_COMBINED_SEC_CERT|
+                        INTERNET_ERROR_MASK_LOGIN_FAILURE_DISPLAY_ENTITY_BODY))) {
+            SetLastError(ERROR_INVALID_PARAMETER);
+            ret = FALSE;
+        } else if(dwBufferLength != sizeof(ULONG)) {
+            SetLastError(ERROR_INTERNET_BAD_OPTION_LENGTH);
+            ret = FALSE;
+        } else
+            lpwhh->ErrorMask = *(ULONG*)lpBuffer;
       }
       break;
     case INTERNET_OPTION_CODEPAGE:
diff --git a/dlls/wininet/internet.h b/dlls/wininet/internet.h
index 6fdb5dc..64bfdaa 100644
--- a/dlls/wininet/internet.h
+++ b/dlls/wininet/internet.h
@@ -156,6 +156,7 @@ struct _object_header_t
     DWORD  dwFlags;
     DWORD_PTR dwContext;
     DWORD  dwError;
+    ULONG  ErrorMask;
     DWORD  dwInternalFlags;
     LONG   refs;
     INTERNET_STATUS_CALLBACK lpfnStatusCB;
diff --git a/dlls/wininet/tests/internet.c b/dlls/wininet/tests/internet.c
index fa28b0c..4da9c21 100644
--- a/dlls/wininet/tests/internet.c
+++ b/dlls/wininet/tests/internet.c
@@ -835,27 +835,75 @@ static void test_PrivacyGetSetZonePreferenceW(void)
     ok(ret == 0, "expected ret == 0, got %u\n", ret);
 }
 
-static void test_Option_Policy(void)
+static void test_InternetSetOption(void)
 {
-    HINTERNET hinet;
+    HINTERNET ses, con, req;
+    ULONG ulArg;
+    DWORD size;
     BOOL ret;
 
-    hinet = InternetOpen(NULL, INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
-    ok(hinet != 0, "InternetOpen failed: 0x%08x\n", GetLastError());
+    ses = InternetOpen(NULL, INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
+    ok(ses != 0, "InternetOpen failed: 0x%08x\n", GetLastError());
+    con = InternetConnect(ses, "www.winehq.org", 80, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
+    ok(con != 0, "InternetConnect failed: 0x%08x\n", GetLastError());
+    req = HttpOpenRequest(con, "GET", "/", NULL, NULL, NULL, 0, 0);
+    ok(req != 0, "HttpOpenRequest failed: 0x%08x\n", GetLastError());
 
+    /* INTERNET_OPTION_POLICY tests */
     SetLastError(0xdeadbeef);
-    ret = InternetSetOptionW(hinet, INTERNET_OPTION_POLICY, NULL, 0);
+    ret = InternetSetOptionW(ses, INTERNET_OPTION_POLICY, NULL, 0);
     ok(ret == FALSE, "InternetSetOption should've failed\n");
     ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError should've "
             "given ERROR_INVALID_PARAMETER, gave: 0x%08x\n", GetLastError());
 
     SetLastError(0xdeadbeef);
-    ret = InternetQueryOptionW(hinet, INTERNET_OPTION_POLICY, NULL, 0);
+    ret = InternetQueryOptionW(ses, INTERNET_OPTION_POLICY, NULL, 0);
     ok(ret == FALSE, "InternetQueryOption should've failed\n");
     ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError should've "
             "given ERROR_INVALID_PARAMETER, gave: 0x%08x\n", GetLastError());
 
-    ret = InternetCloseHandle(hinet);
+    /* INTERNET_OPTION_ERROR_MASK tests */
+    SetLastError(0xdeadbeef);
+    size = sizeof(ulArg);
+    ret = InternetQueryOptionW(NULL, INTERNET_OPTION_ERROR_MASK, (void*)&ulArg, &size);
+    ok(ret == FALSE, "InternetQueryOption should've failed\n");
+    ok(GetLastError() == ERROR_INTERNET_INCORRECT_HANDLE_TYPE, "GetLastError() = %x\n", GetLastError());
+
+    SetLastError(0xdeadbeef);
+    ulArg = 11;
+    ret = InternetSetOption(NULL, INTERNET_OPTION_ERROR_MASK, (void*)&ulArg, sizeof(ULONG));
+    ok(ret == FALSE, "InternetQueryOption should've failed\n");
+    ok(GetLastError() == ERROR_INTERNET_INCORRECT_HANDLE_TYPE, "GetLastError() = %x\n", GetLastError());
+
+    SetLastError(0xdeadbeef);
+    ulArg = 11;
+    ret = InternetSetOption(req, INTERNET_OPTION_ERROR_MASK, (void*)&ulArg, 20);
+    ok(ret == FALSE, "InternetQueryOption should've failed\n");
+    ok(GetLastError() == ERROR_INTERNET_BAD_OPTION_LENGTH, "GetLastError() = %d\n", GetLastError());
+
+    SetLastError(0xdeadbeef);
+    ulArg = 11;
+    ret = InternetSetOption(req, INTERNET_OPTION_ERROR_MASK, (void*)&ulArg, sizeof(ULONG));
+    ok(ret == TRUE, "InternetQueryOption should've succeeded\n");
+    ok(GetLastError() == 0xdeadbeef, "GetLastError() = %d\n", GetLastError());
+
+    SetLastError(0xdeadbeef);
+    ulArg = 4;
+    ret = InternetSetOption(req, INTERNET_OPTION_ERROR_MASK, (void*)&ulArg, sizeof(ULONG));
+    ok(ret == FALSE, "InternetQueryOption should've failed\n");
+    ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError() = %x\n", GetLastError());
+
+    SetLastError(0xdeadbeef);
+    ulArg = 16;
+    ret = InternetSetOption(req, INTERNET_OPTION_ERROR_MASK, (void*)&ulArg, sizeof(ULONG));
+    ok(ret == FALSE, "InternetQueryOption should've failed\n");
+    ok(GetLastError() == ERROR_INVALID_PARAMETER, "GetLastError() = %x\n", GetLastError());
+
+    ret = InternetCloseHandle(req);
+    ok(ret == TRUE, "InternetCloseHandle failed: 0x%08x\n", GetLastError());
+    ret = InternetCloseHandle(con);
+    ok(ret == TRUE, "InternetCloseHandle failed: 0x%08x\n", GetLastError());
+    ret = InternetCloseHandle(ses);
     ok(ret == TRUE, "InternetCloseHandle failed: 0x%08x\n", GetLastError());
 }
 
@@ -1097,7 +1145,6 @@ START_TEST(internet)
     test_complicated_cookie();
     test_version();
     test_null();
-    test_Option_Policy();
     test_Option_PerConnectionOption();
     test_Option_PerConnectionOptionA();
 
@@ -1123,4 +1170,6 @@ START_TEST(internet)
         test_PrivacyGetSetZonePreferenceW();
     else
         win_skip("Privacy[SG]etZonePreferenceW are not available\n");
+
+    test_InternetSetOption();
 }
diff --git a/include/wininet.h b/include/wininet.h
index 1cb0508..a0ec408 100644
--- a/include/wininet.h
+++ b/include/wininet.h
@@ -122,6 +122,9 @@ INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTP)
                                 )
 
 #define INTERNET_ERROR_MASK_INSERT_CDROM                    0x1
+#define INTERNET_ERROR_MASK_COMBINED_SEC_CERT               0x2
+#define INTERNET_ERROR_MASK_NEED_MSN_SSPI_PKG               0x4
+#define INTERNET_ERROR_MASK_LOGIN_FAILURE_DISPLAY_ENTITY_BODY 0x8
 
 #define INTERNET_OPTIONS_MASK   (~INTERNET_FLAGS_MASK)
 #define WININET_API_FLAG_ASYNC          0x00000001




More information about the wine-cvs mailing list