[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    kdesupport/akonadi/server/src
From:       Volker Krause <vkrause () kde ! org>
Date:       2009-02-28 10:52:48
Message-ID: 1235818368.760169.1511.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 933199 by vkrause:

Retrieve all items from the source resource before we copy them.


 M  +8 -1      handler/colcopy.cpp  
 M  +21 -2     storage/itemretriever.cpp  
 M  +4 -1      storage/itemretriever.h  


--- trunk/kdesupport/akonadi/server/src/handler/colcopy.cpp #933198:933199
@@ -21,9 +21,10 @@
 
 #include "akonadiconnection.h"
 #include "handlerhelper.h"
-#include "../../libs/imapparser_p.h"
+#include "libs/imapparser_p.h"
 #include "storage/datastore.h"
 #include "storage/transaction.h"
+#include "storage/itemretriever.h"
 
 using namespace Akonadi;
 
@@ -43,6 +44,12 @@
   if ( !target.isValid() )
     return failureResponse( "No valid target specified" );
 
+  // retrieve all not yet cached items of the source
+  ItemRetriever retriever( connection() );
+  retriever.setCollection( source, true );
+  retriever.setRetrieveFullPayload( true );
+  retriever.exec();
+
   DataStore *store = connection()->storageBackend();
   Transaction transaction( store );
 
--- trunk/kdesupport/akonadi/server/src/storage/itemretriever.cpp #933198:933199
@@ -31,11 +31,12 @@
 
 ItemRetriever::ItemRetriever( AkonadiConnection *connection ) :
   mConnection( connection ),
-  mFullPayload( false )
+  mFullPayload( false ),
+  mRecursive( false )
 {
 }
 
-void ItemRetriever::setRetrievePart(const QStringList& parts)
+void ItemRetriever::setRetrieveParts(const QStringList& parts)
 {
   mParts = parts;
 }
@@ -71,6 +72,13 @@
     mParts += QLatin1String( "PLD:RFC822" );
 }
 
+void ItemRetriever::setCollection(const Collection& collection, bool recursive)
+{
+  mCollection = collection;
+  mItemSet = ImapSet();
+  mRecursive = recursive;
+}
+
 static const int itemQueryIdColumn = 0;
 static const int itemQueryRidColumn = 1;
 static const int itemQueryMimeTypeColumn = 2;
@@ -186,6 +194,17 @@
     }
     itemQuery.query().next();
   }
+
+  // retrieve items in child collections if requested
+  if ( mRecursive && mCollection.isValid() ) {
+    foreach ( const Collection &col, mCollection.children() ) {
+      ItemRetriever retriever( mConnection );
+      retriever.setCollection( col, mRecursive );
+      retriever.setRetrieveParts( mParts );
+      retriever.setRetrieveFullPayload( mFullPayload );
+      retriever.exec();
+    }
+  }
   qDebug() << "ItemRetriever::exec() done";
 }
 
--- trunk/kdesupport/akonadi/server/src/storage/itemretriever.h #933198:933199
@@ -43,11 +43,13 @@
   public:
     ItemRetriever( AkonadiConnection *connection );
 
-    void setRetrievePart( const QStringList &parts );
+    void setRetrieveParts( const QStringList &parts );
     void setRetrieveFullPayload( bool fullPayload );
     void setItemSet( const ImapSet &set, const Collection &collection = Collection() );
     void setItemSet( const ImapSet &set, bool isUid );
     void setItem( const Akonadi::Entity::Id &id );
+    /** Retrieve all items in the given collection. */
+    void setCollection( const Akonadi::Collection &collection, bool recursive = true );
 
     void exec();
 
@@ -61,6 +63,7 @@
     AkonadiConnection* mConnection;
     QStringList mParts;
     bool mFullPayload;
+    bool mRecursive;
 };
 
 }
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic