Page MenuHomePhorge

No OneTemporary

diff --git a/kdewebkit/kwebpage.cpp b/kdewebkit/kwebpage.cpp
index 2865ffcd75..52472191ac 100644
--- a/kdewebkit/kwebpage.cpp
+++ b/kdewebkit/kwebpage.cpp
@@ -1,550 +1,562 @@
/*
* This file is part of the KDE project.
*
* Copyright (C) 2008 Dirk Mueller <mueller@kde.org>
* Copyright (C) 2008 Urs Wolfer <uwolfer @ kde.org>
* Copyright (C) 2008 Michael Howell <mhowell123@gmail.com>
* Copyright (C) 2009,2010 Dawit Alemayehu <adawit@kde.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
*/
// Own
#include "kwebpage.h"
#include "kwebwallet.h"
// Local
#include "kwebpluginfactory.h"
// KDE
#include <kaction.h>
#include <kfiledialog.h>
#include <kprotocolmanager.h>
#include <kjobuidelegate.h>
#include <krun.h>
#include <kstandarddirs.h>
#include <kstandardshortcut.h>
#include <kurl.h>
#include <kdebug.h>
+#include <kshell.h>
#include <kmimetypetrader.h>
#include <klocalizedstring.h>
#include <ktemporaryfile.h>
#include <kio/accessmanager.h>
#include <kio/job.h>
#include <kio/copyjob.h>
#include <kio/jobuidelegate.h>
#include <kio/renamedialog.h>
#include <kparts/browseropenorsavequestion.h>
// Qt
#include <QtCore/QPointer>
#include <QtCore/QFileInfo>
#include <QtCore/QCoreApplication>
#include <QtWebKit/QWebFrame>
#include <QtNetwork/QNetworkReply>
#define QL1S(x) QLatin1String(x)
#define QL1C(x) QLatin1Char(x)
static void reloadRequestWithoutDisposition (QNetworkReply* reply)
{
QNetworkRequest req (reply->request());
req.setRawHeader("x-kdewebkit-ignore-disposition", "true");
QWebFrame* frame = qobject_cast<QWebFrame*> (req.originatingObject());
if (!frame)
return;
frame->load(req);
}
static bool isMimeTypeAssociatedWithSelf(const KService::Ptr &offer)
{
if (!offer)
return false;
kDebug(800) << offer->desktopEntryName();
const QString& appName = QCoreApplication::applicationName();
if (appName == offer->desktopEntryName() || offer->exec().trimmed().startsWith(appName))
return true;
// konqueror exception since it uses kfmclient to open html content...
if (appName == QL1S("konqueror") && offer->exec().trimmed().startsWith(QL1S("kfmclient")))
return true;
return false;
}
static void extractMimeType(const QNetworkReply* reply, QString& mimeType)
{
mimeType.clear();
const KIO::MetaData& metaData = reply->attribute(static_cast<QNetworkRequest::Attribute>(KIO::AccessManager::MetaData)).toMap();
if (metaData.contains(QL1S("content-type")))
mimeType = metaData.value(QL1S("content-type"));
if (!mimeType.isEmpty())
return;
if (!reply->hasRawHeader("Content-Type"))
return;
const QString value (QL1S(reply->rawHeader("Content-Type").simplified().constData()));
const int index = value.indexOf(QL1C(';'));
mimeType = ((index == -1) ? value : value.left(index));
}
static bool downloadResource (const KUrl& srcUrl, const QString& suggestedName = QString(),
QWidget* parent = 0, const KIO::MetaData& metaData = KIO::MetaData())
{
const QString fileName = suggestedName.isEmpty() ? srcUrl.fileName() : suggestedName;
// convert filename to URL using fromPath to avoid trouble with ':' in filenames (#184202)
KUrl destUrl = KFileDialog::getSaveFileName(KUrl::fromPath(fileName), QString(), parent);
if (!destUrl.isValid())
return false;
// Using KIO::copy rather than file_copy, to benefit from "dest already exists" dialogs.
KIO::Job *job = KIO::copy(srcUrl, destUrl);
if (!metaData.isEmpty())
job->setMetaData(metaData);
job->addMetaData(QL1S("MaxCacheSize"), QL1S("0")); // Don't store in http cache.
job->addMetaData(QL1S("cache"), QL1S("cache")); // Use entry from cache if available.
job->ui()->setWindow((parent ? parent->window() : 0));
job->ui()->setAutoErrorHandlingEnabled(true);
return true;
}
static bool isReplyStatusOk(const QNetworkReply* reply)
{
if (!reply || reply->error() != QNetworkReply::NoError)
return false;
// Check HTTP status code only for http and webdav protocols...
const QString scheme = reply->url().scheme();
if (scheme.startsWith(QLatin1String("http"), Qt::CaseInsensitive) ||
scheme.startsWith(QLatin1String("webdav"), Qt::CaseInsensitive)) {
bool ok = false;
const int statusCode = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(&ok);
if (!ok || statusCode < 200 || statusCode > 299)
return false;
}
return true;
}
class KWebPage::KWebPagePrivate
{
public:
KWebPagePrivate() : inPrivateBrowsingMode(false) {}
void _k_copyResultToTempFile(KJob * job)
{
if ( job->error() ) {
job->uiDelegate()->showErrorMessage();
return;
}
// Same as KRun::foundMimeType but with a different URL
(void)KRun::runUrl(static_cast<KIO::FileCopyJob *>(job)->destUrl(), mimeType, window);
}
QPointer<QWidget> window;
QString mimeType;
QPointer<KWebWallet> wallet;
bool inPrivateBrowsingMode;
};
static void setActionIcon(QAction* action, const QIcon& icon)
{
if (action) {
action->setIcon(icon);
}
}
static void setActionShortcut(QAction* action, const KShortcut& shortcut)
{
if (action) {
action->setShortcuts(shortcut.toList());
}
}
KWebPage::KWebPage(QObject *parent, Integration flags)
:QWebPage(parent), d(new KWebPagePrivate)
{
// KDE KParts integration for <embed> tag...
if (!flags || (flags & KPartsIntegration))
setPluginFactory(new KWebPluginFactory(this));
QWidget *parentWidget = qobject_cast<QWidget*>(parent);
QWidget *window = parentWidget ? parentWidget->window() : 0;
// KDE IO (KIO) integration...
if (!flags || (flags & KIOIntegration)) {
KIO::Integration::AccessManager *manager = new KIO::Integration::AccessManager(this);
// Disable QtWebKit's internal cache to avoid duplication with the one in KIO...
manager->setCache(0);
manager->setWindow(window);
manager->setEmitReadyReadOnMetaDataChange(true);
setNetworkAccessManager(manager);
}
// KWallet integration...
if (!flags || (flags & KWalletIntegration)) {
setWallet(new KWebWallet(0, (window ? window->winId() : 0) ));
}
setActionIcon(action(Back), KIcon("go-previous"));
setActionIcon(action(Forward), KIcon("go-next"));
setActionIcon(action(Reload), KIcon("view-refresh"));
setActionIcon(action(Stop), KIcon("process-stop"));
setActionIcon(action(Cut), KIcon("edit-cut"));
setActionIcon(action(Copy), KIcon("edit-copy"));
setActionIcon(action(Paste), KIcon("edit-paste"));
setActionIcon(action(Undo), KIcon("edit-undo"));
setActionIcon(action(Redo), KIcon("edit-redo"));
setActionIcon(action(InspectElement), KIcon("view-process-all"));
setActionIcon(action(OpenLinkInNewWindow), KIcon("window-new"));
setActionIcon(action(OpenFrameInNewWindow), KIcon("window-new"));
setActionIcon(action(OpenImageInNewWindow), KIcon("window-new"));
setActionIcon(action(CopyLinkToClipboard), KIcon("edit-copy"));
setActionIcon(action(CopyImageToClipboard), KIcon("edit-copy"));
setActionIcon(action(ToggleBold), KIcon("format-text-bold"));
setActionIcon(action(ToggleItalic), KIcon("format-text-italic"));
setActionIcon(action(ToggleUnderline), KIcon("format-text-underline"));
setActionIcon(action(DownloadLinkToDisk), KIcon("document-save"));
setActionIcon(action(DownloadImageToDisk), KIcon("document-save"));
settings()->setWebGraphic(QWebSettings::MissingPluginGraphic, KIcon("preferences-plugin").pixmap(32, 32));
settings()->setWebGraphic(QWebSettings::MissingImageGraphic, KIcon("image-missing").pixmap(32, 32));
settings()->setWebGraphic(QWebSettings::DefaultFrameIconGraphic, KIcon("applications-internet").pixmap(32, 32));
setActionShortcut(action(Back), KStandardShortcut::back());
setActionShortcut(action(Forward), KStandardShortcut::forward());
setActionShortcut(action(Reload), KStandardShortcut::reload());
setActionShortcut(action(Stop), KShortcut(QKeySequence(Qt::Key_Escape)));
setActionShortcut(action(Cut), KStandardShortcut::cut());
setActionShortcut(action(Copy), KStandardShortcut::copy());
setActionShortcut(action(Paste), KStandardShortcut::paste());
setActionShortcut(action(Undo), KStandardShortcut::undo());
setActionShortcut(action(Redo), KStandardShortcut::redo());
setActionShortcut(action(SelectAll), KStandardShortcut::selectAll());
}
KWebPage::~KWebPage()
{
delete d;
}
bool KWebPage::isExternalContentAllowed() const
{
KIO::AccessManager *manager = qobject_cast<KIO::AccessManager*>(networkAccessManager());
if (manager)
return manager->isExternalContentAllowed();
return true;
}
KWebWallet *KWebPage::wallet() const
{
return d->wallet;
}
void KWebPage::setAllowExternalContent(bool allow)
{
KIO::AccessManager *manager = qobject_cast<KIO::AccessManager*>(networkAccessManager());
if (manager)
manager->setExternalContentAllowed(allow);
}
void KWebPage::setWallet(KWebWallet* wallet)
{
// Delete the current wallet if this object is its parent...
if (d->wallet && this == d->wallet->parent())
delete d->wallet;
d->wallet = wallet;
if (d->wallet)
d->wallet->setParent(this);
}
void KWebPage::downloadRequest(const QNetworkRequest &request)
{
downloadResource(request.url(), QString(), view(),
request.attribute(static_cast<QNetworkRequest::Attribute>(KIO::AccessManager::MetaData)).toMap());
}
void KWebPage::downloadUrl(const KUrl &url)
{
downloadResource(url, QString(), view());
}
void KWebPage::downloadResponse(QNetworkReply *reply)
{
Q_ASSERT(reply);
if (!reply)
return;
// Put the job on hold only for the protocols we know about (read: http).
KIO::Integration::AccessManager::putReplyOnHold(reply);
QString mimeType;
KIO::MetaData metaData;
if (handleReply(reply, &mimeType, &metaData)) {
return;
}
const KUrl replyUrl (reply->url());
QWidget* topLevelWindow = view() ? view()->window() : 0;
// Ask KRun to handle the response when mimetype is unknown
if (mimeType.isEmpty()) {
(void)new KRun(replyUrl, topLevelWindow, 0 , replyUrl.isLocalFile());
return;
}
// Ask KRun::runUrl to handle the response when mimetype is inode/*
if (mimeType.startsWith(QL1S("inode/"), Qt::CaseInsensitive) &&
KRun::runUrl(replyUrl, mimeType, topLevelWindow, false, false,
metaData.value(QL1S("content-disposition-filename")))) {
return;
}
}
QString KWebPage::sessionMetaData(const QString &key) const
{
QString value;
KIO::Integration::AccessManager *manager = qobject_cast<KIO::Integration::AccessManager *>(networkAccessManager());
if (manager)
value = manager->sessionMetaData().value(key);
return value;
}
QString KWebPage::requestMetaData(const QString &key) const
{
QString value;
KIO::Integration::AccessManager *manager = qobject_cast<KIO::Integration::AccessManager *>(networkAccessManager());
if (manager)
value = manager->requestMetaData().value(key);
return value;
}
void KWebPage::setSessionMetaData(const QString &key, const QString &value)
{
KIO::Integration::AccessManager *manager = qobject_cast<KIO::Integration::AccessManager *>(networkAccessManager());
if (manager)
manager->sessionMetaData()[key] = value;
}
void KWebPage::setRequestMetaData(const QString &key, const QString &value)
{
KIO::Integration::AccessManager *manager = qobject_cast<KIO::Integration::AccessManager *>(networkAccessManager());
if (manager)
manager->requestMetaData()[key] = value;
}
void KWebPage::removeSessionMetaData(const QString &key)
{
KIO::Integration::AccessManager *manager = qobject_cast<KIO::Integration::AccessManager *>(networkAccessManager());
if (manager)
manager->sessionMetaData().remove(key);
}
void KWebPage::removeRequestMetaData(const QString &key)
{
KIO::Integration::AccessManager *manager = qobject_cast<KIO::Integration::AccessManager *>(networkAccessManager());
if (manager)
manager->requestMetaData().remove(key);
}
QString KWebPage::userAgentForUrl(const QUrl& _url) const
{
const KUrl url(_url);
const QString userAgent = KProtocolManager::userAgentForHost((url.isLocalFile() ? QL1S("localhost") : url.host()));
if (userAgent == KProtocolManager::defaultUserAgent())
return QWebPage::userAgentForUrl(_url);
return userAgent;
}
static void setDisableCookieJarStorage(QNetworkAccessManager* manager, bool status)
{
if (manager) {
KIO::Integration::CookieJar *cookieJar = manager ? qobject_cast<KIO::Integration::CookieJar*>(manager->cookieJar()) : 0;
if (cookieJar) {
//kDebug(800) << "Store cookies ?" << !status;
cookieJar->setDisableCookieStorage(status);
}
}
}
bool KWebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, NavigationType type)
{
kDebug(800) << "url:" << request.url() << ", type:" << type << ", frame:" << frame;
if (frame && d->wallet && type == QWebPage::NavigationTypeFormSubmitted)
d->wallet->saveFormData(frame);
// Make sure nothing is cached when private browsing mode is enabled...
if (settings()->testAttribute(QWebSettings::PrivateBrowsingEnabled)) {
if (!d->inPrivateBrowsingMode) {
setDisableCookieJarStorage(networkAccessManager(), true);
setSessionMetaData(QL1S("no-cache"), QL1S("true"));
d->inPrivateBrowsingMode = true;
}
} else {
if (d->inPrivateBrowsingMode) {
setDisableCookieJarStorage(networkAccessManager(), false);
removeSessionMetaData(QL1S("no-cache"));
d->inPrivateBrowsingMode = false;
}
}
/*
If the navigation request is from the main frame, set the cross-domain
meta-data value to the current url for proper integration with KCookieJar...
*/
if (frame == mainFrame() && type != QWebPage::NavigationTypeReload)
setSessionMetaData(QL1S("cross-domain"), request.url().toString());
return QWebPage::acceptNavigationRequest(frame, request, type);
}
bool KWebPage::handleReply(QNetworkReply* reply, QString* contentType, KIO::MetaData* metaData)
{
// Reply url...
const KUrl replyUrl (reply->url());
// Get the top level window...
QWidget* topLevelWindow = view() ? view()->window() : 0;
// Get suggested file name...
const KIO::MetaData& data = reply->attribute(static_cast<QNetworkRequest::Attribute>(KIO::AccessManager::MetaData)).toMap();
const QString suggestedFileName = data.value(QL1S("content-disposition-filename"));
if (metaData) {
*metaData = data;
}
// Get the mime-type...
QString mimeType;
extractMimeType(reply, mimeType);
if (contentType) {
*contentType = mimeType;
}
// Let the calling function deal with handling empty or inode/* mimetypes...
if (mimeType.isEmpty() || mimeType.startsWith(QL1S("inode/"), Qt::CaseInsensitive)) {
return false;
}
// Convert executable text files to plain text...
if (KParts::BrowserRun::isTextExecutable(mimeType))
mimeType = QL1S("text/plain");
//kDebug(800) << "Content-disposition:" << suggestedFileName;
//kDebug(800) << "Got unsupported content of type:" << mimeType << "URL:" << replyUrl;
//kDebug(800) << "Error code:" << reply->error() << reply->errorString();
if (isReplyStatusOk(reply)) {
KParts::BrowserOpenOrSaveQuestion::Result result;
KParts::BrowserOpenOrSaveQuestion dlg(topLevelWindow, replyUrl, mimeType);
dlg.setSuggestedFileName(suggestedFileName);
dlg.setFeatures(KParts::BrowserOpenOrSaveQuestion::ServiceSelection);
result = dlg.askOpenOrSave();
switch (result) {
case KParts::BrowserOpenOrSaveQuestion::Open:
// Handle Post operations that return content...
if (reply->operation() == QNetworkAccessManager::PostOperation) {
d->mimeType = mimeType;
d->window = topLevelWindow;
QFileInfo finfo (suggestedFileName.isEmpty() ? replyUrl.fileName() : suggestedFileName);
KTemporaryFile tempFile;
tempFile.setSuffix(QL1C('.') + finfo.suffix());
tempFile.setAutoRemove(false);
tempFile.open();
KUrl destUrl;
destUrl.setPath(tempFile.fileName());
KIO::Job *job = KIO::file_copy(replyUrl, destUrl, 0600, KIO::Overwrite);
job->ui()->setWindow(topLevelWindow);
job->ui()->setAutoErrorHandlingEnabled(true);
connect(job, SIGNAL(result(KJob *)),
this, SLOT(_k_copyResultToTempFile(KJob*)));
return true;
}
// Ask before running any executables...
if (KParts::BrowserRun::allowExecution(mimeType, replyUrl)) {
KService::Ptr offer = dlg.selectedService();
// HACK: The check below is necessary to break an infinite
// recursion that occurs whenever this function is called as a result
// of receiving content that can be rendered by the app using this engine.
// For example a text/html header that containing a content-disposition
// header is received by the app using this class.
if (isMimeTypeAssociatedWithSelf(offer)) {
reloadRequestWithoutDisposition(reply);
} else {
KUrl::List list;
list.append(replyUrl);
bool success = false;
// kDebug(800) << "Suggested file name:" << suggestedFileName;
if (offer) {
success = KRun::run(*offer, list, topLevelWindow , false, suggestedFileName);
} else {
success = KRun::displayOpenWithDialog(list, topLevelWindow, false, suggestedFileName);
}
// For non KIO apps and cancelled Open With dialog, remove slave on hold.
if (!success || (offer && !offer->categories().contains(QL1S("KDE")))) {
KIO::SimpleJob::removeOnHold(); // Remove any slave-on-hold...
}
}
return true;
}
// TODO: Instead of silently failing when allowExecution fails, notify
// the user why the requested action cannot be fulfilled...
break;
case KParts::BrowserOpenOrSaveQuestion::Save:
// Do not download local files...
if (!replyUrl.isLocalFile()) {
+ QString downloadCmd (reply->property(QLatin1String("DownloadManagerExe")).toString());
+ if (!downloadCmd.isEmpty()) {
+ downloadCmd += QLatin1Char(' ');
+ downloadCmd += KShell::quoteArg(replyUrl.url());
+ if (!suggestedFileName.isEmpty()) {
+ downloadCmd += QLatin1Char(' ');
+ downloadCmd += suggestedFileName;
+ }
+ if (KRun::runCommand(downloadCmd, view()))
+ return true;
+ }
return downloadResource(replyUrl, suggestedFileName, topLevelWindow);
}
return true;
case KParts::BrowserOpenOrSaveQuestion::Cancel:
default:
return true;
}
} else {
KService::Ptr offer = KMimeTypeTrader::self()->preferredService(mimeType);
if (isMimeTypeAssociatedWithSelf(offer)) {
reloadRequestWithoutDisposition(reply);
return true;
}
}
return false;
}
#include "kwebpage.moc"
diff --git a/kdewebkit/kwebpage.h b/kdewebkit/kwebpage.h
index 9d7a49e535..1964fbc12f 100644
--- a/kdewebkit/kwebpage.h
+++ b/kdewebkit/kwebpage.h
@@ -1,350 +1,367 @@
/*
* This file is part of the KDE project.
*
* Copyright (C) 2008 Dirk Mueller <mueller@kde.org>
* Copyright (C) 2008 Urs Wolfer <uwolfer @ kde.org>
* Copyright (C) 2008 Michael Howell <mhowell123@gmail.com>
* Copyright (C) 2009,2010 Dawit Alemayehu <adawit @ kde.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
*/
#ifndef KWEBPAGE_H
#define KWEBPAGE_H
#include <kdewebkit_export.h>
#include <QtWebKit/QWebPage>
class KWebWallet;
class KUrl;
class KJob;
namespace KIO {
class MetaData;
}
/**
* @short An enhanced QWebPage that provides integration into the KDE environment.
*
* This is a convenience class that provides full integration with KDE
* technologies such as KIO for network request handling, KCookiejar for cookie
* handling, KParts for embedding non-html content and KWallet for storing
* form data. It also sets standard icons for many of the actions provided by
* QWebPage.
*
* Most of this integration happens behind the scenes. If you want KWallet
* integration, however, you will have to provide a mechanism for deciding
* whether to allow form data to be stored. To do this, you will need to
* connect to the KWebWallet::saveFormDataRequested signal and call either
* KWebWallet::acceptSaveFormDataRequest or
* KWebWallet::rejectSaveFormDataRequest, typically after asking the user
* whether they want to save the form data. If you do not do this, no form
* data will be saved.
*
* KWebPage will also not automatically load form data for you. You should
* connect to QWebPage::loadFinished and, if the page was loaded successfully,
* call
* @code
* page->wallet()->fillFormData(page->mainFrame());
* @endcode
*
* @see KIO::Integration
* @see KWebWallet
*
* @author Urs Wolfer <uwolfer @ kde.org>
* @author Dawit Alemayehu <adawit @ kde.org>
*
* @since 4.4
*/
class KDEWEBKIT_EXPORT KWebPage : public QWebPage
{
Q_OBJECT
Q_FLAGS (Integration)
public:
/**
* Flags for setting the desired level of integration.
*/
enum IntegrationFlags
{
/**
* Provide only very basic integration such as using KDE icons for the
* actions provided by QWebPage.
*/
NoIntegration = 0x01,
/**
* Use KIO to handle network requests.
*
* @see KIO::Integration::AccessManager
*/
KIOIntegration = 0x02,
/**
* Use KPart componenets, if available, to display content in
* &lt;embed&gt; and &lt;object&gt; tags.
*/
KPartsIntegration = 0x04,
/**
* Use KWallet to store login credentials and other form data from web
* sites.
*
* @see wallet() and setWallet()
*/
KWalletIntegration = 0x08
};
Q_DECLARE_FLAGS(Integration, IntegrationFlags)
/**
* Constructs a KWebPage with parent @p parent.
*
* Note that if no integration flags are set (the default), all integration
* options are activated. If you inherit from this class you can use the
* flags in @ref IntegrationFlags to control how much integration should
* be used.
*
* @see KIO::Integration::CookieJar
* @see KIO::Integration::AccessManager
* @see wallet() and setWallet()
*/
explicit KWebPage(QObject *parent = 0, Integration flags = Integration());
/**
* Destroys the KWebPage.
*/
~KWebPage();
/**
* Whether access to remote content is permitted.
*
* If this is @c false, only resources on the local system can be accessed
* through this web page. By default access to remote content is allowed.
*
* If KIO integration is disabled, this will always return @c true.
*
* @see setAllowExternalContent()
* @see KIO::Integration::AccessManager::isExternalContentAllowed()
*
* @return @c true if access to remote content is permitted, @c false otherwise
*/
bool isExternalContentAllowed() const;
/**
* The wallet integration manager.
*
* If you wish to use KDE wallet integration, you will have to connect to
* signals emitted by this object and react accordingly. See KWebWallet
* for more information.
*
* @return the wallet integration manager, or 0 if KDE wallet integration
* is disabled
*/
KWebWallet *wallet() const;
/**
* Set whether to allow remote content.
*
* If KIO integration is not enabled, this method will have no effect.
*
* @see isExternalContentAllowed()
* @see KIO::Integration::AccessManager::setAllowExternalContent(bool)
*
* @param allow @c true if access to remote content should be allowed,
* @c false if only local content should be accessible
*/
void setAllowExternalContent(bool allow);
/**
* Set the @ref KWebWallet that is used to store form data.
*
* This KWebPage will take ownership of @p wallet, so that the wallet
* is deleted when the KWebPage is deleted. If you do not want that
* to happen, you should call setParent() on @p wallet after calling
* this function.
*
* @see KWebWallet
*
* @param wallet the KWebWallet to be used for storing form data, or
* 0 to disable KWallet integration
*/
void setWallet(KWebWallet* wallet);
public Q_SLOTS:
/**
* Download @p request using KIO.
*
* This slot first prompts the user where to save the requested
* resource and then downloads it using KIO.
*/
virtual void downloadRequest(const QNetworkRequest &request);
/**
* Download @p url using KIO.
*
* This slot first prompts the user where to save the requested
* resource and then downloads it using KIO.
*/
virtual void downloadUrl(const KUrl &url);
/**
* Download the resource specified by @p reply using KIO.
*
* This slot first prompts the user where to save the requested resource
* and then downloads it using KIO.
*
+ * In KDE 4.8 and higher, if @p reply contains a QObject property called
+ * "DownloadManagerExe", then an attempt will be made to the command
+ * specified by that property to download the specified resource.
+ *
+ * If the "DownloadManagerExe" property is not defined or the command
+ * specified by it could not be successfully executed, then the user will
+ * be prompted for the action to take.
+ *
* @since 4.5
+ * @see handleReply
*/
void downloadResponse(QNetworkReply *reply);
protected:
/**
* Get an item of session metadata.
*
* Retrieves the value of the permanent (per-session) metadata for @p key.
*
* If KIO integration is disabled, this will always return an empty string.
*
* @see KIO::Integration::AccessManager::sessionMetaData
* @see setSessionMetaData
*
* @param key the key of the metadata to retrieve
* @return the value of the metadata associated with @p key, or an
* empty string if there is no such metadata
*/
QString sessionMetaData(const QString &key) const;
/**
* Get an item of request metadata.
*
* Retrieves the value of the temporary (per-request) metadata for @p key.
*
* If KIO integration is disabled, this will always return an empty string.
*
* @see KIO::Integration::AccessManager::requestMetaData
* @see setRequestMetaData
*
* @param key the key of the metadata to retrieve
* @return the value of the metadata associated with @p key, or an
* empty string if there is no such metadata
*/
QString requestMetaData(const QString &key) const;
/**
* Set an item of metadata to be sent to the KIO slave with every request.
*
* If KIO integration is disabled, this method will have no effect.
*
* Metadata set using this method will be sent with every request.
*
* @see KIO::Integration::AccessManager::sessionMetaData
*
* @param key the key for the metadata; any existing metadata associated
* with this key will be overwritten
* @param value the value to associate with @p key
*/
void setSessionMetaData(const QString &key, const QString &value);
/**
* Set an item of metadata to be sent to the KIO slave with the next request.
*
* If KIO integration is disabled, this method will have no effect.
*
* Metadata set using this method will be deleted after it has been sent
* once.
*
* @see KIO::Integration::AccessManager::requestMetaData
*
* @param key the key for the metadata; any existing metadata associated
* with this key will be overwritten
* @param value the value to associate with @p key
*/
void setRequestMetaData(const QString &key, const QString &value);
/**
* Remove an item of session metadata.
*
* Removes the permanent (per-session) metadata associated with @p key.
*
* @see KIO::Integration::AccessManager::sessionMetaData
* @see setSessionMetaData
*
* @param key the key for the metadata to remove
*/
void removeSessionMetaData(const QString &key);
/**
* Remove an item of request metadata.
*
* Removes the temporary (per-request) metadata associated with @p key.
*
* @see KIO::Integration::AccessManager::requestMetaData
* @see setRequestMetaData
*
* @param key the key for the metadata to remove
*/
void removeRequestMetaData(const QString &key);
/**
* @reimp
*
* This function is re-implemented to provide KDE user-agent management
* integration through KProtocolManager.
*
* If a special user-agent has been configured for the host indicated by
* @p url, that user-agent will be returned. Otherwise, QWebPage's
* default user agent is returned.
*
* @see KProtocolManager::userAgentForHost.
* @see QWebPage::userAgentForUrl.
*/
virtual QString userAgentForUrl(const QUrl& url) const;
/**
* @reimp
*
* This performs various integration-related actions when navigation
* is requested. If you override this method, you should ensure you
* call KWebPage::acceptNaviationRequest (unless you want to block
* the request outright), even if you do not use the return value.
*
* If you do override acceptNavigationRequest and call this method,
* however, be aware of the effect of the page's
* linkDelegationPolicy on how * QWebPage::acceptNavigationRequest
* behaves.
*
* @see QWebPage::acceptNavigationRequest
*/
virtual bool acceptNavigationRequest(QWebFrame * frame, const QNetworkRequest & request, NavigationType type);
/**
- * Attempts to handle @ref reply and returns true on success, false otherwise.
+ * Attempts to handle @p reply and returns true on success, false otherwise.
+ *
+ * In KDE 4.8 and higher, if @p reply contains a QObject property called
+ * "DownloadManagerExe", then an attempt will be made to the command
+ * specified by that property to download the specified resource.
+ *
+ * If the "DownloadManagerExe" property is not defined or the command
+ * specified by it could not be successfully executed, then the user will
+ * be prompted for the action to take.
*
* @param reply the QNetworkReply object to be handled.
* @param contentType if not null, it will be set to the content-type specified in @p reply, if any.
* @param metaData if not null, it will be set to the KIO meta-data specified in @p reply, if any.
* @since 4.6.3
*/
bool handleReply (QNetworkReply* reply, QString* contentType = 0, KIO::MetaData* metaData = 0);
private:
class KWebPagePrivate;
KWebPagePrivate* const d;
Q_PRIVATE_SLOT(d, void _k_copyResultToTempFile(KJob *))
};
Q_DECLARE_OPERATORS_FOR_FLAGS(KWebPage::Integration)
#endif // KWEBPAGE_H

File Metadata

Mime Type
text/x-diff
Expires
Fri, Nov 1, 7:54 AM (1 d, 3 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
10074561
Default Alt Text
(34 KB)

Event Timeline