Reviewed by mjs.
authormjs <mjs@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 8 Mar 2006 11:56:08 +0000 (11:56 +0000)
committermjs <mjs@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 8 Mar 2006 11:56:08 +0000 (11:56 +0000)
        Add stubs to allow JavaScript-enabled WebCore to not crash.
        Add ScreenWin implementation.
        Add alert() support.

        * WebCore.vcproj/WebCore/WebCore.vcproj:
        * bridge/win/FrameWin.cpp:
        (WebCore::FrameWin::runJavaScriptAlert):
        (WebCore::FrameWin::runJavaScriptConfirm):
        * platform/win/ScreenWin.cpp: Added.
        (WebCore::monitorInfoForWidget):
        (WebCore::WebCore::screenRect):
        (WebCore::WebCore::screenDepth):
        (WebCore::WebCore::usableScreenRect):
        * platform/win/TemporaryLinkStubs.cpp:
        (FrameWin::canUndo):
        (FrameWin::runJavaScriptPrompt):
        (FrameWin::canPaste):
        (WebCore::setCookies):
        (WebCore::cookies):
        (WebCore::cookiesEnabled):
        (PlugInInfoStore::createPluginInfoForPluginAtIndex):
        (PlugInInfoStore::pluginCount):
        (WebCore::refreshPlugins):
        (FrameWin::clearUndoRedoOperations):
        (FrameWin::incomingReferrer):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@13213 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog
WebCore/platform/TransferJob.h
WebCore/platform/TransferJobInternal.h
WebCore/platform/win/TransferJobWin.cpp

index b4a99e5..46c487a 100644 (file)
 
 2006-03-08  Maciej Stachowiak  <mjs@apple.com>
 
+        Reviewed by Eric.
+
+        - very rough implementation of networking in TransferJob for windows
+
+        * platform/TransferJob.h:
+        * platform/TransferJobInternal.h:
+        (WebCore::TransferJobInternal::TransferJobInternal):
+        * platform/win/TransferJobWin.cpp:
+        (WebCore::transferJobStatusCallback):
+        (WebCore::TransferJob::start):
+
+2006-03-08  Maciej Stachowiak  <mjs@apple.com>
+
         Reviewed by Darin.
 
         - fix win32 build
index 17904a2..698ec94 100644 (file)
 #include <kxmlcore/HashMap.h>
 #include "Timer.h"
 
+#ifdef WIN32
+typedef unsigned long DWORD;
+typedef unsigned long DWORD_PTR;
+typedef void* LPVOID;
+typedef LPVOID HINTERNET;
+typedef LPVOID HANDLE;
+#endif
+
 #if __APPLE__
 #ifdef __OBJC__
 @class KWQResourceLoader;
@@ -72,7 +80,8 @@ public:
     void setLoader(KWQResourceLoader*);
 #endif
 #if WIN32
-    void TransferJob::fileLoadTimer(Timer<TransferJob>* timer);
+    void fileLoadTimer(Timer<TransferJob>* timer);
+    friend void __stdcall transferJobStatusCallback(HINTERNET, DWORD_PTR, DWORD, LPVOID, DWORD);
 #endif
 
     void cancel();
index 64da8d4..45b7d32 100644 (file)
@@ -29,9 +29,6 @@
 
 #include "KURL.h"
 #include "formdata.h"
-#if WIN32
-#include "windows.h"
-#endif
 
 // The allocations and releases in TransferJobInternal are
 // definitely Cocoa-exception-free (either simple Foundation
@@ -99,8 +96,9 @@ namespace WebCore {
         NSURLResponse* response;
 #endif
 #if WIN32
-                HANDLE m_fileHandle;
-                Timer<TransferJob> m_fileLoadTimer;
+        HANDLE m_fileHandle;
+        Timer<TransferJob> m_fileLoadTimer;
+        HINTERNET m_resourceHandle;
 #endif
         };
 
index 629553b..cd0057c 100644 (file)
@@ -29,6 +29,8 @@
 #include "TransferJobInternal.h"
 #include "KURL.h"
 #include "formdata.h"
+#include <windows.h>
+#include <wininet.h>
 
 namespace WebCore {
     
@@ -42,6 +44,33 @@ TransferJob::~TransferJob()
 {
 }
 
+static void __stdcall transferJobStatusCallback(HINTERNET internetHandle, DWORD_PTR context, DWORD internetStatus, LPVOID statusInformation, DWORD statusInformationLength)
+{
+    TransferJob* job = (TransferJob*)context;
+
+    if (internetStatus == INTERNET_STATUS_HANDLE_CREATED)
+        job->d->m_resourceHandle = HINTERNET(LPINTERNET_ASYNC_RESULT(statusInformation)->dwResult);
+    else if (internetStatus == INTERNET_STATUS_REQUEST_COMPLETE) {
+        HINTERNET resourceHandle = job->d->m_resourceHandle;
+
+        char buffer[32728];
+        DWORD bytesRead = 0;
+        DWORD totalBytes = 0;
+        bool ok = false;
+        while ((ok = InternetReadFile(resourceHandle, buffer, 32728, &bytesRead)) && bytesRead) {
+            job->client()->receivedData(job, buffer, bytesRead);
+            totalBytes += bytesRead;
+            bytesRead = 0;
+        }
+         
+        if (ok) {
+            InternetCloseHandle(resourceHandle);
+            job->client()->receivedAllData(job, 0);
+            job->client()->receivedAllData(job);
+        }
+    }
+}
+
 bool TransferJob::start(DocLoader* docLoader)
 {
     if (d->URL.isLocalFile()) {
@@ -50,15 +79,33 @@ bool TransferJob::start(DocLoader* docLoader)
         if (path[0] == '/')
             path = path.mid(1);
         d->m_fileHandle = CreateFileA(path.ascii(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
-    }
 
-    if (!d->m_fileHandle || d->m_fileHandle == INVALID_HANDLE_VALUE) {
-        delete this;
-        return false;
-    }
+        if (d->m_fileHandle == INVALID_HANDLE_VALUE) {
+            delete this;
+            return false;
+        }
+
+        d->m_fileLoadTimer.startOneShot(0.0);
+        return true;
+    } else {
+        // leak the Internet for now
+        static HINTERNET internetHandle = InternetOpen(L"Spinneret", INTERNET_OPEN_TYPE_PRECONFIG, 0, 0, INTERNET_FLAG_ASYNC);
+        if (!internetHandle) {
+            delete this;
+            return false;
+        }
+        static INTERNET_STATUS_CALLBACK callbackHandle = InternetSetStatusCallback(internetHandle, transferJobStatusCallback);
 
-    d->m_fileLoadTimer.startOneShot(0.0);
-    return true;
+        HINTERNET urlHandle =
+            InternetOpenUrlA(internetHandle, d->URL.url().ascii(), NULL, -1, 0, (DWORD_PTR)this);
+
+        if (urlHandle == INVALID_HANDLE_VALUE) {
+            delete this;
+            return false;
+        }
+
+        return true;
+    }
 }
 
 void TransferJob::fileLoadTimer(Timer<TransferJob>* timer)