summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/browserapplication.cpp55
-rw-r--r--src/browserapplication.h14
-rw-r--r--src/mainwindow.cpp61
-rw-r--r--src/mainwindow.h1
-rw-r--r--src/webview.cpp9
5 files changed, 59 insertions, 81 deletions
diff --git a/src/browserapplication.cpp b/src/browserapplication.cpp
index bbd4b8b1..008917e1 100644
--- a/src/browserapplication.cpp
+++ b/src/browserapplication.cpp
@@ -22,9 +22,10 @@
// Local Includes
#include "browserapplication.h"
+#include "rekonq.h"
+
#include "mainwindow.h"
#include "cookiejar.h"
-#include "downloadmanager.h"
#include "history.h"
#include "networkaccessmanager.h"
#include "mainview.h"
@@ -34,6 +35,8 @@
#include <KCmdLineArgs>
#include <KAboutData>
#include <KConfig>
+#include <kio/job.h>
+#include <kio/jobclasses.h>
// Qt Includes
#include <QBuffer>
@@ -49,7 +52,6 @@
-DownloadManager *BrowserApplication::s_downloadManager = 0;
HistoryManager *BrowserApplication::s_historyManager = 0;
NetworkAccessManager *BrowserApplication::s_networkAccessManager = 0;
@@ -103,7 +105,6 @@ BrowserApplication::BrowserApplication(KCmdLineArgs *args, const QString &server
BrowserApplication::~BrowserApplication()
{
- delete s_downloadManager;
qDeleteAll(m_mainWindows);
delete s_networkAccessManager;
}
@@ -146,6 +147,41 @@ void BrowserApplication::postLaunch()
}
+void BrowserApplication::downloadUrl(const KUrl &url)
+{
+// QString path = ReKonfig::downloadDir() + QString("/") + url.fileName();
+// KIO::NetAccess::download( url , path , mainWindow() );
+ m_downloadUrl = url;
+ KIO::TransferJob * job = KIO::get( m_downloadUrl, KIO::NoReload);
+ connect(job, SIGNAL( result(KJob*) ), this, SLOT( slotResult(KJob*) ) );
+ connect(job, SIGNAL(data(KIO::Job*,const QByteArray &)), this, SLOT(slotData(KIO::Job*, const QByteArray&)));
+}
+
+
+void BrowserApplication::slotResult(KJob* job)
+{
+ if ( job->error() )
+ {
+ kDebug() << job->errorString();
+ }
+ else
+ {
+ QString path = ReKonfig::downloadDir() + QString("/") + m_downloadUrl.fileName();
+ QFile destFile( path );
+ destFile.write(m_downloadData);
+ destFile.close();
+ m_downloadData = 0;
+ }
+}
+
+
+void BrowserApplication::slotData(KIO::Job*, const QByteArray& data)
+{
+ m_downloadData.append(data);
+}
+
+
+
QList<MainWindow*> BrowserApplication::mainWindows()
{
clean();
@@ -243,7 +279,7 @@ bool BrowserApplication::isTheOnlyBrowser() const
void BrowserApplication::openUrl(const KUrl &url)
{
- mainWindow()->loadUrl( url );
+ mainWindow()->loadUrl(url);
}
@@ -293,17 +329,6 @@ CookieJar *BrowserApplication::cookieJar()
}
-DownloadManager *BrowserApplication::downloadManager()
-{
- if (!s_downloadManager)
- {
- s_downloadManager = new DownloadManager();
- }
- return s_downloadManager;
-}
-
-
-
NetworkAccessManager *BrowserApplication::networkAccessManager()
{
if (!s_networkAccessManager)
diff --git a/src/browserapplication.h b/src/browserapplication.h
index 4ec2cca6..7b8b98bc 100644
--- a/src/browserapplication.h
+++ b/src/browserapplication.h
@@ -27,6 +27,9 @@
#include <KCmdLineArgs>
#include <KIcon>
#include <KUrl>
+#include <KJob>
+#include <kio/job.h>
+#include <kio/jobclasses.h>
// Qt Includes
#include <QPointer>
@@ -37,7 +40,6 @@ QT_END_NAMESPACE
class MainWindow;
class CookieJar;
-class DownloadManager;
class HistoryManager;
class NetworkAccessManager;
@@ -49,19 +51,18 @@ public:
BrowserApplication(KCmdLineArgs*, const QString &);
~BrowserApplication();
static BrowserApplication *instance();
-// void loadSettings();
bool isTheOnlyBrowser() const;
MainWindow *mainWindow();
QList<MainWindow*> mainWindows();
KIcon icon(const KUrl &url) const;
+ void downloadUrl(const KUrl &url);
void saveSession();
bool canRestoreSession() const;
static HistoryManager *historyManager();
static CookieJar *cookieJar();
- static DownloadManager *downloadManager();
static NetworkAccessManager *networkAccessManager();
public slots:
@@ -72,18 +73,23 @@ private slots:
void postLaunch();
void openUrl(const KUrl &url);
void newLocalSocketConnection();
+ void slotResult(KJob*);
+ void slotData(KIO::Job*, const QByteArray&);
private:
void clean();
static HistoryManager *s_historyManager;
- static DownloadManager *s_downloadManager;
static NetworkAccessManager *s_networkAccessManager;
QList<QPointer<MainWindow> > m_mainWindows;
QLocalServer *m_localServer;
QByteArray m_lastSession;
mutable KIcon m_defaultIcon;
+
+ // about download
+ KUrl m_downloadUrl;
+ QByteArray m_downloadData;
};
#endif // BROWSERAPPLICATION_H
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 629899e4..482c351d 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -28,9 +28,10 @@
// Local Includes
#include "browserapplication.h"
-#include "downloadmanager.h"
#include "settings.h"
#include "history.h"
+#include "cookiejar.h"
+#include "networkaccessmanager.h"
#include "bookmarks.h"
#include "webview.h"
@@ -194,10 +195,6 @@ void MainWindow::setupActions()
actionCollection()->addAction( QLatin1String("page source"), a );
connect( a, SIGNAL( triggered(bool) ), this, SLOT( slotViewPageSource() ) );
- a = new KAction( KIcon( "kget" ), i18n("Downloads"), this );
- actionCollection()->addAction( QLatin1String("downloads"), a);
- connect( a, SIGNAL( triggered(bool) ), this, SLOT( slotDownloadManager() ) );
-
a = new KAction( KIcon("tools-report-bug"), i18n("Enable Web &Inspector"), this );
a->setCheckable(true);
actionCollection()->addAction( QLatin1String("web inspector"), a );
@@ -306,48 +303,10 @@ void MainWindow::slotUpdateConf()
defaultSettings->setAttribute(QWebSettings::PluginsEnabled, arePluginsEnabled);
defaultSettings->setAttribute(QWebSettings::JavascriptEnabled, isJavascriptEnabled);
-// int canAcceptCookies = ReKonfig::acceptCookies();
-// int canKeepCookiesUntil = ReKonfig::keepCookiesUntil();
-//
-// CookieJar::KeepPolicy keepCookies;
-// switch(canAcceptCookies)
-// {
-// default:
-// case 0:
-// keepCookies = CookieJar::KeepUntilExpire;
-// break;
-// case 1:
-// keepCookies = CookieJar::KeepUntilExit;
-// break;
-// case 2:
-// keepCookies = CookieJar::KeepUntilTimeLimit;
-// break;
-// }
-// CookieJar *jar = BrowserApplication::cookieJar();
-// QMetaEnum acceptPolicyEnum = jar->staticMetaObject.enumerator(jar->staticMetaObject.indexOfEnumerator("AcceptPolicy"));
-//
-// CookieJar::KeepPolicy keepPolicy;
-// switch(canKeepCookiesUntil)
-// {
-// default:
-// case 0:
-// keepPolicy = CookieJar::KeepUntilExpire;
-// break;
-// case 1:
-// keepPolicy = CookieJar::KeepUntilExit;
-// break;
-// case 2:
-// keepPolicy = CookieJar::KeepUntilTimeLimit;
-// break;
-// }
-//
-// QMetaEnum keepPolicyEnum = jar->staticMetaObject.enumerator(jar->staticMetaObject.indexOfEnumerator("KeepPolicy"));
-// // ---
-// BrowserApplication::instance()->loadSettings();
-// BrowserApplication::networkAccessManager()->loadSettings();
-// BrowserApplication::cookieJar()->loadSettings();
-// BrowserApplication::historyManager()->loadSettings();
-
+ // load Settings on main classes
+ BrowserApplication::networkAccessManager()->loadSettings();
+ BrowserApplication::cookieJar()->loadSettings();
+ BrowserApplication::historyManager()->loadSettings();
}
@@ -416,12 +375,6 @@ void MainWindow::loadUrl(const KUrl &url)
}
-void MainWindow::slotDownloadManager()
-{
- BrowserApplication::downloadManager()->show();
-}
-
-
void MainWindow::slotOpenLocation()
{
m_view->currentLineEdit()->selectAll();
@@ -431,7 +384,7 @@ void MainWindow::slotOpenLocation()
void MainWindow::slotFileSaveAs()
{
- BrowserApplication::downloadManager()->download(currentTab()->url(), true);
+ BrowserApplication::instance()->downloadUrl( currentTab()->url() );
}
diff --git a/src/mainwindow.h b/src/mainwindow.h
index 86a3e30d..8b8f1cbe 100644
--- a/src/mainwindow.h
+++ b/src/mainwindow.h
@@ -110,7 +110,6 @@ private slots:
// Tools Menu slots
void slotToggleInspector(bool enable);
- void slotDownloadManager();
// Settings Menu slots
void slotPreferences();
diff --git a/src/webview.cpp b/src/webview.cpp
index adfeab97..c7202fd8 100644
--- a/src/webview.cpp
+++ b/src/webview.cpp
@@ -30,13 +30,11 @@
#include "mainwindow.h"
#include "mainview.h"
#include "cookiejar.h"
-#include "downloadmanager.h"
#include "networkaccessmanager.h"
// KDE Includes
#include <KStandardDirs>
#include <KDebug>
-#include <kio/netaccess.h>
// Qt Includes
#include <QClipboard>
@@ -126,7 +124,7 @@ void WebPage::handleUnsupportedContent(QNetworkReply *reply)
{
if (reply->error() == QNetworkReply::NoError)
{
- BrowserApplication::downloadManager()->handleUnsupportedContent(reply);
+ BrowserApplication::instance()->downloadUrl( reply->url() );
return;
}
@@ -305,12 +303,9 @@ void WebView::setStatusBarText(const QString &string)
}
-// FIXME: use KIO transfer job instead!!
void WebView::downloadRequested(const QNetworkRequest &request)
{
- const KUrl url = KUrl( request.url() );
- QString path = ReKonfig::downloadDir() + QString("/") + url.fileName();
- KIO::NetAccess::download( url , path , this );
+ BrowserApplication::instance()->downloadUrl( request.url() );
}