[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    branches/work/unity/WebKit/WebCore/platform/qt
From:       Nikolas Zimmermann <wildfox () kde ! org>
Date:       2006-08-05 12:22:42
Message-ID: 1154780562.252871.29651.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 569986 by wildfox:

Making XMLHttpRequest work with this and my previous commit.

- Implement receivedResponse() & assempleResponseHeaders()
  in the TransferJob interface. Call it from TransferJobManager.
  (quite hackish using curl, see comments)

This makes it possible to receive answers from Rob's Ajax WebApp.
Jay! Now it crashes when displaying the new content, next one to fix :-)


 M  +5 -0      FrameQt.cpp  
 M  +1 -0      FrameQt.h  
 M  +0 -3      TemporaryLinkStubs.cpp  
 M  +48 -1     TransferJobCurl.cpp  
 M  +8 -1      TransferJobManager.cpp  


--- branches/work/unity/WebKit/WebCore/platform/qt/FrameQt.cpp #569985:569986
@@ -523,6 +523,11 @@
     return result;
 }
 
+void FrameQt::receivedRepsonse(TransferJob*, PlatformResponse)
+{
+    // no-op
+}
+
 void FrameQt::receivedData(TransferJob* job, const char* data, int length)
 {
     write(data, length);
--- branches/work/unity/WebKit/WebCore/platform/qt/FrameQt.h #569985:569986
@@ -134,6 +134,7 @@
 
     bool keyEvent(const PlatformKeyboardEvent &keyEvent);
 
+    virtual void receivedRepsonse(TransferJob*, PlatformResponse);
     virtual void receivedData(TransferJob*, const char*, int);
     virtual void receivedAllData(TransferJob*,PlatformData);
 
--- branches/work/unity/WebKit/WebCore/platform/qt/TemporaryLinkStubs.cpp #569985:569986
@@ -58,7 +58,6 @@
 #include "LocalizedStrings.h"
 #include "PlugInInfoStore.h"
 #include "RenderTheme.h"
-#include "TransferJob.h"
 #include "TextBoundaries.h"
 #include "AccessibilityObjectCache.h"
 #include "KWQKSSLKeyGen.h"
@@ -78,7 +77,6 @@
 void WebCore::refreshPlugins(bool) { notImplemented(); }
 
 Color WebCore::focusRingColor() { notImplemented(); return 0xFF0000FF; }
-void WebCore::TransferJob::assembleResponseHeaders() const { notImplemented(); }
 
 namespace WebCore {
 void QSlider::setValue(double) { notImplemented(); }
@@ -114,7 +112,6 @@
 void QLineEdit::setLiveSearch(bool) { notImplemented(); }
 
 }
-void WebCore::TransferJob::retrieveCharset() const { notImplemented(); }
 
 void KWQCheckCacheObjectStatus(DocLoader*, CachedObject*) { notImplemented(); }
 bool KWQCheckIfReloading(WebCore::DocLoader*) { notImplemented(); return false; }
--- branches/work/unity/WebKit/WebCore/platform/qt/TransferJobCurl.cpp #569985:569986
@@ -24,8 +24,9 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
  */
-
+#include <QDebug>
 #include "config.h"
+#include "HelperQt.h"
 #include "TransferJob.h"
 
 #include "DocLoader.h"
@@ -54,6 +55,52 @@
     TransferJobManager::get()->cancel(this);
 }
 
+void TransferJob::assembleResponseHeaders() const
+{
+    if (!d->assembledResponseHeaders) {
+        d->responseHeaders = DeprecatedString(d->response.constData(), d->response.length());
+
+        d->assembledResponseHeaders = true;
+ 
+        // TODO: Move the client activation to receivedResponse(), once
+        // we use KIO, and receivedResponse() is called only once.
+        if (d->client)
+            d->client->receivedResponse(const_cast<TransferJob *>(this), (char *) d->response.data());
+
+        d->response = QString(); // Reset
+    }
+}
+
+void TransferJob::retrieveCharset() const
+{
+    if (!d->retrievedCharset) {
+        d->retrievedCharset = true;
+    }
+
+    // TODO: We can just parse the headers here, but once we use KIO
+    // we can set the response parameter to sth. else than a "char*".
+    // I save my time but not implementing it for now :-)
+    notImplemented();
+}
+
+void TransferJob::receivedResponse(char* response)
+{
+    Q_ASSERT(method() == "POST");
+
+    d->assembledResponseHeaders = false;
+    d->retrievedCharset = false;
+
+    // TODO: This is flawed:
+    // - usually receivedResponse() should be called _once_, when the
+    //   response is available - seems very unflexible to do that with libcurl
+    //   (so let's wait until it dies and do it properly with KIO then.)
+    // - QString::fromLatin1() is also wrong, of course.
+    //
+    // Anyway, let's collect the response data here, as the TransferJobManager
+    // calls us for every line of the header it receives.
+    d->response += QString::fromLatin1(response);
+}
+
 } // namespace WebCore
 
 // vim: ts=4 sw=4 et
--- branches/work/unity/WebKit/WebCore/platform/qt/TransferJobManager.cpp #569985:569986
@@ -67,8 +67,15 @@
     return totalSize;
 }
 
-static size_t headerCallback(char* ptr, size_t size, size_t nmemb, void* data)
+static size_t headerCallback(char* ptr, size_t size, size_t nmemb, void* obj)
 {
+    TransferJob* job = static_cast<TransferJob*>(obj);
+    TransferJobInternal* d = job->getInternal();
+ 
+    if (job->method() == "POST") {
+        job->receivedResponse(ptr);
+    }
+    
     int totalSize = size * nmemb;
     return totalSize;
 }
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic