[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: branches/work/unity
From: Nikolas Zimmermann <wildfox () kde ! org>
Date: 2006-08-23 23:02:47
Message-ID: 1156374167.532387.9948.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 576374 by wildfox:
Finally I can commit the UseKIO.patch!
Because of David's excellent work kio_http works fine again, so does \
unity+kio.
M +0 -6 CMakeLists.txt
D UseKIO.patch
M +3 -2 WebKit/WebCore/CMakeLists.txt
M +5 -0 WebKit/WebCore/kwq/KWQKIOGlobal.h
M +3 -8 WebKit/WebCore/platform/TransferJobInternal.h
D WebKit/WebCore/platform/qt/TransferJobCurl.cpp
M +92 -161 WebKit/WebCore/platform/qt/TransferJobManager.cpp
M +24 -29 WebKit/WebCore/platform/qt/TransferJobManager.h
A WebKit/WebCore/platform/qt/TransferJobQt.cpp [License: \
UNKNOWN]
--- branches/work/unity/CMakeLists.txt #576373:576374
@@ -17,8 +17,6 @@
# quick check the libicu is available
find_path(LIBICU_INCLUDE_DIR unicode/umachine.h )
-find_path(LIBCURL_INCLUDE_DIR curl/curl.h )
-
if (NOT BISON_EXECUTABLE)
message(FATAL_ERROR "Could not find bison. Bison is necessary. Please \
install it.") endif (NOT BISON_EXECUTABLE)
@@ -31,10 +29,6 @@
message(FATAL_ERROR "libicu not found, cannot create unity without it")
endif (NOT LIBICU_INCLUDE_DIR)
-if (NOT LIBCURL_INCLUDE_DIR)
- message(FATAL_ERROR "libcurl not found, cannot create unity without \
it")
-endif (NOT LIBCURL_INCLUDE_DIR)
-
add_definitions (${QT_DEFINITIONS} ${KDE4_DEFINITIONS} -DQT3_SUPPORT \
-DHAVE_CONFIG_H=1) link_directories (${KDE4_LIB_DIR})
include_directories (${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} \
${KDE4_INCLUDES} ${LIBICU_INCLUDE_DIR})
--- branches/work/unity/WebKit/WebCore/CMakeLists.txt #576373:576374
@@ -65,6 +65,7 @@
ENDIF(__KDE_HAVE_WVARIADIC_MACROS)
kde4_automoc(platform/qt/CanvasQt.cpp)
+kde4_automoc(platform/qt/TransferJobManager.cpp)
# rules for generated files
IF (USE_WEBKIT_SVG_SUPPORT)
@@ -850,7 +851,7 @@
platform/qt/RenderThemeQt.cpp
platform/qt/FontDataQt.cpp
platform/qt/SharedTimerLinux.cpp
- platform/qt/TransferJobCurl.cpp
+ platform/qt/TransferJobQt.cpp
platform/qt/TransferJobManager.cpp
platform/qt/FloatPointQt.cpp
platform/qt/ListBoxQt.cpp
@@ -1006,7 +1007,7 @@
${LIBXSLT_LIBRARIES}
${LIBXML2_LIBRARIES}
icuuc
- curl
+ kio
wtf-unity
kjs-unity
pcre-unity
--- branches/work/unity/WebKit/WebCore/kwq/KWQKIOGlobal.h #576373:576374
@@ -26,6 +26,8 @@
#ifndef KIO_GLOBAL_H_
#define KIO_GLOBAL_H_
+#if __APPLE__
+
namespace KIO {
enum CacheControl
@@ -37,5 +39,8 @@
};
}
+#elif PLATFORM(QT)
+#include <kio/global.h>
+#endif
#endif /* KIO_GLOBAL_H_ */
--- branches/work/unity/WebKit/WebCore/platform/TransferJobInternal.h \
#576373:576374 @@ -40,8 +40,7 @@
#endif
#if PLATFORM(QT)
-#include <QString>
-typedef void CURL;
+#include <kio/job.h>
#endif
// The allocations and releases in TransferJobInternal are
@@ -76,7 +75,7 @@
, m_formDataLength(0)
, m_bytesRemainingToWrite(0)
#endif
-#if PLATFORM(GDK) || PLATFORM(QT)
+#if PLATFORM(GDK)
, m_handle(0)
#endif
{
@@ -106,7 +105,7 @@
, m_formDataLength(0)
, m_bytesRemainingToWrite(0)
#endif
-#if PLATFORM(GDK) || PLATFORM(QT)
+#if PLATFORM(GDK)
, m_handle(0)
#endif
{
@@ -146,10 +145,6 @@
#if PLATFORM(GDK)
CURL *m_handle;
#endif
-#if PLATFORM(QT)
- CURL *m_handle;
- QString response;
-#endif
};
} // namespace WebCore
--- branches/work/unity/WebKit/WebCore/platform/qt/TransferJobManager.cpp \
#576373:576374 @@ -1,6 +1,6 @@
/*
- * Copyright (C) 2004, 2006 Apple Computer, Inc. All rights reserved.
- * Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com
+ * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
+ *
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -25,185 +25,127 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include <QDebug>
+#include <kio/job.h>
+
#include "config.h"
+#include "HelperQt.h"
#include "TransferJobManager.h"
-
-#include "TransferJob.h"
#include "TransferJobInternal.h"
namespace WebCore {
-const int selectTimeoutMS = 5;
-const double pollTimeSeconds = 0.05;
+static TransferJobManager *s_self = 0;
-TransferJobManager::TransferJobManager()
- : m_useSimple(false)
- , jobs(new HashSet<TransferJob*>)
- , m_downloadTimer(this, &TransferJobManager::downloadTimerCallback)
+TransferJobManager::TransferJobManager() : m_jobToKioMap(), \
m_kioToJobMap() {
- curl_global_init(CURL_GLOBAL_ALL);
- curlMultiHandle = curl_multi_init();
}
-TransferJobManager* TransferJobManager::get()
+TransferJobManager::~TransferJobManager()
{
- static TransferJobManager* singleton;
- if (!singleton)
- singleton = new TransferJobManager;
- return singleton;
}
-void TransferJobManager::useSimpleTransfer(bool useSimple)
+TransferJobManager *TransferJobManager::self()
{
- m_useSimple = useSimple;
+ if(!s_self)
+ s_self = new TransferJobManager();
+
+ return s_self;
}
-static size_t writeCallback(void* ptr, size_t size, size_t nmemb, void* \
obj) +void TransferJobManager::slotData(KIO::Job *kioJob, const QByteArray \
&data) {
- TransferJob* job = static_cast<TransferJob*>(obj);
- TransferJobInternal* d = job->getInternal();
- int totalSize = size * nmemb;
- d->client->receivedData(job, static_cast<char*>(ptr), totalSize);
- return totalSize;
+ qDebug("TransferJobManager::slotData() kioJob=%p", kioJob);
+
+ TransferJob *job = 0;
+
+ // Check if we know about 'kioJob'...
+ QMap<KIO::Job *, TransferJob *>::const_iterator it = \
m_kioToJobMap.find(kioJob); + if(it != m_kioToJobMap.end())
+ job = it.value();
+
+ if(!job)
+ return;
+
+ TransferJobInternal *d = job->getInternal();
+ if(!d || !d->client)
+ return;
+
+ d->client->receivedData(job, data.data(), data.size());
}
-static size_t headerCallback(char* ptr, size_t size, size_t nmemb, void* \
obj) +void TransferJobManager::slotMimetype(KIO::Job *job, const QString \
&type) {
- TransferJob* job = static_cast<TransferJob*>(obj);
- TransferJobInternal* d = job->getInternal();
-
- if (job->method() == "POST") {
- job->receivedResponse(ptr);
- }
-
- int totalSize = size * nmemb;
- return totalSize;
+ qDebug("TransferJobManager::slotMimetype(), job=%p, type=%s", job, \
qPrintable(type)); }
-void TransferJobManager::downloadTimerCallback(Timer<TransferJobManager>* \
timer) +void TransferJobManager::slotResult(KJob *kjob)
{
- if (jobs->isEmpty()) {
- m_downloadTimer.stop();
+ qDebug("TransferJobManager::slotResult(), kjob=%p", kjob);
+
+ KIO::Job *kioJob = qobject_cast<KIO::Job *>(kjob);
+ if(!kioJob)
return;
- }
- if (m_useSimple) {
- for (HashSet<TransferJob*>::iterator it = jobs->begin(); it != \
jobs->end(); ++it) {
- TransferJob* job = *it;
- TransferJobInternal* d = job->getInternal();
- CURLcode res = curl_easy_perform(d->m_handle);
- if (res != CURLE_OK)
- printf("Error WITH JOB %d\n", res);
- d->client->receivedAllData(job, 0);
- d->client->receivedAllData(job);
- curl_easy_cleanup(d->m_handle);
- d->m_handle = 0;
- }
- jobs->clear();
- m_downloadTimer.stop();
- } else {
- FD_ZERO(&fdread);
- FD_ZERO(&fdwrite);
- FD_ZERO(&fdexcep);
- curl_multi_fdset(curlMultiHandle, &fdread, &fdwrite, &fdexcep, \
&maxfd);
- int nrunning;
- struct timeval timeout;
- int retval;
- timeout.tv_sec = 0;
- timeout.tv_usec = selectTimeoutMS * 1000; // select waits \
microseconds
- retval = ::select(maxfd + 1, &fdread, &fdwrite, &fdexcep, \
&timeout);
- switch (retval) {
- case -1: // select error
-#ifndef NDEBUG
- printf("%s, select error(%d)\n", \
__PRETTY_FUNCTION__,retval);
-#endif
- /* fallthrough*/
- case 0: // select timeout
-#ifndef NDEBUG
- printf("%s, select timeout %d\n", \
__PRETTY_FUNCTION__,retval);
-#endif
- /* fallthrough. this can be the first perform to be made \
*/
- default: // 1+ descriptors have data
- while (CURLM_CALL_MULTI_PERFORM == \
curl_multi_perform(curlMultiHandle, &nrunning))
- { }
- }
- // check the curl messages indicating completed transfers
- // and free their resources
- TransferJob* job;
- int nmsgs;
- while (CURLMsg* msg = curl_multi_info_read(curlMultiHandle, \
&nmsgs)) {
- if (msg->msg == CURLMSG_DONE) {
- // find the node which has same d->m_handle as completed \
transfer
- CURL* chandle = msg->easy_handle;
- assert(chandle);
- TransferJob *job;
- curl_easy_getinfo(chandle, CURLINFO_PRIVATE, &job);
- assert(job); //fixme: assert->if ?
- // if found, delete it
- if (job) {
- TransferJobInternal *d = job->getInternal();
- switch (msg->data.result) {
- case CURLE_OK: {
- // use this to authenticate
- long respCode = -1;
- curl_easy_getinfo(d->m_handle, \
CURLINFO_RESPONSE_CODE, &respCode);
- remove(job);
- break;
- }
- default:
- printf("Curl ERROR %s\n", \
curl_easy_strerror(msg->data.result));
- job->setError(msg->data.result);
- remove(job);
- break;
- }
- } else {
- printf("CurlRequest not found, eventhough curl \
d->m_handle finished\n");
- assert(0);
- }
- }
+ TransferJob *job = 0;
- }
- }
- if (!jobs->isEmpty())
- m_downloadTimer.startOneShot(pollTimeSeconds);
+ // Check if we know about 'kioJob'...
+ QMap<KIO::Job *, TransferJob *>::const_iterator it = \
m_kioToJobMap.find(kioJob); + if(it != m_kioToJobMap.end())
+ job = it.value();
+
+ if(!job)
+ return;
+
+ job->setError(kjob->error());
+ remove(job);
}
-void TransferJobManager::remove(TransferJob* job)
+void TransferJobManager::remove(TransferJob *job)
{
- TransferJobInternal* d = job->getInternal();
- if (!d->m_handle)
+ qDebug("TransferJobManager::remove(), job=%p", job);
+
+ TransferJobInternal *d = job->getInternal();
+ if(!d || !d->client)
return;
- if (jobs->contains(job))
- jobs->remove(job);
- if (jobs->isEmpty())
- m_downloadTimer.stop();
+
+ KIO::Job *kioJob = 0;
+
+ // Check if we know about 'job'...
+ QMap<TransferJob *, KIO::Job *>::const_iterator it = \
m_jobToKioMap.find(job); + if(it != m_jobToKioMap.end())
+ kioJob = it.value();
+
+ if(!kioJob)
+ return;
+
d->client->receivedAllData(job, 0);
d->client->receivedAllData(job);
- if (d->m_handle) {
- curl_multi_remove_handle(curlMultiHandle, d->m_handle);
- curl_easy_cleanup(d->m_handle);
- d->m_handle = NULL;
- }
+
+ m_jobToKioMap.remove(job);
+ m_kioToJobMap.remove(kioJob);
}
-void TransferJobManager::add(TransferJob* job)
+void TransferJobManager::add(TransferJob *job)
{
- bool startTimer = jobs->isEmpty();
- TransferJobInternal* d = job->getInternal();
+ TransferJobInternal *d = job->getInternal();
DeprecatedString url = d->URL.url();
- d->m_handle = curl_easy_init();
- curl_easy_setopt(d->m_handle, CURLOPT_PRIVATE, job);
- curl_easy_setopt(d->m_handle, CURLOPT_ERRORBUFFER, error_buffer);
- curl_easy_setopt(d->m_handle, CURLOPT_WRITEFUNCTION, writeCallback);
- curl_easy_setopt(d->m_handle, CURLOPT_WRITEDATA, job);
- curl_easy_setopt(d->m_handle, CURLOPT_HEADERFUNCTION, headerCallback);
- curl_easy_setopt(d->m_handle, CURLOPT_WRITEHEADER, job);
- curl_easy_setopt(d->m_handle, CURLOPT_FOLLOWLOCATION, 1);
- curl_easy_setopt(d->m_handle, CURLOPT_MAXREDIRS, 10);
- curl_easy_setopt(d->m_handle, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
- // url ptr must remain valid through the request
- curl_easy_setopt(d->m_handle, CURLOPT_URL, url.ascii());
+ qDebug("TransferJobManager::add(), job=%p, url=%s", job, \
url.latin1()); +
+ if(job->method() == "GET")
+ {
+ KIO::Job *kioJob = KIO::get(KUrl(toQString(url)), false, false);
+
+ m_jobToKioMap.insert(job, kioJob);
+ m_kioToJobMap.insert(kioJob, job);
+
+ QObject::connect(kioJob, SIGNAL(data(KIO::Job *, const QByteArray \
&)), this, SLOT(slotData(KIO::Job *, const QByteArray &))); + \
QObject::connect(kioJob, SIGNAL(mimetype(KIO::Job *, const QString &)), \
this, SLOT(slotMimetype(KIO::Job *, const QString &))); + \
QObject::connect(kioJob, SIGNAL(result(KJob *)), this, SLOT(slotResult(KJob \
*))); + }
+
+ /*
if(job->method() == "POST") {
DeprecatedString postData = job->postData().flattenToString();
@@ -214,30 +156,19 @@
// TODO: Do it properly after we got rid of libcurl! (also leaks \
the headerlist. hmpf.)
curl_easy_setopt(d->m_handle, CURLOPT_POSTFIELDS, postDataString);
}
-
- if (m_useSimple)
- jobs->add(job);
- else {
- CURLMcode ret = curl_multi_add_handle(curlMultiHandle, \
d->m_handle);
- // don't call perform, because events must be async
- // timeout will occur and do curl_multi_perform
- if (ret && ret != CURLM_CALL_MULTI_PERFORM) {
- printf("Error %d starting job %s\n", ret, \
d->URL.url().ascii());
- job->setError(1);
- startTimer =false;
- } else
- jobs->add(job);
- }
- if (startTimer)
- m_downloadTimer.startOneShot(pollTimeSeconds);
+ */
}
-void TransferJobManager::cancel(TransferJob* job)
+void TransferJobManager::cancel(TransferJob *job)
{
+ qDebug("TransferJobManager::cancel(), job=%p", job);
+
remove(job);
job->setError(1);
}
} // namespace WebCore
+#include "TransferJobManager.moc"
+
// vim: ts=4 sw=4 et
--- branches/work/unity/WebKit/WebCore/platform/qt/TransferJobManager.h \
#576373:576374 @@ -1,6 +1,6 @@
/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
- * Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com
+ * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
+ *
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -22,48 +22,43 @@
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef TransferJobManager_H_
-#define TransferJobManager_H_
+#ifndef TransferJobManager_H
+#define TransferJobManager_H
+#include <QMap>
+#include <QObject>
+
#include "Frame.h"
#include "Timer.h"
-#include "TransferJobClient.h"
-#include <curl/curl.h>
+#include "TransferJob.h"
namespace WebCore {
-class TransferJobManager {
+class TransferJobManager : public QObject {
+Q_OBJECT
public:
- static TransferJobManager* get();
- void add(TransferJob*);
- void cancel(TransferJob*);
+ static TransferJobManager *self();
- // If true, don't multiplex downloads: download completely one at a \
time.
- void useSimpleTransfer(bool useSimple);
+ void add(TransferJob *job);
+ void cancel(TransferJob *job);
+public Q_SLOTS:
+ void slotData(KIO::Job *job, const QByteArray &data);
+ void slotMimetype(KIO::Job *job, const QString &type);
+ void slotResult(KJob *job);
+
private:
TransferJobManager();
- void downloadTimerCallback(Timer<TransferJobManager>*);
- void remove(TransferJob*);
+ ~TransferJobManager();
- bool m_useSimple;
- HashSet<TransferJob*>* jobs;
- Timer<TransferJobManager> m_downloadTimer;
- CURLM* curlMultiHandle; // not freed
+ void remove(TransferJob *job);
- // curl filehandles to poll with select
- fd_set fdread;
- fd_set fdwrite;
- fd_set fdexcep;
-
- int maxfd;
- char error_buffer[CURL_ERROR_SIZE];
-
- // NULL-terminated list of supported protocols
- const char* const* curl_protocols; // not freed
+ // KIO Job <-> WebKit Job mapping
+ QMap<TransferJob *, KIO::Job *> m_jobToKioMap;
+ QMap<KIO::Job *, TransferJob *> m_kioToJobMap;
};
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic