summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2009-11-11 02:14:26 +0100
committerAndrea Diamantini <adjam7@gmail.com>2009-11-13 02:50:36 +0100
commit04a0850cb6f7750859a10ea3fe3c7a48e94728dc (patch)
tree9cba4c0b947e1b6b155f57ea2a80b56e547f080c /src
parentFinally remembered to fix urlbar (diff)
downloadrekonq-04a0850cb6f7750859a10ea3fe3c7a48e94728dc.tar.xz
Moving to kdewebkit.
First step
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt4
-rw-r--r--src/application.cpp21
-rw-r--r--src/application.h5
-rw-r--r--src/cookiejar.cpp110
-rw-r--r--src/cookiejar.h56
-rw-r--r--src/mainwindow.cpp10
-rw-r--r--src/networkaccessmanager.cpp64
-rw-r--r--src/networkaccessmanager.h47
-rw-r--r--src/settings.cpp1
-rw-r--r--src/webpage.cpp38
-rw-r--r--src/webpage.h14
-rw-r--r--src/webpluginfactory.cpp6
-rw-r--r--src/webpluginfactory.h6
-rw-r--r--src/webview.cpp16
-rw-r--r--src/webview.h7
15 files changed, 28 insertions, 377 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 9c0ace58..3fa889c5 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -9,13 +9,11 @@ SET( rekonq_KDEINIT_SRCS
newtabpage.cpp
previewimage.cpp
websnap.cpp
- networkaccessmanager.cpp
autosaver.cpp
application.cpp
mainwindow.cpp
mainview.cpp
tabbar.cpp
- cookiejar.cpp
history.cpp
historymodels.cpp
bookmarks.cpp
@@ -66,8 +64,8 @@ KDE4_ADD_KDEINIT_EXECUTABLE( rekonq ${rekonq_KDEINIT_SRCS} main.cpp )
TARGET_LINK_LIBRARIES ( kdeinit_rekonq
${QT_LIBRARIES}
- ${QT_QTNETWORK_LIBRARY}
${QT_QTWEBKIT_LIBRARY}
+ ${KDE4_KDEWEBKIT_LIBS}
${KDE4_KUTILS_LIBS}
${KDE4_KDEUI_LIBS}
${KDE4_KIO_LIBS}
diff --git a/src/application.cpp b/src/application.cpp
index 0dfc478f..9616688f 100644
--- a/src/application.cpp
+++ b/src/application.cpp
@@ -35,9 +35,7 @@
// Local Includes
#include "mainwindow.h"
-#include "cookiejar.h"
#include "history.h"
-#include "networkaccessmanager.h"
#include "mainview.h"
#include "webview.h"
#include "urlbar.h"
@@ -61,7 +59,6 @@
QPointer<HistoryManager> Application::s_historyManager;
-QPointer<NetworkAccessManager> Application::s_networkAccessManager;
QPointer<BookmarkProvider> Application::s_bookmarkProvider;
QPointer<SessionManager> Application::s_sessionManager;
@@ -77,7 +74,6 @@ Application::~Application()
{
qDeleteAll(m_mainWindows);
delete s_bookmarkProvider;
- delete s_networkAccessManager;
delete s_historyManager;
}
@@ -209,23 +205,6 @@ MainWindow *Application::mainWindow()
}
-CookieJar *Application::cookieJar()
-{
- return (CookieJar *)networkAccessManager()->cookieJar();
-}
-
-
-NetworkAccessManager *Application::networkAccessManager()
-{
- if (!s_networkAccessManager)
- {
- s_networkAccessManager = new NetworkAccessManager();
- s_networkAccessManager->setCookieJar(new CookieJar);
- }
- return s_networkAccessManager;
-}
-
-
HistoryManager *Application::historyManager()
{
if (!s_historyManager)
diff --git a/src/application.h b/src/application.h
index 0f256a45..786e5173 100644
--- a/src/application.h
+++ b/src/application.h
@@ -45,10 +45,8 @@
class KIcon;
class KUrl;
class BookmarkProvider;
-class CookieJar;
class HistoryManager;
class MainWindow;
-class NetworkAccessManager;
class SessionManager;
@@ -105,8 +103,6 @@ public:
static KIcon icon(const KUrl &url);
static HistoryManager *historyManager();
- static CookieJar *cookieJar();
- static NetworkAccessManager *networkAccessManager();
static BookmarkProvider *bookmarkProvider();
static SessionManager *sessionManager();
@@ -141,7 +137,6 @@ private:
KUrl guessUrlFromString(const QString &url);
static QPointer<HistoryManager> s_historyManager;
- static QPointer<NetworkAccessManager> s_networkAccessManager;
static QPointer<BookmarkProvider> s_bookmarkProvider;
static QPointer<SessionManager> s_sessionManager;
diff --git a/src/cookiejar.cpp b/src/cookiejar.cpp
deleted file mode 100644
index 05ffb987..00000000
--- a/src/cookiejar.cpp
+++ /dev/null
@@ -1,110 +0,0 @@
-/* ============================================================
-*
-* This file is a part of the rekonq project
-*
-* Copyright (C) 2009 by Andrea Diamantini <adjam7 at gmail dot com>
-* Copyright (C) 2009 by Lionel Chauvin <megabigbug@yahoo.fr>
-*
-*
-* This program is free software; you can redistribute it and/or
-* modify it under the terms of the GNU General Public License as
-* published by the Free Software Foundation; either version 2 of
-* the License or (at your option) version 3 or any later version
-* accepted by the membership of KDE e.V. (or its successor approved
-* by the membership of KDE e.V.), which shall act as a proxy
-* defined in Section 14 of version 3 of the license.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see <http://www.gnu.org/licenses/>.
-*
-* ============================================================ */
-
-
-// Self Includes
-#include "cookiejar.h"
-#include "cookiejar.moc"
-
-// Auto Includes
-#include "rekonq.h"
-
-// Local Includes
-#include "application.h"
-#include "mainwindow.h"
-
-// KDE Includes
-#include <KConfig>
-#include <KStandardDirs>
-#include <KDebug>
-
-// Qt Includes
-#include <QtCore/QDataStream>
-#include <QtCore/QDateTime>
-#include <QtCore/QString>
-
-#include <QtDBus/QDBusInterface>
-#include <QtDBus/QDBusReply>
-
-
-CookieJar::CookieJar(QObject* parent)
- : QNetworkCookieJar(parent)
- , m_windowId(-1)
-{
-}
-
-
-CookieJar::~CookieJar()
-{
-}
-
-
-QList<QNetworkCookie> CookieJar::cookiesForUrl(const QUrl & url) const
-{
-
- QDBusInterface kcookiejar("org.kde.kded", "/modules/kcookiejar", "org.kde.KCookieServer");
- QList<QNetworkCookie> cookieList;
- QDBusReply<QString> reply = kcookiejar.call("findDOMCookies", url.toString() );
-
- if (reply.isValid())
- {
- cookieList << reply.value().toUtf8();
- }
- else
- {
- kWarning() << "Unable to communicate with the cookiejar!";
- }
-
- return cookieList;
-}
-
-
-bool CookieJar::setCookiesFromUrl(const QList<QNetworkCookie> & cookieList, const QUrl & url)
-{
- QDBusInterface kcookiejar("org.kde.kded", "/modules/kcookiejar", "org.kde.KCookieServer");
- QByteArray cookieHeader;
- Q_FOREACH(const QNetworkCookie& cookie, cookieList)
- {
- cookieHeader = "Set-Cookie: ";
- cookieHeader += cookie.toRawForm();
- kcookiejar.call("addCookies", url.toString(), cookieHeader, m_windowId );
- }
-
- return !kcookiejar.lastError().isValid();
-}
-
-
-void CookieJar::clear()
-{
- QDBusInterface kcookiejar("org.kde.kded", "/modules/kcookiejar", "org.kde.KCookieServer");
-
- QDBusReply<void> reply = kcookiejar.call( "deleteAllCookies" );
- if (!reply.isValid())
- {
- kWarning() << "Unable to delete all the cookies as requested.";
- }
- return;
-}
diff --git a/src/cookiejar.h b/src/cookiejar.h
deleted file mode 100644
index 9ae24409..00000000
--- a/src/cookiejar.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/* ============================================================
-*
-* This file is a part of the rekonq project
-*
-* Copyright (C) 2009 by Andrea Diamantini <adjam7 at gmail dot com>
-* Copyright (C) 2009 by Lionel Chauvin <megabigbug@yahoo.fr>
-*
-*
-* This program is free software; you can redistribute it and/or
-* modify it under the terms of the GNU General Public License as
-* published by the Free Software Foundation; either version 2 of
-* the License or (at your option) version 3 or any later version
-* accepted by the membership of KDE e.V. (or its successor approved
-* by the membership of KDE e.V.), which shall act as a proxy
-* defined in Section 14 of version 3 of the license.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see <http://www.gnu.org/licenses/>.
-*
-* ============================================================ */
-
-
-#ifndef RECOOKIEJAR_H
-#define RECOOKIEJAR_H
-
-
-// Qt Includes
-#include <QtNetwork/QNetworkCookieJar>
-
-// Forward Declarations
-class QUrl;
-
-
-class CookieJar : public QNetworkCookieJar
-{
- Q_OBJECT
-
-public:
- CookieJar(QObject* parent = 0);
- virtual ~CookieJar();
-
- virtual QList<QNetworkCookie> cookiesForUrl(const QUrl & url) const;
- virtual bool setCookiesFromUrl(const QList<QNetworkCookie> & cookieList, const QUrl & url);
-
- void clear();
-
-private:
- qlonglong m_windowId;
-};
-
-#endif // RECOOKIEJAR_H
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 7a9e3ad6..43031446 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -37,8 +37,6 @@
#include "application.h"
#include "settings.h"
#include "history.h"
-#include "cookiejar.h"
-#include "networkaccessmanager.h"
#include "bookmarks.h"
#include "webview.h"
#include "mainview.h"
@@ -89,6 +87,9 @@
#include <QtGui/QPrintPreviewDialog>
#include <QtGui/QFontMetrics>
+#include <QtDBus/QDBusInterface>
+#include <QtDBus/QDBusReply>
+
#include <QtWebKit/QWebHistory>
@@ -1033,12 +1034,13 @@ void MainWindow::clearPrivateData()
if(clearWidget.clearCookies->isChecked())
{
- Application::cookieJar()->clear();
+ QDBusInterface kcookiejar("org.kde.kded", "/modules/kcookiejar", "org.kde.KCookieServer");
+ QDBusReply<void> reply = kcookiejar.call( "deleteAllCookies" );
}
if(clearWidget.clearCachedPages->isChecked())
{
- Application::networkAccessManager()->resetDiskCache();
+ // TODO implement me!
}
if(clearWidget.clearWebIcons->isChecked())
diff --git a/src/networkaccessmanager.cpp b/src/networkaccessmanager.cpp
deleted file mode 100644
index 38f4c8c4..00000000
--- a/src/networkaccessmanager.cpp
+++ /dev/null
@@ -1,64 +0,0 @@
-/* ============================================================
-*
-* This file is a part of the rekonq project
-*
-* Copyright (C) 2007-2008 Trolltech ASA. All rights reserved
-* Copyright (C) 2008-2009 by Andrea Diamantini <adjam7 at gmail dot com>*
-*
-* This program is free software; you can redistribute it and/or
-* modify it under the terms of the GNU General Public License as
-* published by the Free Software Foundation; either version 2 of
-* the License or (at your option) version 3 or any later version
-* accepted by the membership of KDE e.V. (or its successor approved
-* by the membership of KDE e.V.), which shall act as a proxy
-* defined in Section 14 of version 3 of the license.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see <http://www.gnu.org/licenses/>.
-*
-* ============================================================ */
-
-
-// Self Includes
-#include "networkaccessmanager.h"
-#include "networkaccessmanager.moc"
-
-// Local Includes
-#include "application.h"
-#include "mainwindow.h"
-
-// Auto Includes
-#include "rekonq.h"
-
-// KDE Includes
-#include <KStandardDirs>
-
-// Qt Includes
-#include <QtNetwork/QNetworkDiskCache>
-
-
-NetworkAccessManager::NetworkAccessManager(QObject *parent)
- : AccessManager(parent)
-{
- // resetting disk cache
- resetDiskCache();
-}
-
-
-void NetworkAccessManager::resetDiskCache()
-{
- if(!cache())
- {
- QNetworkDiskCache *diskCache = new QNetworkDiskCache(this);
- setCache(diskCache);
- }
- else
- {
- cache()->clear();
- }
-}
diff --git a/src/networkaccessmanager.h b/src/networkaccessmanager.h
deleted file mode 100644
index 6cade7fe..00000000
--- a/src/networkaccessmanager.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/* ============================================================
-*
-* This file is a part of the rekonq project
-*
-* Copyright (C) 2007-2008 Trolltech ASA. All rights reserved
-* Copyright (C) 2008-2009 by Andrea Diamantini <adjam7 at gmail dot com>*
-*
-* This program is free software; you can redistribute it and/or
-* modify it under the terms of the GNU General Public License as
-* published by the Free Software Foundation; either version 2 of
-* the License or (at your option) version 3 or any later version
-* accepted by the membership of KDE e.V. (or its successor approved
-* by the membership of KDE e.V.), which shall act as a proxy
-* defined in Section 14 of version 3 of the license.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see <http://www.gnu.org/licenses/>.
-*
-* ============================================================ */
-
-
-#ifndef NETWORKACCESSMANAGER_H
-#define NETWORKACCESSMANAGER_H
-
-
-// KDE Includes
-#include <kio/accessmanager.h>
-
-
-using namespace KIO;
-
-
-class NetworkAccessManager : public AccessManager
-{
- Q_OBJECT
-
-public:
- NetworkAccessManager(QObject *parent = 0);
- void resetDiskCache();
-};
-
-#endif // NETWORKACCESSMANAGER_H
diff --git a/src/settings.cpp b/src/settings.cpp
index 5696995c..110aaa08 100644
--- a/src/settings.cpp
+++ b/src/settings.cpp
@@ -36,7 +36,6 @@
// Local Includes
#include "application.h"
#include "mainwindow.h"
-#include "networkaccessmanager.h"
#include "webview.h"
//Ui Includes
diff --git a/src/webpage.cpp b/src/webpage.cpp
index 56865eb7..e75e898c 100644
--- a/src/webpage.cpp
+++ b/src/webpage.cpp
@@ -39,8 +39,6 @@
#include "application.h"
#include "mainwindow.h"
#include "mainview.h"
-#include "cookiejar.h"
-#include "networkaccessmanager.h"
#include "webview.h"
#include "webpluginfactory.h"
@@ -66,8 +64,8 @@
#include <QtGui/QKeyEvent>
-WebPage::WebPage(QObject *parent)
- : QWebPage(parent)
+WebPage::WebPage(QObject *parent, qlonglong windowId)
+ : KWebPage(parent, windowId)
, m_keyboardModifiers(Qt::NoModifier)
, m_pressedButtons(Qt::NoButton)
{
@@ -75,8 +73,7 @@ WebPage::WebPage(QObject *parent)
setForwardUnsupportedContent(true);
- setNetworkAccessManager(Application::networkAccessManager());
- connect(networkAccessManager(), SIGNAL(finished(QNetworkReply*)), this, SLOT(manageNetworkErrors(QNetworkReply*)));
+ connect(this, SIGNAL(finished(QNetworkReply*)), this, SLOT(manageNetworkErrors(QNetworkReply*)));
connect(this, SIGNAL(downloadRequested(const QNetworkRequest &)), this, SLOT(downloadRequested(const QNetworkRequest &)));
connect(this, SIGNAL(unsupportedContent(QNetworkReply *)), this, SLOT(handleUnsupportedContent(QNetworkReply *)));
@@ -122,7 +119,7 @@ bool WebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &r
m_requestedUrl = request.url();
- return QWebPage::acceptNavigationRequest(frame, request, type);
+ return KWebPage::acceptNavigationRequest(frame, request, type);
}
@@ -258,30 +255,3 @@ QString WebPage::errorPage(QNetworkReply *reply)
;
return html;
}
-
-
-// TODO FIXME: sometimes url.fileName() fails to retrieve url file name
-void WebPage::downloadRequested(const QNetworkRequest &request)
-{
- const KUrl url(request.url());
-
- const QString destUrl = KFileDialog::getSaveFileName(url.fileName(), QString(), view());
- if (destUrl.isEmpty()) return;
- KIO::Job *job = KIO::file_copy(url, KUrl(destUrl), -1, KIO::Overwrite);
- //job->setMetaData(metadata); //TODO: add metadata from request
- job->addMetaData( QLatin1String("MaxCacheSize"), QLatin1String("0") ); // Don't store in http cache.
- job->addMetaData( QLatin1String("cache"), QLatin1String("cache") ); // Use entry from cache if available.
- job->uiDelegate()->setAutoErrorHandlingEnabled(true);
-}
-
-
-QString WebPage::userAgentForUrl(const QUrl& _url) const
-{
- const KUrl url(_url);
- QString userAgent = KProtocolManager::userAgentForHost((url.isLocalFile() ? "localhost" : url.host()));
-
- if (userAgent == KProtocolManager::defaultUserAgent())
- return QWebPage::userAgentForUrl(_url);
-
- return userAgent;
-}
diff --git a/src/webpage.h b/src/webpage.h
index 45fc0c51..725788ee 100644
--- a/src/webpage.h
+++ b/src/webpage.h
@@ -32,22 +32,23 @@
#define WEBPAGE_H
+// KDE Includes
+#include <KWebPage>
+
// Qt Includes
-#include <QWebPage>
#include <QUrl>
// Forward Declarations
class QWebFrame;
class QNetworkReply;
-class QUrl;
-class WebPage : public QWebPage
+class WebPage : public KWebPage
{
Q_OBJECT
public:
- explicit WebPage(QObject *parent = 0);
+ explicit WebPage(QObject *parent = 0, qlonglong windowId = 0);
~WebPage();
public slots:
@@ -59,13 +60,10 @@ protected:
virtual bool acceptNavigationRequest(QWebFrame *frame,
const QNetworkRequest &request,
- NavigationType type);
-
- virtual QString userAgentForUrl(const QUrl& url) const;
+ NavigationType type);//
protected Q_SLOTS:
virtual void handleUnsupportedContent(QNetworkReply *reply);
- virtual void downloadRequested(const QNetworkRequest &request);
private:
friend class WebView;
diff --git a/src/webpluginfactory.cpp b/src/webpluginfactory.cpp
index 3daffbb6..bc79c60b 100644
--- a/src/webpluginfactory.cpp
+++ b/src/webpluginfactory.cpp
@@ -38,7 +38,7 @@
WebPluginFactory::WebPluginFactory(QObject *parent)
- : QWebPluginFactory(parent)
+ : KWebPluginFactory(parent)
{
}
@@ -78,13 +78,13 @@ QObject *WebPluginFactory::create(const QString &mimeType,
// this let QtWebKit using builtin plugins
// to load in example flash contents and so on..
kDebug() << "No plugins found for" << mimeType << ". Falling back to QtWebKit ones...";
- return 0;
+ return KWebPluginFactory::create(mimeType, url, argumentNames, argumentValues);
}
QList<QWebPluginFactory::Plugin> WebPluginFactory::plugins() const
{
- QList<QWebPluginFactory::Plugin> plugins;
+ QList<KWebPluginFactory::Plugin> plugins = KWebPluginFactory::plugins();
QWebPluginFactory::Plugin p;
p.name = "application/image-preview";
diff --git a/src/webpluginfactory.h b/src/webpluginfactory.h
index 738605db..30a366d4 100644
--- a/src/webpluginfactory.h
+++ b/src/webpluginfactory.h
@@ -28,13 +28,15 @@
#define WEB_PLUGIN_FACTORY_H
+// KDE Includes
+#include <KWebPluginFactory>
+
// Qt Includes
-#include <QtWebKit/QWebPluginFactory>
#include <QtCore/QList>
#include <QtGui/QWidget>
-class WebPluginFactory : public QWebPluginFactory
+class WebPluginFactory : public KWebPluginFactory
{
Q_OBJECT
diff --git a/src/webview.cpp b/src/webview.cpp
index 1dd5ad6a..4d3df502 100644
--- a/src/webview.cpp
+++ b/src/webview.cpp
@@ -53,7 +53,7 @@
WebView::WebView(QWidget* parent)
- : QWebView(parent)
+ : KWebView(parent, false)
, m_page(new WebPage(this))
, m_progress(0)
, m_mousePos(QPoint(0,0))
@@ -378,20 +378,6 @@ QPoint WebView::mousePos()
}
-void WebView::wheelEvent(QWheelEvent *event)
-{
- if (QApplication::keyboardModifiers() & Qt::ControlModifier)
- {
- int numDegrees = event->delta() / 8;
- int numSteps = numDegrees / 15;
- setTextSizeMultiplier(textSizeMultiplier() + numSteps * 0.1);
- event->accept();
- return;
- }
- QWebView::wheelEvent(event);
-}
-
-
void WebView::search()
{
KAction *a = qobject_cast<KAction*>(sender());
diff --git a/src/webview.h b/src/webview.h
index e860b8c8..a753736c 100644
--- a/src/webview.h
+++ b/src/webview.h
@@ -33,13 +33,13 @@
#include <KUrl>
// Qt Includes
-#include <QWebView>
+#include <KWebView>
// Forward Declarations
class WebPage;
-class WebView : public QWebView
+class WebView : public KWebView
{
Q_OBJECT
@@ -55,9 +55,8 @@ public:
protected:
void contextMenuEvent(QContextMenuEvent *event);
- void mousePressEvent(QMouseEvent *event);
+ void mousePressEvent(QMouseEvent *event);// need to be ported
void mouseMoveEvent(QMouseEvent *event);
- void wheelEvent(QWheelEvent *event);
void keyPressEvent(QKeyEvent *event);
private slots: