[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdepim/akonadi/resources
From: Kevin Ottens <ervin () kde ! org>
Date: 2009-05-27 14:15:40
Message-ID: 1243433740.910932.23797.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 973541 by ervin:
Finally got the QUOTA support to work.
M +1 -0 CMakeLists.txt
M +51 -0 imap/imapresource.cpp
M +1 -0 imap/imapresource.h
A shared/imapquotaattribute.cpp [License: LGPL (v2+)]
A shared/imapquotaattribute.h [License: LGPL (v2+)]
--- trunk/KDE/kdepim/akonadi/resources/CMakeLists.txt #973540:973541
@@ -20,6 +20,7 @@
set( AKONADI_IMAPATTRIBUTES_SHARED_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/shared/imapaclattribute.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/shared/imapquotaattribute.cpp
)
if ( XSLTPROC_EXECUTABLE )
--- trunk/KDE/kdepim/akonadi/resources/imap/imapresource.cpp #973540:973541
@@ -49,6 +49,7 @@
#include <kimap/fetchjob.h>
#include <kimap/getacljob.h>
#include <kimap/getmetadatajob.h>
+#include <kimap/getquotarootjob.h>
#include <kimap/listjob.h>
#include <kimap/loginjob.h>
#include <kimap/logoutjob.h>
@@ -79,6 +80,7 @@
#include "collectionflagsattribute.h"
#include "collectionannotationsattribute.h"
#include "imapaclattribute.h"
+#include "imapquotaattribute.h"
#include "imapaccount.h"
@@ -93,6 +95,7 @@
Akonadi::AttributeFactory::registerAttribute<CollectionFlagsAttribute>();
Akonadi::AttributeFactory::registerAttribute<CollectionAnnotationsAttribute>();
Akonadi::AttributeFactory::registerAttribute<ImapAclAttribute>();
+ Akonadi::AttributeFactory::registerAttribute<ImapQuotaAttribute>();
changeRecorder()->fetchCollection( true );
changeRecorder()->itemFetchScope().fetchFullPayload( true );
@@ -461,6 +464,14 @@
rights->start();
}
+ // Get the QUOTA info from the mailbox if it's supported
+ if ( capabilities.contains( "QUOTA" ) ) {
+ KIMAP::GetQuotaRootJob *quota = new KIMAP::GetQuotaRootJob( m_account->session() );
+ quota->setProperty( "akonadiCollection", QVariant::fromValue( col ) );
+ quota->setMailBox( mailBox );
+ connect( quota, SIGNAL( result( KJob* ) ), SLOT( onQuotasReceived( KJob* ) ) );
+ quota->start();
+ }
// Now is the right time to expunge the messages marked \\Deleted from this mailbox.
KIMAP::SelectJob *select = new KIMAP::SelectJob( m_account->session() );
@@ -705,6 +716,46 @@
}
}
+void ImapResource::onQuotasReceived( KJob *job )
+{
+ if ( job->error() ) {
+ return; // Well, no metadata for us then...
+ }
+
+ KIMAP::GetQuotaRootJob *quotaJob = qobject_cast<KIMAP::GetQuotaRootJob*>( job );
+ Collection collection = job->property( "akonadiCollection" ).value<Collection>();
+
+ QList<QByteArray> newRoots = quotaJob->roots();
+ QList< QMap<QByteArray, qint64> > newLimits;
+ QList< QMap<QByteArray, qint64> > newUsages;
+
+ foreach ( const QByteArray &root, newRoots ) {
+ newLimits << quotaJob->allLimits( root );
+ newUsages << quotaJob->allUsages( root );
+ }
+
+ // Store the mailbox Quotas
+ if ( !collection.hasAttribute( "imapquota" ) ) {
+ ImapQuotaAttribute *quotaAttribute = new ImapQuotaAttribute( newRoots, newLimits, newUsages );
+ collection.addAttribute( quotaAttribute );
+ } else {
+ ImapQuotaAttribute *quotaAttribute =
+ static_cast<ImapQuotaAttribute*>( collection.attribute( "imapquota" ) );
+ const QList<QByteArray> oldRoots = quotaAttribute->roots();
+ const QList< QMap<QByteArray, qint64> > oldLimits = quotaAttribute->limits();
+ const QList< QMap<QByteArray, qint64> > oldUsages = quotaAttribute->usages();
+
+ if ( oldRoots != newRoots
+ || oldLimits != newLimits
+ || oldUsages != newUsages ) {
+ quotaAttribute->setQuotas( newRoots, newLimits, newUsages );
+ }
+ }
+
+ CollectionModifyJob *modify = new CollectionModifyJob( collection );
+ modify->exec();
+}
+
void ImapResource::onGetMetaDataDone( KJob *job )
{
if ( job->error() ) {
--- trunk/KDE/kdepim/akonadi/resources/imap/imapresource.h #973540:973541
@@ -77,6 +77,7 @@
const QList< QList<QByteArray> > &flags );
void onGetAclDone( KJob *job );
void onRightsReceived( KJob *job );
+ void onQuotasReceived( KJob *job );
void onGetMetaDataDone( KJob *job );
void onSelectDone( KJob *job );
void onHeadersReceived( const QString &mailBox, const QMap<qint64, qint64> &uids,
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic