[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: branches/KDE/4.4/kdelibs/kio/kio
From: Dawit Alemayehu <adawit () kde ! org>
Date: 2010-01-25 22:35:15
Message-ID: 1264458915.622928.31387.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 1080241 by adawit:
* Moved the newly added function for preventing internal redirection handling
from KIO::TransfterJon to KIO::SimpleJob.
* Renamed these newly added setter/getter function to isRedirectionHandlingEnabled
and setRedirectionHandlingEnabled respectively based on feedback.
* Implemented the ability to disable internal redirection handling in KIO
classes that support redirection and inherit from KIO::SimpleJob.
M +1 -1 accessmanager.cpp
M +70 -53 job.cpp
M +3 -3 job_p.h
M +17 -17 jobclasses.h
--- branches/KDE/4.4/kdelibs/kio/kio/accessmanager.cpp #1080240:1080241
@@ -120,7 +120,7 @@
QNetworkReply *AccessManager::createRequest(Operation op, const QNetworkRequest \
&req, QIODevice *outgoingData) {
- KIO::TransferJob *kioJob = 0;
+ KIO::SimpleJob *kioJob = 0;
if ( !d->externalContentAllowed && req.url().scheme() != "file" && \
!req.url().scheme().isEmpty() ) {
kDebug( 7044 ) << "Blocked: " << req.url().scheme() << req.url();
--- branches/KDE/4.4/kdelibs/kio/kio/job.cpp #1080240:1080241
@@ -356,6 +356,17 @@
Scheduler::removeSlaveOnHold();
}
+bool SimpleJob::isRedirectionHandlingEnabled() const
+{
+ return d_func()->m_redirectionHandlingEnabled;
+}
+
+void SimpleJob::setRedirectionHandlingEnabled(bool handle)
+{
+ Q_D(SimpleJob);
+ d->m_redirectionHandlingEnabled = handle;
+}
+
SimpleJob::~SimpleJob()
{
Q_D(SimpleJob);
@@ -603,29 +614,35 @@
void MkdirJob::slotFinished()
{
Q_D(MkdirJob);
- if ( d->m_redirectionURL.isEmpty() || !d->m_redirectionURL.isValid())
+
+ if (!d->m_redirectionURL.isEmpty() && d->m_redirectionURL.isValid())
{
- // Return slave to the scheduler
- SimpleJob::slotFinished();
- } else {
//kDebug(7007) << "MkdirJob: Redirection to " << m_redirectionURL;
if (queryMetaData("permanent-redirect")=="true")
emit permanentRedirection(this, d->m_url, d->m_redirectionURL);
- KUrl dummyUrl;
- int permissions;
- QDataStream istream( d->m_packedArgs );
- istream >> dummyUrl >> permissions;
- d->m_url = d->m_redirectionURL;
- d->m_redirectionURL = KUrl();
- d->m_packedArgs.truncate(0);
- QDataStream stream( &d->m_packedArgs, QIODevice::WriteOnly );
- stream << d->m_url << permissions;
+ if ( d->m_redirectionHandlingEnabled )
+ {
+ KUrl dummyUrl;
+ int permissions;
+ QDataStream istream( d->m_packedArgs );
+ istream >> dummyUrl >> permissions;
- // Return slave to the scheduler
- d->slaveDone();
- Scheduler::doJob(this);
+ d->m_url = d->m_redirectionURL;
+ d->m_redirectionURL = KUrl();
+ d->m_packedArgs.truncate(0);
+ QDataStream stream( &d->m_packedArgs, QIODevice::WriteOnly );
+ stream << d->m_url << permissions;
+
+ // Return slave to the scheduler
+ d->slaveDone();
+ Scheduler::doJob(this);
+ return;
+ }
}
+
+ // Return slave to the scheduler
+ SimpleJob::slotFinished();
}
SimpleJob *KIO::mkdir( const KUrl& url, int permissions )
@@ -826,24 +843,30 @@
void StatJob::slotFinished()
{
Q_D(StatJob);
- if ( d->m_redirectionURL.isEmpty() || !d->m_redirectionURL.isValid())
+
+ if ( !d->m_redirectionURL.isEmpty() && d->m_redirectionURL.isValid() )
{
- // Return slave to the scheduler
- SimpleJob::slotFinished();
- } else {
//kDebug(7007) << "StatJob: Redirection to " << m_redirectionURL;
if (queryMetaData("permanent-redirect")=="true")
emit permanentRedirection(this, d->m_url, d->m_redirectionURL);
- d->m_url = d->m_redirectionURL;
- d->m_redirectionURL = KUrl();
- d->m_packedArgs.truncate(0);
- QDataStream stream( &d->m_packedArgs, QIODevice::WriteOnly );
- stream << d->m_url;
- // Return slave to the scheduler
- d->slaveDone();
- Scheduler::doJob(this);
+ if ( d->m_redirectionHandlingEnabled )
+ {
+ d->m_url = d->m_redirectionURL;
+ d->m_redirectionURL = KUrl();
+ d->m_packedArgs.truncate(0);
+ QDataStream stream( &d->m_packedArgs, QIODevice::WriteOnly );
+ stream << d->m_url;
+
+ // Return slave to the scheduler
+ d->slaveDone();
+ Scheduler::doJob(this);
+ return;
+ }
}
+
+ // Return slave to the scheduler
+ SimpleJob::slotFinished();
}
void StatJob::slotMetaData( const KIO::MetaData &_metaData)
@@ -977,7 +1000,7 @@
if (queryMetaData("permanent-redirect")=="true")
emit permanentRedirection(this, d->m_url, d->m_redirectionURL);
- if (d->m_handleRedirection) {
+ if ( d->m_redirectionHandlingEnabled ) {
// Honour the redirection
// We take the approach of "redirecting this same job"
// Another solution would be to create a subjob, but the same problem
@@ -1031,6 +1054,7 @@
}
}
+ // Return slave to the scheduler
SimpleJob::slotFinished();
}
@@ -1160,17 +1184,6 @@
return d_func()->m_errorPage;
}
-bool TransferJob::handleRedirection() const
-{
- return d_func()->m_handleRedirection;
-}
-
-void TransferJob::setHandleRedirection(bool handle)
-{
- Q_D(TransferJob);
- d->m_handleRedirection = handle;
-}
-
void TransferJobPrivate::start(Slave *slave)
{
Q_Q(TransferJob);
@@ -1636,7 +1649,7 @@
if (queryMetaData("permanent-redirect")=="true")
emit permanentRedirection(this, d->m_url, d->m_redirectionURL);
- if (d->m_handleRedirection) {
+ if ( d->m_redirectionHandlingEnabled ) {
d->staticData.truncate(0);
d->m_internalSuspended = false;
d->m_url = d->m_redirectionURL;
@@ -2468,24 +2481,28 @@
}
}
}
- if ( d->m_redirectionURL.isEmpty() || !d->m_redirectionURL.isValid() || error() \
) {
- // Return slave to the scheduler
- SimpleJob::slotFinished();
- } else {
+ if ( !d->m_redirectionURL.isEmpty() && d->m_redirectionURL.isValid() && !error() \
) {
//kDebug(7007) << "Redirection to " << d->m_redirectionURL;
if (queryMetaData("permanent-redirect")=="true")
emit permanentRedirection(this, d->m_url, d->m_redirectionURL);
- d->m_url = d->m_redirectionURL;
- d->m_redirectionURL = KUrl();
- d->m_packedArgs.truncate(0);
- QDataStream stream( &d->m_packedArgs, QIODevice::WriteOnly );
- stream << d->m_url;
- // Return slave to the scheduler
- d->slaveDone();
- Scheduler::doJob(this);
+ if ( d->m_redirectionHandlingEnabled ) {
+ d->m_url = d->m_redirectionURL;
+ d->m_redirectionURL = KUrl();
+ d->m_packedArgs.truncate(0);
+ QDataStream stream( &d->m_packedArgs, QIODevice::WriteOnly );
+ stream << d->m_url;
+
+ // Return slave to the scheduler
+ d->slaveDone();
+ Scheduler::doJob(this);
+ return;
+ }
}
+
+ // Return slave to the scheduler
+ SimpleJob::slotFinished();
}
void ListJob::slotMetaData( const KIO::MetaData &_metaData)
--- branches/KDE/4.4/kdelibs/kio/kio/job_p.h #1080240:1080241
@@ -84,7 +84,7 @@
*/
SimpleJobPrivate(const KUrl& url, int command, const QByteArray &packedArgs)
: m_slave(0), m_packedArgs(packedArgs), m_url(url), m_command(command),
- m_checkOnHold(false)
+ m_checkOnHold(false), m_redirectionHandlingEnabled(true)
{
if (m_url.hasSubUrl())
{
@@ -127,6 +127,7 @@
QString m_protocol;
QString m_proxy;
bool m_checkOnHold;
+ bool m_redirectionHandlingEnabled;
void simpleJobInit();
@@ -242,11 +243,10 @@
inline TransferJobPrivate(const KUrl& url, int command, const QByteArray \
&packedArgs, const QByteArray &_staticData)
: SimpleJobPrivate(url, command, packedArgs),
- m_handleRedirection(true), m_internalSuspended(false), \
m_errorPage(false), + m_internalSuspended(false), m_errorPage(false),
staticData(_staticData), m_isMimetypeEmitted(false), m_subJob(0)
{ }
- bool m_handleRedirection;
bool m_internalSuspended;
bool m_errorPage;
QByteArray staticData;
--- branches/KDE/4.4/kdelibs/kio/kio/jobclasses.h #1080240:1080241
@@ -361,6 +361,23 @@
*/
static void removeOnHold();
+ /**
+ * Returns true if redirections are handled internally, the default.
+ *
+ * @since 4.4
+ */
+ bool isRedirectionHandlingEnabled() const;
+
+ /**
+ * Set @p handle to false to prevent the internal handling of redirections.
+ *
+ * When this flag is set, redirection requests are simply forwarded to the
+ * caller instead of being handled internally.
+ *
+ * @since 4.4
+ */
+ void setRedirectionHandlingEnabled(bool handle);
+
public Q_SLOTS:
/**
* @internal
@@ -601,23 +618,6 @@
*/
void setTotalSize(KIO::filesize_t bytes);
- /**
- * Returns true when redirections are handled internally, the default.
- *
- * @since 4.4
- */
- bool handleRedirection() const;
-
- /**
- * Set @p handle to false to prevent the internal handling of redirections.
- *
- * When this flag is set, redirection requests are simply forwarded to the
- * caller instead of being handled internally.
- *
- * @since 4.4
- */
- void setHandleRedirection(bool handle);
-
protected:
/**
* Called when m_subJob finishes.
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic