summaryrefslogtreecommitdiff
path: root/src/webpage.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/webpage.cpp')
-rw-r--r--src/webpage.cpp158
1 files changed, 79 insertions, 79 deletions
diff --git a/src/webpage.cpp b/src/webpage.cpp
index 3986fafb..a7baac6d 100644
--- a/src/webpage.cpp
+++ b/src/webpage.cpp
@@ -87,19 +87,19 @@
// Returns true if the scheme and domain of the two urls match...
static bool domainSchemeMatch(const QUrl& u1, const QUrl& u2)
{
- if(u1.scheme() != u2.scheme())
+ if (u1.scheme() != u2.scheme())
return false;
QStringList u1List = u1.host().split(QL1C('.'), QString::SkipEmptyParts);
QStringList u2List = u2.host().split(QL1C('.'), QString::SkipEmptyParts);
- if(qMin(u1List.count(), u2List.count()) < 2)
+ if (qMin(u1List.count(), u2List.count()) < 2)
return false; // better safe than sorry...
- while(u1List.count() > 2)
+ while (u1List.count() > 2)
u1List.removeFirst();
- while(u2List.count() > 2)
+ while (u2List.count() > 2)
u2List.removeFirst();
return (u1List == u2List);
@@ -115,31 +115,31 @@ static void extractSuggestedFileName(const QNetworkReply* reply, QString& fileNa
{
fileName.clear();
const KIO::MetaData& metaData = reply->attribute(static_cast<QNetworkRequest::Attribute>(KIO::AccessManager::MetaData)).toMap();
- if(metaData.value(QL1S("content-disposition-type")).compare(QL1S("attachment"), Qt::CaseInsensitive) == 0)
+ if (metaData.value(QL1S("content-disposition-type")).compare(QL1S("attachment"), Qt::CaseInsensitive) == 0)
fileName = metaData.value(QL1S("content-disposition-filename"));
- if(!fileName.isEmpty())
+ if (!fileName.isEmpty())
return;
- if(!reply->hasRawHeader("Content-Disposition"))
+ if (!reply->hasRawHeader("Content-Disposition"))
return;
const QString value(QL1S(reply->rawHeader("Content-Disposition").simplified().constData()));
- if(value.startsWith(QL1S("attachment"), Qt::CaseInsensitive) || value.startsWith(QL1S("inline"), Qt::CaseInsensitive))
+ if (value.startsWith(QL1S("attachment"), Qt::CaseInsensitive) || value.startsWith(QL1S("inline"), Qt::CaseInsensitive))
{
const int length = value.size();
int pos = value.indexOf(QL1S("filename"), 0, Qt::CaseInsensitive);
- if(pos > -1)
+ if (pos > -1)
{
pos += 9;
- while(pos < length && (value.at(pos) == QL1C(' ') || value.at(pos) == QL1C('=') || value.at(pos) == QL1C('"')))
+ while (pos < length && (value.at(pos) == QL1C(' ') || value.at(pos) == QL1C('=') || value.at(pos) == QL1C('"')))
pos++;
int endPos = pos;
- while(endPos < length && value.at(endPos) != QL1C('"') && value.at(endPos) != QL1C(';'))
+ while (endPos < length && value.at(endPos) != QL1C('"') && value.at(endPos) != QL1C(';'))
endPos++;
- if(endPos > pos)
+ if (endPos > pos)
fileName = value.mid(pos, (endPos - pos)).trimmed();
}
}
@@ -150,18 +150,18 @@ 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")))
+ if (metaData.contains(QL1S("content-type")))
mimeType = metaData.value(QL1S("content-type"));
- if(!mimeType.isEmpty())
+ if (!mimeType.isEmpty())
return;
- if(!reply->hasRawHeader("Content-Type"))
+ if (!reply->hasRawHeader("Content-Type"))
return;
const QString value(QL1S(reply->rawHeader("Content-Type").simplified().constData()));
const int index = value.indexOf(QL1C(';'));
- if(index == -1)
+ if (index == -1)
mimeType = value;
else
mimeType = value.left(index);
@@ -181,13 +181,13 @@ static bool downloadResource(const KUrl& srcUrl, const KIO::MetaData& metaData =
// follow bug:184202 fixes
destUrl = KFileDialog::getSaveFileName(KUrl(KGlobalSettings::downloadPath().append(fileName)), QString(), parent);
- if(destUrl.isEmpty())
+ if (destUrl.isEmpty())
return false;
- if(destUrl.isLocalFile())
+ if (destUrl.isLocalFile())
{
QFileInfo finfo(destUrl.toLocalFile());
- if(finfo.exists())
+ if (finfo.exists())
{
QDateTime now = QDateTime::currentDateTime();
QPointer<KIO::RenameDialog> dlg = new KIO::RenameDialog(parent,
@@ -207,24 +207,24 @@ static bool downloadResource(const KUrl& srcUrl, const KIO::MetaData& metaData =
}
}
}
- while(result == KIO::R_CANCEL && destUrl.isValid());
+ while (result == KIO::R_CANCEL && destUrl.isValid());
// Save download history
DownloadItem *item = rApp->downloadManager()->addDownload(srcUrl.pathOrUrl(), destUrl.pathOrUrl());
- if(!KStandardDirs::findExe("kget").isNull() && ReKonfig::kgetDownload())
+ if (!KStandardDirs::findExe("kget").isNull() && ReKonfig::kgetDownload())
{
//KGet integration:
- if(!QDBusConnection::sessionBus().interface()->isServiceRegistered("org.kde.kget"))
+ if (!QDBusConnection::sessionBus().interface()->isServiceRegistered("org.kde.kget"))
{
KToolInvocation::kdeinitExecWait("kget");
}
QDBusInterface kget("org.kde.kget", "/KGet", "org.kde.kget.main");
- if(!kget.isValid())
+ if (!kget.isValid())
return false;
QDBusMessage transfer = kget.call(QL1S("addTransfer"), srcUrl.prettyUrl(), destUrl.prettyUrl(), true);
- if(transfer.arguments().isEmpty())
+ if (transfer.arguments().isEmpty())
return true;
const QString transferPath = transfer.arguments().first().toString();
@@ -233,13 +233,13 @@ static bool downloadResource(const KUrl& srcUrl, const KIO::MetaData& metaData =
}
KIO::Job *job = KIO::file_copy(srcUrl, destUrl, -1, KIO::Overwrite);
- if(item)
+ if (item)
{
QObject::connect(job, SIGNAL(percent(KJob *, unsigned long)), item, SLOT(updateProgress(KJob *, unsigned long)));
QObject::connect(job, SIGNAL(finished(KJob *)), item, SLOT(onFinished(KJob*)));
}
- if(!metaData.isEmpty())
+ if (!metaData.isEmpty())
job->setMetaData(metaData);
job->addMetaData(QL1S("MaxCacheSize"), QL1S("0")); // Don't store in http cache.
@@ -268,7 +268,7 @@ WebPage::WebPage(QWidget *parent)
manager->setCache(0);
// set cookieJar window..
- if(parent && parent->window())
+ if (parent && parent->window())
manager->setWindow(parent->window());
// set network reply object to emit readyRead when it receives meta data
@@ -304,7 +304,7 @@ WebPage::~WebPage()
bool WebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, NavigationType type)
{
- if(_isOnRekonqPage)
+ if (_isOnRekonqPage)
{
WebView *view = qobject_cast<WebView *>(parent());
WebTab *tab = qobject_cast<WebTab *>(view->parent());
@@ -320,7 +320,7 @@ bool WebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &r
KIO::MetaData metaData = manager->requestMetaData();
// Get the SSL information sent, if any...
- if(metaData.contains(QL1S("ssl_in_use")))
+ if (metaData.contains(QL1S("ssl_in_use")))
{
WebSslInfo info;
info.restoreFrom(metaData.toVariant(), request.url());
@@ -328,17 +328,17 @@ bool WebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &r
_sslInfo = info;
}
- if(frame)
+ if (frame)
{
- if(_protHandler.preHandling(request, frame))
+ if (_protHandler.preHandling(request, frame))
{
return false;
}
- switch(type)
+ switch (type)
{
case QWebPage::NavigationTypeLinkClicked:
- if(_sslInfo.isValid())
+ if (_sslInfo.isValid())
{
setRequestMetaData("ssl_was_in_use", "TRUE");
}
@@ -348,10 +348,10 @@ bool WebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &r
break;
case QWebPage::NavigationTypeFormResubmitted:
- if(KMessageBox::warningContinueCancel(view(),
- i18n("Are you sure you want to send your data again?"),
- i18n("Resend form data")
- )
+ if (KMessageBox::warningContinueCancel(view(),
+ i18n("Are you sure you want to send your data again?"),
+ i18n("Resend form data")
+ )
== KMessageBox::Cancel)
{
return false;
@@ -374,11 +374,11 @@ bool WebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &r
WebPage *WebPage::createWindow(QWebPage::WebWindowType type)
{
// added to manage web modal dialogs
- if(type == QWebPage::WebModalDialog)
+ if (type == QWebPage::WebModalDialog)
kDebug() << "Modal Dialog";
WebTab *w = 0;
- if(ReKonfig::openTabNoWindow())
+ if (ReKonfig::openTabNoWindow())
{
w = rApp->mainWindow()->mainView()->newWebTab(!ReKonfig::openTabsBack());
}
@@ -394,16 +394,16 @@ void WebPage::handleUnsupportedContent(QNetworkReply *reply)
{
Q_ASSERT(reply);
- if(!reply)
+ if (!reply)
return;
// handle protocols WebKit cannot handle...
- if(_protHandler.postHandling(reply->request(), mainFrame()))
+ if (_protHandler.postHandling(reply->request(), mainFrame()))
{
return;
}
- if(reply->error() != QNetworkReply::NoError)
+ if (reply->error() != QNetworkReply::NoError)
return;
KIO::Integration::AccessManager::putReplyOnHold(reply);
@@ -415,7 +415,7 @@ void WebPage::handleUnsupportedContent(QNetworkReply *reply)
extractMimeType(reply, _mimeType);
// Convert executable text files to plain text...
- if(KParts::BrowserRun::isTextExecutable(_mimeType))
+ if (KParts::BrowserRun::isTextExecutable(_mimeType))
_mimeType = QL1S("text/plain");
kDebug() << "Detected MimeType = " << _mimeType;
@@ -427,7 +427,7 @@ void WebPage::handleUnsupportedContent(QNetworkReply *reply)
KUrl replyUrl = reply->url();
bool isLocal = replyUrl.isLocalFile();
- if(appService.isNull()) // no service can handle this. We can just download it..
+ if (appService.isNull()) // no service can handle this. We can just download it..
{
isLocal
? KMessageBox::sorry(view(), i18n("No service can handle this file."))
@@ -436,13 +436,13 @@ void WebPage::handleUnsupportedContent(QNetworkReply *reply)
return;
}
- if(!isLocal)
+ if (!isLocal)
{
KParts::BrowserOpenOrSaveQuestion dlg(rApp->mainWindow(), replyUrl, _mimeType);
- if(!_suggestedFileName.isEmpty())
+ if (!_suggestedFileName.isEmpty())
dlg.setSuggestedFileName(_suggestedFileName);
- switch(dlg.askEmbedOrSave())
+ switch (dlg.askEmbedOrSave())
{
case KParts::BrowserOpenOrSaveQuestion::Save:
downloadReply(reply, _suggestedFileName);
@@ -457,7 +457,7 @@ void WebPage::handleUnsupportedContent(QNetworkReply *reply)
}
// Handle Post operations that return content...
- if(reply->operation() == QNetworkAccessManager::PostOperation)
+ if (reply->operation() == QNetworkAccessManager::PostOperation)
{
kDebug() << "POST OPERATION: downloading file...";
QFileInfo finfo(_suggestedFileName.isEmpty() ? _loadingUrl.fileName() : _suggestedFileName);
@@ -475,7 +475,7 @@ void WebPage::handleUnsupportedContent(QNetworkReply *reply)
// case KParts::BrowserRun::Embed
KParts::ReadOnlyPart *pa = KMimeTypeTrader::createPartInstanceFromQuery<KParts::ReadOnlyPart>(_mimeType, view(), this, QString());
- if(pa)
+ if (pa)
{
_isOnRekonqPage = true;
@@ -526,9 +526,9 @@ void WebPage::loadFinished(bool ok)
// KWallet Integration
QStringList list = ReKonfig::walletBlackList();
- if(wallet()
+ if (wallet()
&& !list.contains(mainFrame()->url().toString())
- )
+ )
{
wallet()->fillFormData(mainFrame());
}
@@ -540,18 +540,18 @@ void WebPage::manageNetworkErrors(QNetworkReply *reply)
Q_ASSERT(reply);
// check suggested file name
- if(_suggestedFileName.isEmpty())
+ if (_suggestedFileName.isEmpty())
extractSuggestedFileName(reply, _suggestedFileName);
QWebFrame* frame = qobject_cast<QWebFrame *>(reply->request().originatingObject());
const bool isMainFrameRequest = (frame == mainFrame());
const bool isLoadingUrlReply = (mainFrame()->url() == reply->url());
- if(isMainFrameRequest
+ if (isMainFrameRequest
&& _sslInfo.isValid()
&& isLoadingUrlReply
&& !domainSchemeMatch(reply->url(), _sslInfo.url())
- )
+ )
{
// Reseting cached SSL info...
_sslInfo = WebSslInfo();
@@ -559,11 +559,11 @@ void WebPage::manageNetworkErrors(QNetworkReply *reply)
// NOTE: These are not all networkreply errors,
// but just that supported directly by KIO
- switch(reply->error())
+ switch (reply->error())
{
case QNetworkReply::NoError: // no error. Simple :)
- if(isMainFrameRequest && isLoadingUrlReply && !_sslInfo.isValid())
+ if (isMainFrameRequest && isLoadingUrlReply && !_sslInfo.isValid())
{
// Obtain and set the SSL information if any...
_sslInfo.restoreFrom(reply->attribute(static_cast<QNetworkRequest::Attribute>(KIO::AccessManager::MetaData)), reply->url());
@@ -594,10 +594,10 @@ void WebPage::manageNetworkErrors(QNetworkReply *reply)
case QNetworkReply::ProtocolInvalidOperationError: // requested operation is invalid for this protocol
kDebug() << "ERROR " << reply->error() << ": " << reply->errorString();
- if(reply->url() == _loadingUrl)
+ if (reply->url() == _loadingUrl)
{
frame->setHtml(errorPage(reply));
- if(isMainFrameRequest)
+ if (isMainFrameRequest)
{
_isOnRekonqPage = true;
@@ -626,7 +626,7 @@ QString WebPage::errorPage(QNetworkReply *reply)
QFile file(notfoundFilePath);
bool isOpened = file.open(QIODevice::ReadOnly);
- if(!isOpened)
+ if (!isOpened)
{
return QString("Couldn't open the rekonqinfo.html file");
}
@@ -641,21 +641,21 @@ QString WebPage::errorPage(QNetworkReply *reply)
iconPath.replace(QL1S("16"), QL1S("128"));
QString msg;
- msg += "<table>";
- msg += "<tr><td>";
- msg += "<img src=\"" + iconPath + "\" />";
- msg += "</td><td>";
- msg += "<h1>" + reply->errorString() + "</h1>";
- msg += "<h2>" + i18nc("%1=an URL, e.g.'kde.org'", "When connecting to: <b>%1</b>", urlString) + "</h2>";
- msg += "</td></tr></table>";
-
- msg += "<ul><li>" + i18n("Check the address for errors such as <b>ww</b>.kde.org instead of <b>www</b>.kde.org");
- msg += "</li><li>" + i18n("If the address is correct, try to check the network connection.") + "</li><li>" ;
+ msg += QL1S("<table>");
+ msg += QL1S("<tr><td>");
+ msg += QL1S("<img src=\"") + iconPath + QL1S("\" />");
+ msg += QL1S("</td><td>");
+ msg += QL1S("<h1>") + reply->errorString() + QL1S("</h1>");
+ msg += QL1S("<h2>") + i18nc("%1=an URL, e.g.'kde.org'", "When connecting to: <b>%1</b>", urlString) + QL1S("</h2>");
+ msg += QL1S("</td></tr></table>");
+
+ msg += QL1S("<ul><li>") + i18n("Check the address for errors such as <b>ww</b>.kde.org instead of <b>www</b>.kde.org");
+ msg += QL1S("</li><li>") + i18n("If the address is correct, try to check the network connection.") + QL1S("</li><li>") ;
msg += i18n("If your computer or network is protected by a firewall or proxy, make sure that rekonq is permitted to access the network.");
- msg += "</li><li>" + i18n("Of course, if rekonq does not work properly, you can always say it is a programmer error ;)");
- msg += "</li></ul><br/><br/>";
- msg += "<input type=\"button\" id=\"reloadButton\" onClick=\"document.location.href='" + urlString + "';\" value=\"";
- msg += i18n("Try Again") + "\" />";
+ msg += QL1S("</li><li>") + i18n("Of course, if rekonq does not work properly, you can always say it is a programmer error ;)");
+ msg += QL1S("</li></ul><br/><br/>");
+ msg += QL1S("<input type=\"button\" id=\"reloadButton\" onClick=\"document.location.href='") + urlString + QL1S("';\" value=\"");
+ msg += i18n("Try Again") + QL1S("\" />");
QString html = QString(QL1S(file.readAll()))
.arg(title)
@@ -705,12 +705,12 @@ void WebPage::downloadAllContentsWithKGet(QPoint)
contents << baseUrl.resolved(relativeUrl).toString();
}
- if(!QDBusConnection::sessionBus().interface()->isServiceRegistered("org.kde.kget"))
+ if (!QDBusConnection::sessionBus().interface()->isServiceRegistered("org.kde.kget"))
{
KToolInvocation::kdeinitExecWait("kget");
}
QDBusInterface kget("org.kde.kget", "/KGet", "org.kde.kget.main");
- if(kget.isValid())
+ if (kget.isValid())
{
kget.call("importLinks", QVariant(contents.toList()));
}
@@ -719,7 +719,7 @@ void WebPage::downloadAllContentsWithKGet(QPoint)
void WebPage::showSSLInfo(QPoint pos)
{
- if(mainFrame()->url().scheme() == QL1S("https"))
+ if (mainFrame()->url().scheme() == QL1S("https"))
{
SSLWidget *widget = new SSLWidget(mainFrame()->url(), _sslInfo, view());
widget->showAt(pos);
@@ -736,7 +736,7 @@ void WebPage::showSSLInfo(QPoint pos)
void WebPage::updateImage(bool ok)
{
- if(ok)
+ if (ok)
{
NewTabPage p(mainFrame());
p.snapFinished();
@@ -746,7 +746,7 @@ void WebPage::updateImage(bool ok)
void WebPage::copyToTempFileResult(KJob* job)
{
- if(job->error())
+ if (job->error())
job->uiDelegate()->showErrorMessage();
else
(void)KRun::runUrl(static_cast<KIO::FileCopyJob *>(job)->destUrl(), _mimeType, rApp->mainWindow());
@@ -760,7 +760,7 @@ bool WebPage::hasSslValid() const
if (certList.isEmpty())
return false;
- Q_FOREACH(const QSslCertificate &cert, certList)
+ Q_FOREACH(const QSslCertificate & cert, certList)
{
if (!cert.isValid())
return false;