Commit 10f9541e authored by Grégory Oestreicher's avatar Grégory Oestreicher
Browse files

Limit the items types requested

BUG: 322404
FIXED-IN: 4.14.1
parent 91e78a95
......@@ -33,6 +33,11 @@ DavItemsListJob::DavItemsListJob( const DavUtils::DavUrl &url, QObject *parent )
{
}
void DavItemsListJob::setContentMimeTypes( const QStringList &types )
{
mMimeTypes = types;
}
void DavItemsListJob::start()
{
const DavProtocolBase *protocol = DavManager::self()->davProtocol( mUrl.protocol() );
......@@ -41,21 +46,24 @@ void DavItemsListJob::start()
int queryIndex = 0;
while ( it.hasNext() ) {
++mSubJobCount;
const QDomDocument props = it.next();
if ( protocol->useReport() ) {
KIO::DavJob *job = DavManager::self()->createReportJob( mUrl.url(), props );
job->addMetaData( QLatin1String("PropagateHttpHeader"), QLatin1String("true") );
job->setProperty( "davType", QLatin1String("report") );
job->setProperty( "itemsMimeType", protocol->mimeTypeForQuery( queryIndex ) );
connect( job, SIGNAL(result(KJob*)), this, SLOT(davJobFinished(KJob*)) );
} else {
KIO::DavJob *job = DavManager::self()->createPropFindJob( mUrl.url(), props );
job->addMetaData( QLatin1String("PropagateHttpHeader"), QLatin1String("true") );
job->setProperty( "davType", QLatin1String("propFind") );
job->setProperty( "itemsMimeType", protocol->mimeTypeForQuery( queryIndex ) );
connect( job, SIGNAL(result(KJob*)), this, SLOT(davJobFinished(KJob*)) );
const QString mimeType = protocol->mimeTypeForQuery( queryIndex );
if ( mMimeTypes.isEmpty() || mMimeTypes.contains( mimeType ) ) {
++mSubJobCount;
if ( protocol->useReport() ) {
KIO::DavJob *job = DavManager::self()->createReportJob( mUrl.url(), props );
job->addMetaData( QLatin1String("PropagateHttpHeader"), QLatin1String("true") );
job->setProperty( "davType", QLatin1String("report") );
job->setProperty( "itemsMimeType", mimeType );
connect( job, SIGNAL(result(KJob*)), this, SLOT(davJobFinished(KJob*)) );
} else {
KIO::DavJob *job = DavManager::self()->createPropFindJob( mUrl.url(), props );
job->addMetaData( QLatin1String("PropagateHttpHeader"), QLatin1String("true") );
job->setProperty( "davType", QLatin1String("propFind") );
job->setProperty( "itemsMimeType", mimeType );
connect( job, SIGNAL(result(KJob*)), this, SLOT(davJobFinished(KJob*)) );
}
}
++queryIndex;
......
......@@ -25,6 +25,7 @@
#include <kjob.h>
#include <QtCore/QSet>
#include <QtCore/QStringList>
/**
* @short A job that lists all DAV items inside a DAV collection.
......@@ -42,6 +43,15 @@ class DavItemsListJob : public KJob
*/
explicit DavItemsListJob( const DavUtils::DavUrl &url, QObject *parent = 0 );
/**
* Limits the mime types of the items requested.
*
* If no mime type is given then all will be requested.
*
* @param types The list of mime types to include
*/
void setContentMimeTypes( const QStringList &types );
/**
* Starts the job.
*/
......@@ -57,6 +67,7 @@ class DavItemsListJob : public KJob
private:
DavUtils::DavUrl mUrl;
QStringList mMimeTypes;
DavItem::List mItems;
QSet<QString> mSeenUrls; // to prevent events duplication with some servers
uint mSubJobCount;
......
......@@ -266,6 +266,7 @@ void DavGroupwareResource::retrieveItems( const Akonadi::Collection &collection
DavItemsListJob *job = new DavItemsListJob( davUrl );
job->setProperty( "collection", QVariant::fromValue( collection ) );
job->setContentMimeTypes( collection.contentMimeTypes() );
connect( job, SIGNAL(result(KJob*)), SLOT(onRetrieveItemsFinished(KJob*)) );
job->start();
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment