diff -pubNr /opt/kde-stable/include/akonadi/agentbase.h /opt/kde-trunk/include/akonadi/agentbase.h
--- /opt/kde-stable/include/akonadi/agentbase.h	2009-10-12 18:32:20.000000000 +0200
+++ /opt/kde-trunk/include/akonadi/agentbase.h	2009-10-09 09:22:21.000000000 +0200
@@ -153,6 +153,8 @@ class AKONADI_EXPORT AgentBase : public 
      * @endcode
      *
      * @author Kevin Krammer <kevin.krammer@gmx.at>
+     *
+     * @deprecated Use Observer2 instead
      */
     class AKONADI_EXPORT Observer  // krazy:exclude=dpointer
     {
@@ -208,6 +210,67 @@ class AKONADI_EXPORT AgentBase : public 
     };
 
     /**
+     * BC extension of Observer with support for monitoring item and collection moves.
+     * Use this one instead of Observer.
+     *
+     * @since 4.4
+     */
+    class AKONADI_EXPORT Observer2 : public Observer  // krazy:exclude=dpointer
+    {
+        using Observer::collectionChanged;
+
+      public:
+        /**
+         * Reimplement to handle item moves.
+         * When using this class in combination with Akonadi::ResourceBase, inter-resource
+         * moves are handled internally already and the corresponding  add or delete method
+         * is called instead.
+         *
+         * @param item The moved item.
+         * @param collectionSource The collection the item has been moved from.
+         * @param collectionDestination The collection the item has been moved to.
+         */
+        virtual void itemMoved( const Akonadi::Item &item, const Akonadi::Collection &collectionSource,
+                                const Akonadi::Collection &collectionDestination );
+
+        /**
+         * Reimplement to handle item linking.
+         * This is only relevant for virtual resources.
+         * @param item The linked item.
+         * @param collection The collection the item is linked to.
+         */
+        virtual void itemLinked( const Akonadi::Item &item, const Akonadi::Collection &collection );
+
+        /**
+         * Reimplement to handle item unlinking.
+         * This is only relevant for virtual resources.
+         * @param item The unlinked item.
+         * @param collection The collection the item is unlinked to.
+         */
+        virtual void itemUnlinked( const Akonadi::Item &item, const Akonadi::Collection &collection );
+
+        /**
+         * Reimplement to handle collection moves.
+         * When using this class in combination with Akonadi::ResourceBase, inter-resource
+         * moves are handled internally already and the corresponding  add or delete method
+         * is called instead.
+         *
+         * @param collection The moved collection.
+         * @param source The previous parent collection.
+         * @param distination The new parent collection.
+         */
+        virtual void collectionMoved( const Akonadi::Collection &collection, const Akonadi::Collection &source,
+                                      const Akonadi::Collection &destination );
+
+        /**
+         * Reimplement to handle changes to existing collections.
+         * @param collection The changed collection.
+         * @param partIdentifiers The identifiers of the collection parts that has been changed.
+         */
+        virtual void collectionChanged( const Akonadi::Collection &collection, const QSet<QByteArray> &partIdentifiers );
+    };
+
+    /**
      * This enum describes the different states the
      * agent can be in.
      */
@@ -284,7 +347,11 @@ class AKONADI_EXPORT AgentBase : public 
      * This method is called whenever the agent shall show its configuration dialog
      * to the user. It will be automatically called when the agent is started for
      * the first time.
+     *
      * @param windowId The parent window id.
+     *
+     * @note If the method is reimplemented it has to emit the configurationDialogAccepted()
+     *       or configurationDialogRejected() signals depending on the users choice.
      */
     virtual void configure( WId windowId );
 
@@ -376,7 +443,17 @@ class AKONADI_EXPORT AgentBase : public 
     void error( const QString& message );
 
     /**
-     * Emitted if another application has changed the agents configuration remotely
+     * Emitted when another application has remotely asked the agent to abort
+     * its current operation.
+     * Connect to this signal if your agent supports abortion. After aborting
+     * and cleaning up, agents should return to Idle status.
+     *
+     * @since 4.4
+     */
+    void abortRequested();
+
+    /**
+     * Emitted if another application has changed the agent's configuration remotely
      * and called AgentInstance::reconfigure().
      *
      * @since 4.2
@@ -390,6 +467,26 @@ class AKONADI_EXPORT AgentBase : public 
      */
     void onlineChanged( bool b );
 
+    /**
+     * This signal is emitted whenever the user has accepted the configuration dialog.
+     *
+     * @note Implementors of agents/resources are responsible to emit this signal if
+     *       the agent/resource reimplements configure().
+     *
+     * @since 4.4
+     */
+    void configurationDialogAccepted();
+
+    /**
+     * This signal is emitted whenever the user has rejected the configuration dialog.
+     *
+     * @note Implementors of agents/resources are responsible to emit this signal if
+     *       the agent/resource reimplements configure().
+     *
+     * @since 4.4
+     */
+    void configurationDialogRejected();
+
   protected:
     /**
      * Creates an agent base.
@@ -464,6 +561,7 @@ class AKONADI_EXPORT AgentBase : public 
     static int init( AgentBase *r );
 
     // D-Bus interface stuff
+    void abort();
     void reconfigure();
     void quit();
 
diff -pubNr /opt/kde-stable/include/akonadi/agentinstancecreatejob.h /opt/kde-trunk/include/akonadi/agentinstancecreatejob.h
--- /opt/kde-stable/include/akonadi/agentinstancecreatejob.h	2009-10-12 18:32:20.000000000 +0200
+++ /opt/kde-trunk/include/akonadi/agentinstancecreatejob.h	2009-10-09 09:22:21.000000000 +0200
@@ -109,6 +109,8 @@ class AKONADI_EXPORT AgentInstanceCreate
     Q_PRIVATE_SLOT( d, void doConfigure() )
     Q_PRIVATE_SLOT( d, void timeout() )
     Q_PRIVATE_SLOT( d, void emitResult() )
+    Q_PRIVATE_SLOT( d, void configurationDialogAccepted() )
+    Q_PRIVATE_SLOT( d, void configurationDialogRejected() )
     //@endcond
 };
 
diff -pubNr /opt/kde-stable/include/akonadi/agentinstance.h /opt/kde-trunk/include/akonadi/agentinstance.h
--- /opt/kde-stable/include/akonadi/agentinstance.h	2009-10-12 18:32:20.000000000 +0200
+++ /opt/kde-trunk/include/akonadi/agentinstance.h	2009-10-13 13:35:33.000000000 +0200
@@ -170,6 +170,12 @@ class AKONADI_EXPORT AgentInstance
     bool operator==( const AgentInstance &other ) const;
 
     /**
+     * Tell the agent to abort its current operation.
+     * @since 4.4
+     */
+    void abort() const;
+
+    /**
      * Tell the agent that its configuration has been changed remotely via D-Bus
      */
     void reconfigure() const;
diff -pubNr /opt/kde-stable/include/akonadi/agentmanager.h /opt/kde-trunk/include/akonadi/agentmanager.h
--- /opt/kde-stable/include/akonadi/agentmanager.h	2009-10-12 18:32:20.000000000 +0200
+++ /opt/kde-trunk/include/akonadi/agentmanager.h	2009-10-09 09:22:21.000000000 +0200
@@ -80,7 +80,7 @@ class AKONADI_EXPORT AgentManager : publ
      * Returns the agent type with the given @p identifier or
      * an invalid agent type if the identifier does not exist.
      */
-    AgentType type( const QString &identififer ) const;
+    AgentType type( const QString &identifier ) const;
 
     /**
      * Returns the list of all available agent instances.
diff -pubNr /opt/kde-stable/include/akonadi/collectiondialog.h /opt/kde-trunk/include/akonadi/collectiondialog.h
--- /opt/kde-stable/include/akonadi/collectiondialog.h	2009-10-12 18:32:20.000000000 +0200
+++ /opt/kde-trunk/include/akonadi/collectiondialog.h	2009-10-09 09:22:21.000000000 +0200
@@ -33,8 +33,9 @@ namespace Akonadi {
 /**
  * @short A collection selection dialog.
  *
- * Provides a dialog that lists all collections that are available
- * on the Akonadi storage.
+ * Provides a dialog that lists collections that are available
+ * on the Akonadi storage and allows to select one or multiple
+ * collections.
  * The list of shown collections can be filtered by mime type.
  *
  * Example:
@@ -75,7 +76,10 @@ class AKONADI_EXPORT CollectionDialog : 
     ~CollectionDialog();
 
     /**
-     * Returns the selected collection.
+     * Returns the selected collection if the selection mode is
+     * QAbstractItemView::SingleSelection what is the default. If
+     * another selection mode was set then an invalid collection
+     * is returned.
      */
     Akonadi::Collection selectedCollection() const;
 
@@ -86,13 +90,11 @@ class AKONADI_EXPORT CollectionDialog : 
 
     /**
      * Sets the mime types any of which the selected collection(s) shall support.
-     * @see Akonadi::CollectionDialog::setMimeTypeFilter()
      */
     void setMimeTypeFilter( const QStringList &mimeTypes );
 
     /**
      * Returns the mime types any of which the selected collection(s) shall support.
-     * @see Akonadi::CollectionDialog::mimeTypeFilter()
      */
     QStringList mimeTypeFilter() const;
 
@@ -111,6 +113,8 @@ class AKONADI_EXPORT CollectionDialog : 
   private:
     class Private;
     Private * const d;
+
+    Q_PRIVATE_SLOT( d, void slotSelectionChanged() )
 };
 
 } // namespace Akonadi
diff -pubNr /opt/kde-stable/include/akonadi/collectionfetchjob.h /opt/kde-trunk/include/akonadi/collectionfetchjob.h
--- /opt/kde-stable/include/akonadi/collectionfetchjob.h	2009-10-12 18:32:20.000000000 +0200
+++ /opt/kde-trunk/include/akonadi/collectionfetchjob.h	2009-10-09 09:22:21.000000000 +0200
@@ -26,6 +26,7 @@
 
 namespace Akonadi {
 
+class CollectionFetchScope;
 class CollectionFetchJobPrivate;
 
 /**
@@ -38,14 +39,11 @@ class CollectionFetchJobPrivate;
  *
  * using namespace Akonadi;
  *
- * // fetching all collections recursive, starting at the root collection
- * CollectionFetchJob *job = new CollectionFetchJob( Collection::root(), CollectionFetchJob::Recursive );
- * if ( job->exec() ) {
- *   Collection::List collections = job->collections();
- *   foreach( const Collection &collection, collections ) {
- *     qDebug() << "Name:" << collection.name();
- *   }
- * }
+ * // fetching all collections containing emails recursively, starting at the root collection
+ * CollectionFetchJob *job = new CollectionFetchJob( Collection::root(), CollectionFetchJob::Recursive, this );
+ * job->fetchScope().setContentMimeTypes( QStringList() << "message/rfc822" );
+ * connect( job, SIGNAL(collectionsReceived(Akonadi::Collection::List), this, SLOT(myCollectionsReceived(Akonadi::Collection::List)) );
+ * connect( job, SIGNAL(result(KJob*)), this, SLOT(collectionFetchResult(KJob*)) );
  *
  * @endcode
  *
@@ -103,20 +101,51 @@ class AKONADI_EXPORT CollectionFetchJob 
      * Sets a resource identifier to limit collection listing to one resource.
      *
      * @param resource The resource identifier.
+     * @deprecated Use CollectionFetchScope instead.
      */
-    void setResource( const QString &resource );
+    KDE_DEPRECATED void setResource( const QString &resource );
 
     /**
      * Include also unsubscribed collections.
+     * @deprecated Use CollectionFetchScope instead.
      */
-    void includeUnsubscribed( bool include = true );
+    KDE_DEPRECATED void includeUnsubscribed( bool include = true );
 
     /**
      * Include also statistics about the collections.
      *
      * @since 4.3
+     * @deprecated Use CollectionFetchScope instead.
      */
-    void includeStatistics( bool include = true );
+    KDE_DEPRECATED void includeStatistics( bool include = true );
+
+    /**
+     * Sets the collection fetch scope.
+     *
+     * The CollectionFetchScope controls how much of a collection's data is fetched
+     * from the server as well as filter to select which collections to fetch.
+     *
+     * @param fetchScope The new scope for collection fetch operations.
+     *
+     * @see fetchScope()
+     * @since 4.4
+     */
+    void setFetchScope( const CollectionFetchScope &fetchScope );
+
+    /**
+     * Returns the collection fetch scope.
+     *
+     * Since this returns a reference it can be used to conveniently modify the
+     * current scope in-place, i.e. by calling a method on the returned reference
+     * without storing it in a local variable. See the CollectionFetchScope documentation
+     * for an example.
+     *
+     * @return a reference to the current collection fetch scope
+     *
+     * @see setFetchScope() for replacing the current collection fetch scope
+     * @since 4.4
+     */
+    CollectionFetchScope &fetchScope();
 
   Q_SIGNALS:
     /**
diff -pubNr /opt/kde-stable/include/akonadi/collectionfetchscope.h /opt/kde-trunk/include/akonadi/collectionfetchscope.h
--- /opt/kde-stable/include/akonadi/collectionfetchscope.h	1970-01-01 01:00:00.000000000 +0100
+++ /opt/kde-trunk/include/akonadi/collectionfetchscope.h	2009-10-09 09:22:21.000000000 +0200
@@ -0,0 +1,186 @@
+/*
+    Copyright (c) 2008 Kevin Krammer <kevin.krammer@gmx.at>
+    Copyright (c) 2009 Volker Krause <vkrause@kde.org>
+
+    This library is free software; you can redistribute it and/or modify it
+    under the terms of the GNU Library General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or (at your
+    option) any later version.
+
+    This library is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
+    License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to the
+    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+    02110-1301, USA.
+*/
+
+#ifndef AKONADI_COLLECTIONFETCHSCOPE_H
+#define AKONADI_COLLECTIONFETCHSCOPE_H
+
+#include "akonadi_export.h"
+
+#include <QtCore/QSharedDataPointer>
+
+class QStringList;
+
+namespace Akonadi {
+
+class CollectionFetchScopePrivate;
+
+/**
+ * @short Specifies which parts of a collection should be fetched from the Akonadi storage.
+ *
+ * When collections are fetched from server either by using CollectionFetchJob explicitly or
+ * when it is being used internally by other classes, e.g. Akonadi::Monitor, the scope
+ * of the fetch operation can be tailored to the application's current needs.
+ *
+ * There are two supported ways of changing the currently active CollectionFetchScope
+ * of classes:
+ * - in-place: modify the CollectionFetchScope object the other class holds as a member
+ * - replace: replace the other class' member with a new scope object
+ *
+ * Example: modifying an CollectionFetchJob's scope @c in-place
+ * @code
+ * Akonadi::CollectionFetchJob *job = new Akonadi::CollectionFetchJob( collection );
+ * job->fetchScope().setIncludeUnsubscribed( true );
+ * @endcode
+ *
+ * Example: @c replacing an CollectionFetchJob's scope
+ * @code
+ * Akonadi::CollectionFetchScope scope;
+ * scope.setIncludeUnsubscribed( true );
+ *
+ * Akonadi::CollectionFetchJob *job = new Akonadi::CollectionFetchJob( collection );
+ * job->setFetchScope( scope );
+ * @endcode
+ *
+ * This class is implicitly shared.
+ *
+ * @author Volker Krause <vkrause@kde.org>
+ * @since 4.4
+ */
+class AKONADI_EXPORT CollectionFetchScope
+{
+  public:
+    /**
+     * Describes the ancestor retrieval depth.
+     */
+    enum AncestorRetrieval {
+      None, ///< No ancestor retrieval at all (the default)
+      Parent, ///< Only retrieve the immediate parent collection
+      All ///< Retrieve all ancestors, up to Collection::root()
+    };
+
+    /**
+     * Creates an empty collection fetch scope.
+     *
+     * Using an empty scope will only fetch the very basic meta data of collections,
+     * e.g. local id, remote id and content mimetypes.
+     */
+    CollectionFetchScope();
+
+    /**
+     * Creates a new collection fetch scope from an @p other.
+     */
+    CollectionFetchScope( const CollectionFetchScope &other );
+
+    /**
+     * Destroys the collection fetch scope.
+     */
+    ~CollectionFetchScope();
+
+    /**
+     * Assigns the @p other to this scope and returns a reference to this scope.
+     */
+    CollectionFetchScope &operator=( const CollectionFetchScope &other );
+
+    /**
+     * Returns whether unsubscribed collection should be included.
+     *
+     * @see setIncludeUnsubscribed()
+     */
+    bool includeUnubscribed() const;
+
+    /**
+     * Sets whether unsubscribed collections should be included in the collection listing.
+     *
+     * @param include @c true to include unsubscribed collections, @c false otherwise (the default).
+     */
+    void setIncludeUnsubscribed( bool include );
+
+    /**
+     * Returns whether collection statistics should be included in the retrieved results.
+     *
+     * @see setIncludeStatistics()
+     */
+    bool includeStatistics() const;
+
+    /**
+     * Sets whether collection statistics should be included in the retrieved results.
+     *
+     * @param include @c true to include collction statistics, @c false otherwise (the default).
+     */
+    void setIncludeStatistics( bool include );
+
+    /**
+     * Returns the resource identifier that is used as filter.
+     *
+     * @see setResource()
+     */
+    QString resource() const;
+
+    /**
+     * Sets a resource filter, that is only collections owned by the specified resource are
+     * retrieved.
+     *
+     * @param resource The resource identifier.
+     */
+    void setResource( const QString &resource );
+
+    /**
+     * Sets a content mimetypes filter, that is only collections that contain at least one of the
+     * given mimetypes (or their parents) are retrieved.
+     *
+     * @param mimeTypes A list of mime types
+     */
+    void setContentMimeTypes( const QStringList &mimeTypes );
+
+    /**
+     * Returns the content mimetypes filter.
+     *
+     * @see setContentMimeTypes()
+     */
+    QStringList contentMimeTypes() const;
+
+    /**
+     * Sets how many levels of ancestor collections should be included in the retrieval.
+     *
+     * @param ancestorDepth The desired ancestor retrieval depth.
+     */
+    void setAncestorRetrieval( AncestorRetrieval ancestorDepth );
+
+    /**
+     * Returns the ancestor retrieval depth.
+     *
+     * @see setAncestorRetrieval()
+     */
+    AncestorRetrieval ancestorRetrieval() const;
+
+    /**
+     * Returns @c true if there is nothing to fetch.
+     */
+    bool isEmpty() const;
+
+  private:
+    //@cond PRIVATE
+    QSharedDataPointer<CollectionFetchScopePrivate> d;
+    //@endcond
+};
+
+}
+
+#endif
diff -pubNr /opt/kde-stable/include/akonadi/collection.h /opt/kde-trunk/include/akonadi/collection.h
--- /opt/kde-stable/include/akonadi/collection.h	2009-10-12 18:32:20.000000000 +0200
+++ /opt/kde-trunk/include/akonadi/collection.h	2009-10-09 09:22:21.000000000 +0200
@@ -81,8 +81,10 @@ class AKONADI_EXPORT Collection : public
       CanChangeCollection = 0x8,        ///< Can change subcollections in this collection
       CanCreateCollection = 0x10,       ///< Can create new subcollections in this collection
       CanDeleteCollection = 0x20,       ///< Can delete subcollections in this collection
+      CanLinkItem = 0x40,               ///< Can create links to existing items in this virtual collection
+      CanUnlinkItem = 0x80,             ///< Can remove links to items in this virtual collection
       AllRights = (CanChangeItem | CanCreateItem | CanDeleteItem |
-                   CanChangeCollection | CanCreateCollection | CanDeleteCollection) ///< Has all rights on this collection
+                   CanChangeCollection | CanCreateCollection | CanDeleteCollection) ///< Has all rights on this storage collection
     };
     Q_DECLARE_FLAGS(Rights, Right)
 
@@ -149,29 +151,34 @@ class AKONADI_EXPORT Collection : public
 
     /**
      * Returns the identifier of the parent collection.
+     * @deprecated Use parentCollection()
      */
-    Id parent() const;
+    KDE_DEPRECATED Id parent() const;
 
     /**
      * Sets the identifier of the @p parent collection.
+     * @deprecated Use setParentCollection()
      */
-    void setParent( Id parent );
+    KDE_DEPRECATED void setParent( Id parent );
 
     /**
      * Sets the parent @p collection.
+     * @deprecated Use setParentCollection()
      */
-    void setParent( const Collection &collection );
+    KDE_DEPRECATED void setParent( const Collection &collection );
 
     /**
      * Returns the parent remote identifier.
      * @note This usually returns nothing for collections retrieved from the backend.
+     * @deprecated Use parentCollection()
      */
-    QString parentRemoteId() const;
+    KDE_DEPRECATED QString parentRemoteId() const;
 
     /**
      * Sets the parent's remote @p identifier.
+     * @deprecated Use setParentCollection()
      */
-    void setParentRemoteId( const QString &identifier );
+    KDE_DEPRECATED void setParentRemoteId( const QString &identifier );
 
     /**
      * Returns the root collection.
@@ -234,5 +241,6 @@ AKONADI_EXPORT QDebug operator<<( QDebug
 
 Q_DECLARE_METATYPE(Akonadi::Collection)
 Q_DECLARE_METATYPE(Akonadi::Collection::List)
+Q_DECLARE_OPERATORS_FOR_FLAGS( Akonadi::Collection::Rights )
 
 #endif
diff -pubNr /opt/kde-stable/include/akonadi/collectionmodifyjob.h /opt/kde-trunk/include/akonadi/collectionmodifyjob.h
--- /opt/kde-stable/include/akonadi/collectionmodifyjob.h	2009-10-12 18:32:20.000000000 +0200
+++ /opt/kde-trunk/include/akonadi/collectionmodifyjob.h	2009-10-09 09:22:21.000000000 +0200
@@ -68,6 +68,12 @@ class AKONADI_EXPORT CollectionModifyJob
      */
     ~CollectionModifyJob();
 
+    /**
+      Returns the modified collection.
+      @since 4.4
+     */
+    Collection collection() const;
+
   protected:
     virtual void doStart();
 
diff -pubNr /opt/kde-stable/include/akonadi/collectionmovejob.h /opt/kde-trunk/include/akonadi/collectionmovejob.h
--- /opt/kde-stable/include/akonadi/collectionmovejob.h	1970-01-01 01:00:00.000000000 +0100
+++ /opt/kde-trunk/include/akonadi/collectionmovejob.h	2009-10-09 09:22:21.000000000 +0200
@@ -0,0 +1,74 @@
+/*
+    Copyright (c) 2009 Volker Krause <vkrause@kde.org>
+
+    This library is free software; you can redistribute it and/or modify it
+    under the terms of the GNU Library General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or (at your
+    option) any later version.
+
+    This library is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
+    License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to the
+    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+    02110-1301, USA.
+*/
+
+#ifndef AKONADI_COLLECTIONMOVEJOB_H
+#define AKONADI_COLLECTIONMOVEJOB_H
+
+#include "akonadi_export.h"
+
+#include <akonadi/job.h>
+
+namespace Akonadi {
+
+class Collection;
+class CollectionMoveJobPrivate;
+
+/**
+ * @short Job that moves a collection in the Akonadi storage to a new parent collection.
+ *
+ * This job moves an existing collection to a new parent collection.
+ *
+ * @code
+ *
+ * const Akonadi::Collection collection = ...
+ * const Akonadi::Collection newParent = ...
+ *
+ * Akonadi::CollectionMoveJob *job = new Akonadi::CollectionMoveJob( collection, newParent );
+ * connect( job, SIGNAL( result( KJob* ) ), this, SLOT( moveResult( KJob* ) ) );
+ *
+ * @endcode
+ *
+ * @since 4.4
+ * @author Volker Krause <vkrause@kde.org>
+ */
+class AKONADI_EXPORT CollectionMoveJob : public Job
+{
+  Q_OBJECT
+
+  public:
+    /**
+     * Creates a new collection move job for the given collection and destination
+     *
+     * @param collection The collection to move.
+     * @param destination The destination collection where @p collection should be moved to.
+     * @param parent The parent object.
+     */
+    CollectionMoveJob( const Collection &collection, const Collection &destination, QObject *parent = 0 );
+
+  protected:
+    virtual void doStart();
+
+  private:
+    Q_DECLARE_PRIVATE( CollectionMoveJob )
+    template <typename T, typename MoveJob> friend class MoveJobImpl;
+};
+
+}
+
+#endif
diff -pubNr /opt/kde-stable/include/akonadi/collectionrequester.h /opt/kde-trunk/include/akonadi/collectionrequester.h
--- /opt/kde-stable/include/akonadi/collectionrequester.h	2009-10-12 18:32:20.000000000 +0200
+++ /opt/kde-trunk/include/akonadi/collectionrequester.h	2009-10-09 09:22:21.000000000 +0200
@@ -89,13 +89,11 @@ class AKONADI_EXPORT CollectionRequester
 
     /**
      * Sets the mime types any of which the selected collection shall support.
-     * @see Akonadi::CollectionDialog::setMimeTypeFilter()
      */
     void setMimeTypeFilter( const QStringList &mimeTypes );
 
     /**
     * Returns the mime types any of which the selected collection shall support.
-    * @see Akonadi::CollectionDialog::mimeTypeFilter()
     */
     QStringList mimeTypeFilter() const;
 
diff -pubNr /opt/kde-stable/include/akonadi/contact/addressbookcombobox.h /opt/kde-trunk/include/akonadi/contact/addressbookcombobox.h
--- /opt/kde-stable/include/akonadi/contact/addressbookcombobox.h	1970-01-01 01:00:00.000000000 +0100
+++ /opt/kde-trunk/include/akonadi/contact/addressbookcombobox.h	2009-09-09 14:11:25.000000000 +0200
@@ -0,0 +1,131 @@
+/*
+    This file is part of Akonadi Contact.
+
+    Copyright (c) 2007-2009 Tobias Koenig <tokoe@kde.org>
+
+    This library is free software; you can redistribute it and/or modify it
+    under the terms of the GNU Library General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or (at your
+    option) any later version.
+
+    This library is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
+    License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to the
+    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+    02110-1301, USA.
+*/
+
+#ifndef AKONADI_ADDRESSBOOKCOMBOBOX_H
+#define AKONADI_ADDRESSBOOKCOMBOBOX_H
+
+#include "akonadi-contact_export.h"
+
+#include <QtGui/QWidget>
+
+#include <akonadi/collection.h>
+
+class QAbstractItemModel;
+
+namespace Akonadi {
+
+/**
+ * @short A combobox for selecting an Akonadi address book.
+ *
+ * This widget provides a combobox to select an address book
+ * collection from the Akonadi storage.
+ * The available address books can be filtered to show only
+ * address books that can contain contacts, contact groups or both.
+ *
+ * Example:
+ *
+ * @code
+ *
+ * using namespace Akonadi;
+ *
+ * AddressBookComboBox *box = new AddressBookComboBox( AddressBookComboBox::All,
+ *                                                     AddressBookComboBox::Readable, this );
+ *
+ * ...
+ *
+ * const Collection addressBook = box->selectedAddressBook();
+ *
+ * @endcode
+ *
+ * @author Tobias Koenig <tokoe@kde.org>
+ * @since 4.4
+ */
+class AKONADI_CONTACT_EXPORT AddressBookComboBox : public QWidget
+{
+  Q_OBJECT
+
+  public:
+    /**
+     * Describes what type of address books shall be listed for
+     * selection.
+     */
+    enum Type
+    {
+      ContactsOnly,      ///< Only address books that can store contacts.
+      ContactGroupsOnly, ///< Only address books that can store contact groups.
+      All                ///< All address books.
+    };
+
+    /**
+     * Describes what rights the address books must have that shall
+     * be listed for selection.
+     */
+    enum Rights
+    {
+      Readable,  ///< Address books that can be read from.
+      Writable   ///< Address books that can be written to.
+    };
+
+    /**
+     * Creates a new address book combobox.
+     *
+     * @param type The type of address books that shall be listed.
+     * @param rights The rights of the address books that shall be listed.
+     * @param parent The parent widget.
+     */
+    AddressBookComboBox( Type type, Rights rights, QWidget *parent = 0 );
+
+    /**
+     * Destroys the collection combobox.
+     */
+    ~AddressBookComboBox();
+
+    /**
+     * Sets the @p addressbook that shall be selected as default.
+     */
+    void setDefaultAddressBook( const Collection &addressbook );
+
+    /**
+     * Returns the selected address book.
+     */
+    Akonadi::Collection selectedAddressBook() const;
+
+  Q_SIGNALS:
+    /**
+     * This signal is emitted whenever the selected address book changed.
+     *
+     * @param addressBook The selected address book.
+     */
+    void selectionChanged( const Akonadi::Collection &addressBook );
+
+  private:
+    //@cond PRIVATE
+    class Private;
+    Private* const d;
+
+    Q_PRIVATE_SLOT( d, void activated( int ) )
+    Q_PRIVATE_SLOT( d, void activated( const QModelIndex& ) )
+    //@endcond
+};
+
+}
+
+#endif
diff -pubNr /opt/kde-stable/include/akonadi/contact/addressbookselectiondialog.h /opt/kde-trunk/include/akonadi/contact/addressbookselectiondialog.h
--- /opt/kde-stable/include/akonadi/contact/addressbookselectiondialog.h	1970-01-01 01:00:00.000000000 +0100
+++ /opt/kde-trunk/include/akonadi/contact/addressbookselectiondialog.h	2009-09-15 14:20:19.000000000 +0200
@@ -0,0 +1,105 @@
+/*
+    This file is part of Akonadi Contact.
+
+    Copyright (c) 2009 Tobias Koenig <tokoe@kde.org>
+
+    This library is free software; you can redistribute it and/or modify it
+    under the terms of the GNU Library General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or (at your
+    option) any later version.
+
+    This library is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
+    License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to the
+    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+    02110-1301, USA.
+*/
+
+#ifndef AKONADI_ADDRESSBOOKSELECTIONDIALOG_H
+#define AKONADI_ADDRESSBOOKSELECTIONDIALOG_H
+
+#include "akonadi-contact_export.h"
+
+#include <kdialog.h>
+
+namespace Akonadi
+{
+
+class Collection;
+
+/**
+ * @short A dialog to select an address book in Akonadi.
+ *
+ * This dialog provides a combobox to select an address book
+ * collection from the Akonadi storage.
+ * The available address books can be filtered to show only
+ * address books that can contain contacts, contact groups or both.
+ *
+ * Example:
+ *
+ * @code
+ *
+ * using namespace Akonadi;
+ *
+ * AddressBookSelectionDialog dlg( AddressBookSelectionDialog::All, this );
+ * if ( dlg.exec() ) {
+ *   const Collection addressBook = dlg.selectedAddressBook();
+ *   ...
+ * }
+ *
+ * @endcode
+ *
+ * @author Tobias Koenig <tokoe@kde.org>
+ * @since 4.4
+ */
+class AKONADI_CONTACT_EXPORT AddressBookSelectionDialog : public KDialog
+{
+  public:
+    /**
+     * Describes what type of address books shall be listed for
+     * selection.
+     */
+    enum Type
+    {
+      ContactsOnly,      ///< Only address books that can store contacts.
+      ContactGroupsOnly, ///< Only address books that can store contact groups.
+      All                ///< All address books.
+    };
+
+    /**
+     * Creates a new address bool selection dialog.
+     *
+     * @param parent The parent widget.
+     */
+    explicit AddressBookSelectionDialog( Type type, QWidget *parent = 0 );
+
+    /**
+     * Destroys the address book selection dialog.
+     */
+    ~AddressBookSelectionDialog();
+
+    /**
+     * Sets the @p addressbook that shall be selected as default.
+     */
+    void setDefaultAddressBook( const Akonadi::Collection &addressbook );
+
+    /**
+     * Returns the selected collection or an invalid collection
+     * if none is selected.
+     */
+    Akonadi::Collection selectedAddressBook() const;
+
+  private:
+    //@cond PRIVATE
+    class Private;
+    Private* const d;
+    //@endcond
+};
+
+}
+
+#endif
diff -pubNr /opt/kde-stable/include/akonadi/contact/akonadi-contact_export.h /opt/kde-trunk/include/akonadi/contact/akonadi-contact_export.h
--- /opt/kde-stable/include/akonadi/contact/akonadi-contact_export.h	1970-01-01 01:00:00.000000000 +0100
+++ /opt/kde-trunk/include/akonadi/contact/akonadi-contact_export.h	2009-08-31 15:13:21.000000000 +0200
@@ -0,0 +1,36 @@
+/*  This file is part of the KDE project
+    Copyright (C) 2007 David Faure <faure@kde.org>
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to
+    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+    Boston, MA 02110-1301, USA.
+*/
+
+#ifndef AKONADI_CONTACT_EXPORT_H
+#define AKONADI_CONTACT_EXPORT_H
+
+/* needed for KDE_EXPORT and KDE_IMPORT macros */
+#include <kdemacros.h>
+
+#ifndef AKONADI_CONTACT_EXPORT
+# if defined(MAKE_AKONADI_CONTACT_LIB)
+   /* We are building this library */
+#  define AKONADI_CONTACT_EXPORT KDE_EXPORT
+# else
+   /* We are using this library */
+#  define AKONADI_CONTACT_EXPORT KDE_IMPORT
+# endif
+#endif
+
+#endif
diff -pubNr /opt/kde-stable/include/akonadi/contact/contactdefaultactions.h /opt/kde-trunk/include/akonadi/contact/contactdefaultactions.h
--- /opt/kde-stable/include/akonadi/contact/contactdefaultactions.h	1970-01-01 01:00:00.000000000 +0100
+++ /opt/kde-trunk/include/akonadi/contact/contactdefaultactions.h	2009-09-21 13:36:00.000000000 +0200
@@ -0,0 +1,120 @@
+/*
+    This file is part of Akonadi Contact.
+
+    Copyright (c) 2009 Tobias Koenig <tokoe@kde.org>
+
+    This library is free software; you can redistribute it and/or modify it
+    under the terms of the GNU Library General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or (at your
+    option) any later version.
+
+    This library is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
+    License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to the
+    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+    02110-1301, USA.
+*/
+
+#ifndef AKONADI_CONTACTDEFAULTACTIONS_H
+#define AKONADI_CONTACTDEFAULTACTIONS_H
+
+#include "akonadi-contact_export.h"
+
+#include <QtCore/QObject>
+
+class QUrl;
+
+namespace KABC {
+class Address;
+class PhoneNumber;
+}
+
+namespace Akonadi {
+
+/**
+ * @short A convenience class that handles different contact related actions.
+ *
+ * This class handles contact related actions like opening an email address,
+ * showing the address of a contact on a map etc.
+ *
+ * Example:
+ *
+ * @code
+ *
+ * using namespace Akonadi;
+ *
+ * const Item contact = ...
+ *
+ * ContactViewer *viewer = new ContactViewer( this );
+ * viewer->setContact( contact );
+ *
+ * ContactDefaultActions *actions = new ContactDefaultActions( this );
+ * actions->connectToView( viewer );
+ *
+ * @endcode
+ *
+ * @author Tobias Koenig <tokoe@kde.org>
+ * @since 4.4
+ */
+class AKONADI_CONTACT_EXPORT ContactDefaultActions : public QObject
+{
+  Q_OBJECT
+
+  public:
+    /**
+     * Creates a new contact default actions object.
+     *
+     * @param parent The parent object.
+     */
+    ContactDefaultActions( QObject *parent = 0 );
+
+    /**
+     * Destroys the contact default actions object.
+     */
+    virtual ~ContactDefaultActions();
+
+    /**
+     * Tries to connect the well known signals of the @p view
+     * to the well known slots of this object.
+     */
+    void connectToView( QObject *view );
+
+  public Q_SLOTS:
+    /**
+     * Shows the given @p url in the users preferred webbrowser.
+     */
+    void showUrl( const QUrl &url );
+
+    /**
+     * Opens the users preferred mail composer and does the setup
+     * to send a mail to the contact with the given @p name and
+     * email @p address.
+     */
+    void sendEmail( const QString &name, const QString &address );
+
+    /**
+     * Dials the given phone @p number with the application as
+     * configured by the user in the general settings dialog.
+     */
+    void dialPhoneNumber( const KABC::PhoneNumber &number );
+
+    /**
+     * Shows the @p address of a contact in a webbrowser or application
+     * as configured by the user in the general settings dialog.
+     */
+    void showAddress( const KABC::Address &address );
+
+  private:
+    //@cond PRIVATE
+    class Private;
+    Private* const d;
+    //@endcond PRIVATE
+};
+
+}
+
+#endif
diff -pubNr /opt/kde-stable/include/akonadi/contact/contacteditordialog.h /opt/kde-trunk/include/akonadi/contact/contacteditordialog.h
--- /opt/kde-stable/include/akonadi/contact/contacteditordialog.h	1970-01-01 01:00:00.000000000 +0100
+++ /opt/kde-trunk/include/akonadi/contact/contacteditordialog.h	2009-09-09 13:51:48.000000000 +0200
@@ -0,0 +1,148 @@
+/*
+    This file is part of Akonadi Contact.
+
+    Copyright (c) 2007-2009 Tobias Koenig <tokoe@kde.org>
+
+    This library is free software; you can redistribute it and/or modify it
+    under the terms of the GNU Library General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or (at your
+    option) any later version.
+
+    This library is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
+    License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to the
+    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+    02110-1301, USA.
+*/
+
+#ifndef AKONADI_CONTACTEDITORDIALOG_H
+#define AKONADI_CONTACTEDITORDIALOG_H
+
+#include "akonadi-contact_export.h"
+
+#include <kdialog.h>
+
+class QAbstractItemModel;
+
+namespace Akonadi {
+
+class AbstractContactEditorWidget;
+class Collection;
+class Item;
+
+/**
+ * @short A dialog for creating or editing a contact in Akonadi.
+ *
+ * This dialog provides a way to create a new contact or edit
+ * an existing contact in Akonadi.
+ *
+ * Example for creating a new contact:
+ *
+ * @code
+ *
+ * Akonadi::ContactEditorDialog dlg( Akonadi::ContactEditorDialog::CreateMode, this );
+ *
+ * if ( dlg.exec() ) {
+ *   qDebug() << "New contact has been added to the address book";
+ * } else {
+ *   qDebug() << "User has canceled operation";
+ * }
+ *
+ * @endcode
+ *
+ * Example for editing an existing contact:
+ *
+ * @code
+ *
+ * const Akonadi::Item contact = ...;
+ *
+ * Akonadi::ContactEditorDialog dlg( Akonadi::ContactEditorDialog::EditMode, this );
+ * dlg.setContact( contact );
+ *
+ * if ( dlg.exec() ) {
+ *   qDebug() << "Contact has been edited";
+ * } else {
+ *   qDebug() << "User has canceled operation";
+ * }
+ *
+ * @endcode
+ *
+ * @author Tobias Koenig <tokoe@kde.org>
+ * @since 4.4
+ */
+class AKONADI_CONTACT_EXPORT ContactEditorDialog : public KDialog
+{
+  Q_OBJECT
+
+  public:
+    /**
+     * Describes the mode of the editor dialog.
+     */
+    enum Mode
+    {
+      CreateMode, ///< Creates a new contact
+      EditMode    ///< Edits an existing contact
+    };
+
+    /**
+     * Creates a new contact editor dialog with the standard editor widget.
+     *
+     * @param mode The mode of the dialog.
+     * @param parent The parent widget of the dialog.
+     */
+    explicit ContactEditorDialog( Mode mode, QWidget *parent = 0 );
+
+    /**
+     * Creates a new contact editor dialog with a custom editor widget.
+     *
+     * @param mode The mode of the dialog.
+     * @param collectionModel The collection model that is used to allow the user
+     *                        to select a target collection for new contacts.
+     * @param editorWidget The contact editor widget that shall be used for editing.
+     * @param parent The parent widget of the dialog.
+     */
+    ContactEditorDialog( Mode mode, AbstractContactEditorWidget *editorWidget, QWidget *parent = 0 );
+
+    /**
+     * Destroys the contact editor dialog.
+     */
+    ~ContactEditorDialog();
+
+    /**
+     * Sets the @p contact to edit when in EditMode.
+     *
+     * @note The contact item just must have a uid set, all
+     *       other data are fetched by the dialog automatically.
+     */
+    void setContact( const Akonadi::Item &contact );
+
+    /**
+     * Sets the @p addressbook that shall be selected as default in create mode.
+     */
+    void setDefaultAddressBook( const Akonadi::Collection &addressbook );
+
+  Q_SIGNALS:
+    /**
+     * This signal is emitted whenever a contact was updated or stored.
+     *
+     * @param contact The data reference of the contact.
+     */
+    void contactStored( const Akonadi::Item &contact );
+
+  private:
+    //@cond PRIVATE
+    class Private;
+    Private* const d;
+
+    Q_PRIVATE_SLOT( d, void slotOkClicked() )
+    Q_PRIVATE_SLOT( d, void slotCancelClicked() )
+    //@endcond PRIVATE
+};
+
+}
+
+#endif
diff -pubNr /opt/kde-stable/include/akonadi/contact/contacteditor.h /opt/kde-trunk/include/akonadi/contact/contacteditor.h
--- /opt/kde-stable/include/akonadi/contact/contacteditor.h	1970-01-01 01:00:00.000000000 +0100
+++ /opt/kde-trunk/include/akonadi/contact/contacteditor.h	2009-09-09 14:22:32.000000000 +0200
@@ -0,0 +1,161 @@
+/*
+    This file is part of Akonadi Contact.
+
+    Copyright (c) 2009 Tobias Koenig <tokoe@kde.org>
+
+    This library is free software; you can redistribute it and/or modify it
+    under the terms of the GNU Library General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or (at your
+    option) any later version.
+
+    This library is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
+    License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to the
+    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+    02110-1301, USA.
+*/
+
+#ifndef AKONADI_CONTACTEDITOR_H
+#define AKONADI_CONTACTEDITOR_H
+
+#include "akonadi-contact_export.h"
+
+#include <QtGui/QWidget>
+
+namespace Akonadi {
+
+class AbstractContactEditorWidget;
+class Collection;
+class Item;
+
+/**
+ * @short An widget to edit contacts in Akonadi.
+ *
+ * This widget provides a way to create a new contact or edit
+ * an existing contact in Akonadi.
+ *
+ * Example for creating a new contact:
+ *
+ * @code
+ *
+ * using namespace Akonadi;
+ *
+ * ContactEditor *editor = new ContactEditor( Akonadi::ContactEditor::CreateMode, this );
+ *
+ * ...
+ *
+ * if ( !editor->saveContact() ) {
+ *   qDebug() << "Unable to save new contact to storage";
+ *   return;
+ * }
+ *
+ * @endcode
+ *
+ * Example for editing an existing contact:
+ *
+ * @code
+ *
+ * const Akonadi::Item contact = ...;
+ *
+ * ContactEditor *editor = new ContactEditor( Akonadi::ContactEditor::EditMode, this );
+ * editor->loadContact( contact );
+ *
+ * ...
+ *
+ * if ( !editor->saveContact() ) {
+ *   qDebug() << "Unable to save changed contact to storage";
+ *   return;
+ * }
+ *
+ * @endcode
+ *
+ * @author Tobias Koenig <tokoe@kde.org>
+ * @since 4.4
+ */
+class AKONADI_CONTACT_EXPORT ContactEditor : public QWidget
+{
+  Q_OBJECT
+
+  public:
+    /**
+     * Describes the mode of the editor.
+     */
+    enum Mode
+    {
+      CreateMode, ///< Creates a new contact
+      EditMode    ///< Edits an existing contact
+    };
+
+    /**
+     * Creates a new contact editor with the standard editor widget.
+     *
+     * @param mode The mode of the editor.
+     * @param editorWidget The contact editor widget that shall be used for editing.
+     * @param parent The parent widget of the editor.
+     */
+    explicit ContactEditor( Mode mode, QWidget *parent = 0 );
+
+    /**
+     * Creates a new contact editor with a custom editor widget.
+     *
+     * @param mode The mode of the editor.
+     * @param editorWidget The contact editor widget that shall be used for editing.
+     * @param parent The parent widget of the editor.
+     */
+    ContactEditor( Mode mode, AbstractContactEditorWidget *editorWidget, QWidget *parent = 0 );
+
+    /**
+     * Destroys the contact editor.
+     */
+    virtual ~ContactEditor();
+
+  public Q_SLOTS:
+    /**
+     * Loads the @p contact into the editor.
+     */
+    void loadContact( const Akonadi::Item &contact );
+
+    /**
+     * Saves the contact from the editor back to the storage.
+     */
+    bool saveContact();
+
+    /**
+     * Sets the @p collection which shall be used to store new
+     * contacts.
+     */
+    void setDefaultCollection( const Akonadi::Collection &collection );
+
+  Q_SIGNALS:
+    /**
+     * This signal is emitted when the @p contact has been saved back
+     * to the storage.
+     */
+    void contactStored( const Akonadi::Item &contact );
+
+    /**
+     * This signal is emitted when an error occurred during the save.
+     *
+     * @p errorMsg The error message.
+     */
+    void error( const QString &errorMsg );
+
+  private:
+    //@cond PRIVATE
+    class Private;
+    Private* const d;
+
+    Q_PRIVATE_SLOT( d, void itemFetchDone( KJob* ) )
+    Q_PRIVATE_SLOT( d, void parentCollectionFetchDone( KJob* ) )
+    Q_PRIVATE_SLOT( d, void storeDone( KJob* ) )
+    Q_PRIVATE_SLOT( d, void itemChanged( const Akonadi::Item&, const QSet<QByteArray>& ) )
+    //@endcond PRIVATE
+};
+
+}
+
+#endif
diff -pubNr /opt/kde-stable/include/akonadi/contact/contacteditorpageplugin.h /opt/kde-trunk/include/akonadi/contact/contacteditorpageplugin.h
--- /opt/kde-stable/include/akonadi/contact/contacteditorpageplugin.h	1970-01-01 01:00:00.000000000 +0100
+++ /opt/kde-trunk/include/akonadi/contact/contacteditorpageplugin.h	2009-10-02 07:10:14.000000000 +0200
@@ -0,0 +1,67 @@
+/*
+    This file is part of Akonadi Contact.
+
+    Copyright (c) 2009 Tobias Koenig <tokoe@kde.org>
+
+    This library is free software; you can redistribute it and/or modify it
+    under the terms of the GNU Library General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or (at your
+    option) any later version.
+
+    This library is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
+    License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to the
+    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+    02110-1301, USA.
+*/
+
+#ifndef AKONADI_CONTACTEDITORPAGEPLUGIN_H
+#define AKONADI_CONTACTEDITORPAGEPLUGIN_H
+
+#include <QtGui/QWidget>
+
+namespace KABC {
+class Addressee;
+}
+
+namespace Akonadi
+{
+
+/**
+ * @short The base class for custom ContactEditor page plugins.
+ *
+ * @author Tobias Koenig <tokoe@kde.org>
+ */
+class ContactEditorPagePlugin : public QWidget
+{
+  public:
+    /**
+     * Returns the i18n'd page title.
+     */
+    virtual QString title() const = 0;
+
+    /**
+     * This method is called to fill the editor widget with the data from @p contact.
+     */
+    virtual void loadContact( const KABC::Addressee &contact ) = 0;
+
+    /**
+     * This method is called to store the data from the editor widget into @p contact.
+     */
+    virtual void storeContact( KABC::Addressee &contact ) const = 0;
+
+    /**
+     * This method is called to set the editor widget @p readOnly.
+     */
+    virtual void setReadOnly( bool readOnly ) = 0;
+};
+
+}
+
+Q_DECLARE_INTERFACE( Akonadi::ContactEditorPagePlugin, "org.freedesktop.Akonadi.ContactEditorPagePlugin/1.0" )
+
+#endif
diff -pubNr /opt/kde-stable/include/akonadi/contact/contactgroupeditordialog.h /opt/kde-trunk/include/akonadi/contact/contactgroupeditordialog.h
--- /opt/kde-stable/include/akonadi/contact/contactgroupeditordialog.h	1970-01-01 01:00:00.000000000 +0100
+++ /opt/kde-trunk/include/akonadi/contact/contactgroupeditordialog.h	2009-09-11 15:02:51.000000000 +0200
@@ -0,0 +1,134 @@
+/*
+    This file is part of Akonadi Contact.
+
+    Copyright (c) 2009 Tobias Koenig <tokoe@kde.org>
+
+    This library is free software; you can redistribute it and/or modify it
+    under the terms of the GNU Library General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or (at your
+    option) any later version.
+
+    This library is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
+    License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to the
+    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+    02110-1301, USA.
+*/
+
+#ifndef AKONADI_CONTACTGROUPEDITORDIALOG_H
+#define AKONADI_CONTACTGROUPEDITORDIALOG_H
+
+#include "akonadi-contact_export.h"
+
+#include <kdialog.h>
+
+class QAbstractItemModel;
+
+namespace Akonadi {
+
+class Item;
+class Collection;
+class ContactGroupEditor;
+
+/**
+ * @short A dialog for creating or editing a contact group in Akonadi.
+ *
+ * This dialog provides a way to create a new contact group or edit
+ * an existing contact group in Akonadi.
+ *
+ * Example for creating a new contact group:
+ *
+ * @code
+ *
+ * Akonadi::ContactGroupEditorDialog dlg( Akonadi::ContactGroupEditorDialog::CreateMode, this );
+ *
+ * if ( dlg.exec() ) {
+ *   qDebug() << "New contact group has been added to the address book";
+ * } else {
+ *   qDebug() << "User has canceled operation";
+ * }
+ *
+ * @endcode
+ *
+ * Example for editing an existing contact group:
+ *
+ * @code
+ *
+ * const Akonadi::Item contactGroup = ...;
+ *
+ * Akonadi::ContactGroupEditorDialog dlg( Akonadi::ContactGroupEditorDialog::EditMode, this );
+ * dlg.setContactGroup( contactGroup );
+ *
+ * if ( dlg.exec() ) {
+ *   qDebug() << "Contact group has been edited";
+ * } else {
+ *   qDebug() << "User has canceled operation";
+ * }
+ *
+ * @endcode
+ *
+ * @author Tobias Koenig <tokoe@kde.org>
+ * @since 4.4
+ */
+class AKONADI_CONTACT_EXPORT ContactGroupEditorDialog : public KDialog
+{
+  Q_OBJECT
+
+  public:
+    /**
+     * Describes the mode of the contact group editor.
+     */
+    enum Mode
+    {
+      CreateMode, ///< Creates a new contact group
+      EditMode    ///< Edits an existing contact group
+    };
+
+    /**
+     * Creates a new contact group editor dialog.
+     *
+     * @param mode The mode of the dialog.
+     * @param parent The parent widget of the dialog.
+     */
+    explicit ContactGroupEditorDialog( Mode mode, QWidget *parent = 0 );
+
+    /**
+     * Destroys the contact group editor dialog.
+     */
+    ~ContactGroupEditorDialog();
+
+    /**
+     * Sets the contact @p group to edit when in EditMode.
+     */
+    void setContactGroup( const Akonadi::Item &group );
+
+    /**
+     * Sets the @p addressbook that shall be selected as default in create mode.
+     */
+    void setDefaultAddressBook( const Akonadi::Collection &addressbook );
+
+  Q_SIGNALS:
+    /**
+     * This signal is emitted whenever a contact group was updated or stored.
+     *
+     * @param group The contact group.
+     */
+    void contactGroupStored( const Akonadi::Item &group );
+
+  protected Q_SLOTS:
+    virtual void slotButtonClicked( int button );
+
+  private:
+    //@cond PRIVATE
+    class Private;
+    Private* const d;
+    //@endcond
+};
+
+}
+
+#endif
diff -pubNr /opt/kde-stable/include/akonadi/contact/contactgroupeditor.h /opt/kde-trunk/include/akonadi/contact/contactgroupeditor.h
--- /opt/kde-stable/include/akonadi/contact/contactgroupeditor.h	1970-01-01 01:00:00.000000000 +0100
+++ /opt/kde-trunk/include/akonadi/contact/contactgroupeditor.h	2009-10-12 07:28:16.000000000 +0200
@@ -0,0 +1,154 @@
+/*
+    This file is part of Akonadi Contact.
+
+    Copyright (c) 2009 Tobias Koenig <tokoe@kde.org>
+
+    This library is free software; you can redistribute it and/or modify it
+    under the terms of the GNU Library General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or (at your
+    option) any later version.
+
+    This library is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
+    License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to the
+    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+    02110-1301, USA.
+*/
+
+#ifndef AKONADI_CONTACTGROUPEDITOR_H
+#define AKONADI_CONTACTGROUPEDITOR_H
+
+#include "akonadi-contact_export.h"
+
+#include <QtGui/QWidget>
+
+namespace Akonadi {
+
+class Collection;
+class Item;
+
+/**
+ * @short An widget to edit contact groups in Akonadi.
+ *
+ * This widget provides a way to create a new contact group or edit
+ * an existing contact group in Akonadi.
+ *
+ * Example for creating a new contact group:
+ *
+ * @code
+ *
+ * using namespace Akonadi;
+ *
+ * ContactGroupEditor *editor = new ContactGroupEditor( Akonadi::ContactGroupEditor::CreateMode, this );
+ *
+ * ...
+ *
+ * if ( !editor->saveContactGroup() ) {
+ *   qDebug() << "Unable to save new contact group to storage";
+ *   return;
+ * }
+ *
+ * @endcode
+ *
+ * Example for editing an existing contact group:
+ *
+ * @code
+ *
+ * const Akonadi::Item contactGroup = ...;
+ *
+ * ContactGroupEditor *editor = new ContactGroupEditor( Akonadi::ContactGroupEditor::EditMode, this );
+ * editor->loadContactGroup( contactGroup );
+ *
+ * ...
+ *
+ * if ( !editor->saveContactGroup() ) {
+ *   qDebug() << "Unable to save changed contact group to storage";
+ *   return;
+ * }
+ *
+ * @endcode
+ *
+ * @author Tobias Koenig <tokoe@kde.org>
+ * @since 4.4
+ */
+class AKONADI_CONTACT_EXPORT ContactGroupEditor : public QWidget
+{
+  Q_OBJECT
+
+  public:
+    /**
+     * Describes the mode of the contact group editor.
+     */
+    enum Mode
+    {
+      CreateMode, ///< Creates a new contact group
+      EditMode    ///< Edits an existing contact group
+    };
+
+    /**
+     * Creates a new contact group editor.
+     *
+     * @param mode The mode of the editor.
+     * @param parent The parent widget of the editor.
+     */
+    explicit ContactGroupEditor( Mode mode, QWidget *parent = 0 );
+
+    /**
+     * Destroys the contact group editor.
+     */
+    virtual ~ContactGroupEditor();
+
+  public Q_SLOTS:
+    /**
+     * Loads the contact @p group into the editor.
+     */
+    void loadContactGroup( const Akonadi::Item &group );
+
+    /**
+     * Saves the contact group from the editor back to the storage.
+     *
+     * @returns @c true if the contact group has been saved successfully, false otherwise.
+     */
+    bool saveContactGroup();
+
+    /**
+     * Sets the @p collection which shall be used to store new
+     * contact groups.
+     */
+    void setDefaultCollection( const Akonadi::Collection &collection );
+
+  Q_SIGNALS:
+    /**
+     * This signal is emitted when the contact @p group has been saved back
+     * to the storage.
+     */
+    void contactGroupStored( const Akonadi::Item &group );
+
+    /**
+     * This signal is emitted when an error occurred during the save.
+     *
+     * @p errorMsg The error message.
+     */
+    void error( const QString &errorMsg );
+
+  private:
+    //@cond PRIVATE
+    class Private;
+    Private* const d;
+
+    Q_DISABLE_COPY( ContactGroupEditor )
+
+    Q_PRIVATE_SLOT( d, void itemFetchDone( KJob* ) )
+    Q_PRIVATE_SLOT( d, void parentCollectionFetchDone( KJob* ) )
+    Q_PRIVATE_SLOT( d, void storeDone( KJob* ) )
+    Q_PRIVATE_SLOT( d, void itemChanged( const Akonadi::Item&, const QSet<QByteArray>& ) )
+    //@endcond
+};
+
+}
+
+#endif
diff -pubNr /opt/kde-stable/include/akonadi/contact/contactgroupexpandjob.h /opt/kde-trunk/include/akonadi/contact/contactgroupexpandjob.h
--- /opt/kde-stable/include/akonadi/contact/contactgroupexpandjob.h	1970-01-01 01:00:00.000000000 +0100
+++ /opt/kde-trunk/include/akonadi/contact/contactgroupexpandjob.h	2009-09-09 13:52:16.000000000 +0200
@@ -0,0 +1,110 @@
+/*
+    This file is part of Akonadi Contact.
+
+    Copyright (c) 2009 Tobias Koenig <tokoe@kde.org>
+
+    This library is free software; you can redistribute it and/or modify it
+    under the terms of the GNU Library General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or (at your
+    option) any later version.
+
+    This library is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
+    License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to the
+    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+    02110-1301, USA.
+*/
+
+#ifndef AKONADI_CONTACTGROUPEXPANDJOB_H
+#define AKONADI_CONTACTGROUPEXPANDJOB_H
+
+#include "akonadi-contact_export.h"
+
+#include <kabc/addressee.h>
+#include <kabc/contactgroup.h>
+#include <kjob.h>
+
+namespace Akonadi {
+
+/**
+ * @short Job that expands a ContactGroup to a list of contacts.
+ *
+ * This job takes a KABC::ContactGroup object and expands it to a list
+ * of KABC::Addressee objects by creating temporary KABC::Addressee objects
+ * for the KABC::ContactGroup::Data objects of the group and fetching the
+ * complete contacts from the Akonadi storage for the
+ * KABC::ContactGroup::ContactReferences of the group.
+ *
+ * @code
+ *
+ * const KABC::ContactGroup group = ...;
+ *
+ * Akonadi::ContactGroupExpandJob *job = new Akonadi::ContactGroupExpandJob( group );
+ * job->start();
+ * connect( job, SIGNAL( result( KJob* ) ), this, SLOT( expandResult( KJob* ) ) );
+ *
+ * ...
+ *
+ * MyClass::expandResult( KJob *job )
+ * {
+ *   Akonadi::ContactGroupExpandJob *expandJob = qobject_cast<Akonadi::ContactGroupExpandJob*>( job );
+ *   const KABC::Addressee::List contacts = expandJob->contacts();
+ *   // do something with the contacts
+ * }
+ *
+ * @endcode
+ *
+ * @author Tobias Koenig <tokoe@kde.org>
+ * @since 4.4
+ */
+class AKONADI_CONTACT_EXPORT ContactGroupExpandJob : public KJob
+{
+  Q_OBJECT
+
+  public:
+    /**
+     * Creates a new contact group expand job.
+     *
+     * @param group The contact group to expand.
+     * @param parent The parent object.
+     */
+    explicit ContactGroupExpandJob( const KABC::ContactGroup &group, QObject *parent = 0 );
+
+    /**
+     * Destroys the contact group expand job.
+     */
+    ~ContactGroupExpandJob();
+
+    /**
+     * Returns the list of contacts.
+     */
+    KABC::Addressee::List contacts() const;
+
+    /**
+     * Returns the list of email addresses of the contacts.
+     *
+     * Each entry of the list is in the form: FullName <email@address>
+     */
+    QStringList emailAddresses() const;
+
+    /**
+     * Starts the expand job.
+     */
+    virtual void start();
+
+  private:
+    //@cond PRIVATE
+    class Private;
+    Private* const d;
+
+    Q_PRIVATE_SLOT( d, void fetchResult( KJob* ) )
+    //@endcond
+};
+
+}
+
+#endif
diff -pubNr /opt/kde-stable/include/akonadi/contact/contactgroupsearchjob.h /opt/kde-trunk/include/akonadi/contact/contactgroupsearchjob.h
--- /opt/kde-stable/include/akonadi/contact/contactgroupsearchjob.h	1970-01-01 01:00:00.000000000 +0100
+++ /opt/kde-trunk/include/akonadi/contact/contactgroupsearchjob.h	2009-09-09 13:52:27.000000000 +0200
@@ -0,0 +1,116 @@
+/*
+    This file is part of Akonadi Contact.
+
+    Copyright (c) 2009 Tobias Koenig <tokoe@kde.org>
+
+    This library is free software; you can redistribute it and/or modify it
+    under the terms of the GNU Library General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or (at your
+    option) any later version.
+
+    This library is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
+    License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to the
+    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+    02110-1301, USA.
+*/
+
+#ifndef AKONADI_CONTACTGROUPSEARCHJOB_H
+#define AKONADI_CONTACTGROUPSEARCHJOB_H
+
+#include "akonadi-contact_export.h"
+
+#include <akonadi/item.h>
+#include <kabc/contactgroup.h>
+#include <kjob.h>
+
+namespace Akonadi {
+
+/**
+ * @short Job that searches for contact groups in the Akonadi storage.
+ *
+ * This job searches for contact groups that match given search criteria and returns
+ * the list of contact groups.
+ *
+ * @code
+ *
+ * Akonadi::ContactGroupSearchJob *job = new Akonadi::ContactGroupSearchJob();
+ * job->setQuery( Akonadi::ContactGroupSearchJob::Name, "Family Members" );
+ * job->start();
+ * connect( job, SIGNAL( result( KJob* ) ), this, SLOT( searchResult( KJob* ) ) );
+ *
+ * ...
+ *
+ * MyClass::searchResult( KJob *job )
+ * {
+ *   Akonadi::ContactGroupSearchJob *searchJob = qobject_cast<Akonadi::ContactGroupSearchJob*>( job );
+ *   const KABC::ContactGroup::List contactGroups = searchJob->contactGroups();
+ *   // do something with the contact groups
+ * }
+ *
+ * @endcode
+ *
+ * @author Tobias Koenig <tokoe@kde.org>
+ * @since 4.4
+ */
+class AKONADI_CONTACT_EXPORT ContactGroupSearchJob : public KJob
+{
+  Q_OBJECT
+
+  public:
+    /**
+     * Creates a new contact group search job.
+     *
+     * @param parent The parent object.
+     */
+    explicit ContactGroupSearchJob( QObject *parent = 0 );
+
+    /**
+     * Destroys the contact group search job.
+     */
+    ~ContactGroupSearchJob();
+
+    /**
+     * Describes the criteria that can be searched for.
+     */
+    enum Criterion
+    {
+      Name ///< The name of the contact group.
+    };
+
+    /**
+     * Sets the @p criterion and @p value for the search.
+     */
+    void setQuery( Criterion criterion, const QString &value );
+
+    /**
+     * Returns the contact groups that matched the search criteria.
+     */
+    KABC::ContactGroup::List contactGroups() const;
+
+    /**
+     * Returns the items that matched the search criteria.
+     */
+    Item::List items() const;
+
+    /**
+     * Starts the search job.
+     */
+    virtual void start();
+
+  private:
+    //@cond PRIVATE
+    class Private;
+    Private* const d;
+
+    Q_PRIVATE_SLOT( d, void searchResult( KJob* ) )
+    //@endcond
+};
+
+}
+
+#endif
diff -pubNr /opt/kde-stable/include/akonadi/contact/contactgroupviewerdialog.h /opt/kde-trunk/include/akonadi/contact/contactgroupviewerdialog.h
--- /opt/kde-stable/include/akonadi/contact/contactgroupviewerdialog.h	1970-01-01 01:00:00.000000000 +0100
+++ /opt/kde-trunk/include/akonadi/contact/contactgroupviewerdialog.h	2009-09-09 14:31:03.000000000 +0200
@@ -0,0 +1,91 @@
+/*
+    This file is part of Akonadi Contact.
+
+    Copyright (c) 2009 Tobias Koenig <tokoe@kde.org>
+
+    This library is free software; you can redistribute it and/or modify it
+    under the terms of the GNU Library General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or (at your
+    option) any later version.
+
+    This library is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
+    License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to the
+    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+    02110-1301, USA.
+*/
+
+#ifndef AKONADI_CONTACTGROUPVIEWERDIALOG_H
+#define AKONADI_CONTACTGROUPVIEWERDIALOG_H
+
+#include "akonadi-contact_export.h"
+
+#include <kdialog.h>
+
+namespace Akonadi {
+
+class Item;
+
+/**
+ * @short A dialog for displaying a contact group in Akonadi.
+ *
+ * This dialog provides a way to show a contact group from the
+ * Akonadi storage.
+ *
+ * Example:
+ *
+ * @code
+ *
+ * const Akonadi::Item group = ...
+ *
+ * Akonadi::ContactGroupViewerDialog dlg( this );
+ * dlg.setContactGroup( group );
+ * dlg.exec();
+ *
+ * @endcode
+ *
+ * @author Tobias Koenig <tokoe@kde.org>
+ * @since 4.4
+ */
+class AKONADI_CONTACT_EXPORT ContactGroupViewerDialog : public KDialog
+{
+  Q_OBJECT
+
+  public:
+    /**
+     * Creates a new contact group viewer dialog.
+     *
+     * @param parent The parent widget of the dialog.
+     */
+    ContactGroupViewerDialog( QWidget *parent = 0 );
+
+    /**
+     * Destroys the contact group viewer dialog.
+     */
+    ~ContactGroupViewerDialog();
+
+    /**
+     * Returns the contact group that is currently displayed.
+     */
+    Akonadi::Item contactGroup() const;
+
+  public Q_SLOTS:
+    /**
+     * Sets the contact @p group that shall be displayed in the dialog.
+     */
+    void setContactGroup( const Akonadi::Item &group );
+
+  private:
+    //@cond PRIVATE
+    class Private;
+    Private* const d;
+    //@endcond
+};
+
+}
+
+#endif
diff -pubNr /opt/kde-stable/include/akonadi/contact/contactgroupviewer.h /opt/kde-trunk/include/akonadi/contact/contactgroupviewer.h
--- /opt/kde-stable/include/akonadi/contact/contactgroupviewer.h	1970-01-01 01:00:00.000000000 +0100
+++ /opt/kde-trunk/include/akonadi/contact/contactgroupviewer.h	2009-09-09 14:34:00.000000000 +0200
@@ -0,0 +1,106 @@
+/*
+    This file is part of Akonadi Contact.
+
+    Copyright (c) 2009 Tobias Koenig <tokoe@kde.org>
+
+    This library is free software; you can redistribute it and/or modify it
+    under the terms of the GNU Library General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or (at your
+    option) any later version.
+
+    This library is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
+    License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to the
+    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+    02110-1301, USA.
+*/
+
+#ifndef AKONADI_CONTACTGROUPVIEWER_H
+#define AKONADI_CONTACTGROUPVIEWER_H
+
+#include "akonadi-contact_export.h"
+
+#include <akonadi/itemmonitor.h>
+
+#include <QtGui/QWidget>
+
+namespace Akonadi {
+
+/**
+ * @short A viewer component for contact groups in Akonadi.
+ *
+ * This widgets provides a way to show a contact group from the
+ * Akonadi storage.
+ *
+ * Example:
+ *
+ * @code
+ *
+ * using namespace Akonadi;
+ *
+ * const Item group = ...
+ *
+ * ContactGroupViewer *viewer = new ContactGroupViewer( this );
+ * viewer->setContactGroup( group );
+ *
+ * @endcode
+ *
+ * @author Tobias Koenig <tokoe@kde.org>
+ * @since 4.4
+ */
+class AKONADI_CONTACT_EXPORT ContactGroupViewer : public QWidget, public Akonadi::ItemMonitor
+{
+  Q_OBJECT
+
+  public:
+    /**
+     * Creates a new contact group viewer.
+     *
+     * @param parent The parent widget.
+     */
+    ContactGroupViewer( QWidget *parent = 0 );
+
+    /**
+     * Destroys the contact group viewer.
+     */
+    ~ContactGroupViewer();
+
+    /**
+     * Returns the contact group that is currently displayed.
+     */
+    Akonadi::Item contactGroup() const;
+
+  public Q_SLOTS:
+    /**
+     * Sets the contact @p group that shall be displayed in the viewer.
+     */
+    void setContactGroup( const Akonadi::Item &group );
+
+  private:
+    /**
+     * This method is called whenever the displayed contact @p group has been changed.
+     */
+    virtual void itemChanged( const Item &group );
+
+    /**
+     * This method is called whenever the displayed contact group has been
+     * removed from Akonadi.
+     */
+    virtual void itemRemoved();
+
+  private:
+    //@cond PRIVATE
+    class Private;
+    Private* const d;
+
+    Q_PRIVATE_SLOT( d, void _k_expandResult( KJob* ) )
+    //@endcond
+};
+
+}
+
+#endif
diff -pubNr /opt/kde-stable/include/akonadi/contact/contactsearchjob.h /opt/kde-trunk/include/akonadi/contact/contactsearchjob.h
--- /opt/kde-stable/include/akonadi/contact/contactsearchjob.h	1970-01-01 01:00:00.000000000 +0100
+++ /opt/kde-trunk/include/akonadi/contact/contactsearchjob.h	2009-09-09 13:52:59.000000000 +0200
@@ -0,0 +1,117 @@
+/*
+    This file is part of Akonadi Contact.
+
+    Copyright (c) 2009 Tobias Koenig <tokoe@kde.org>
+
+    This library is free software; you can redistribute it and/or modify it
+    under the terms of the GNU Library General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or (at your
+    option) any later version.
+
+    This library is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
+    License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to the
+    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+    02110-1301, USA.
+*/
+
+#ifndef AKONADI_CONTACTSEARCHJOB_H
+#define AKONADI_CONTACTSEARCHJOB_H
+
+#include "akonadi-contact_export.h"
+
+#include <akonadi/item.h>
+#include <kabc/addressee.h>
+#include <kjob.h>
+
+namespace Akonadi {
+
+/**
+ * @short Job that searches for contacts in the Akonadi storage.
+ *
+ * This job searches for contacts that match given search criteria and returns
+ * the list of contacts.
+ *
+ * @code
+ *
+ * Akonadi::ContactSearchJob *job = new Akonadi::ContactSearchJob();
+ * job->setQuery( Akonadi::ContactSearchJob::Email, "tokoe@kde.org" );
+ * job->start();
+ * connect( job, SIGNAL( result( KJob* ) ), this, SLOT( searchResult( KJob* ) ) );
+ *
+ * ...
+ *
+ * MyClass::searchResult( KJob *job )
+ * {
+ *   Akonadi::ContactSearchJob *searchJob = qobject_cast<Akonadi::ContactSearchJob*>( job );
+ *   const KABC::Addressee::List contacts = searchJob->contacts();
+ *   // do something with the contacts
+ * }
+ *
+ * @endcode
+ *
+ * @author Tobias Koenig <tokoe@kde.org>
+ * @since 4.4
+ */
+class AKONADI_CONTACT_EXPORT ContactSearchJob : public KJob
+{
+  Q_OBJECT
+
+  public:
+    /**
+     * Creates a new contact search job.
+     *
+     * @param parent The parent object.
+     */
+    explicit ContactSearchJob( QObject *parent = 0 );
+
+    /**
+     * Destroys the contact search job.
+     */
+    ~ContactSearchJob();
+
+    /**
+     * Describes the criteria that can be searched for.
+     */
+    enum Criterion
+    {
+      Name, ///< The name of the contact.
+      Email ///< The email address of the contact.
+    };
+
+    /**
+     * Sets the @p criterion and @p value for the search.
+     */
+    void setQuery( Criterion criterion, const QString &value );
+
+    /**
+     * Returns the contacts that matched the search criteria.
+     */
+    KABC::Addressee::List contacts() const;
+
+    /**
+     * Returns the items that matched the search criteria.
+     */
+    Item::List items() const;
+
+    /**
+     * Starts the search job.
+     */
+    virtual void start();
+
+  private:
+    //@cond PRIVATE
+    class Private;
+    Private* const d;
+
+    Q_PRIVATE_SLOT( d, void searchResult( KJob* ) )
+    //@endcond
+};
+
+}
+
+#endif
diff -pubNr /opt/kde-stable/include/akonadi/contact/contactviewerdialog.h /opt/kde-trunk/include/akonadi/contact/contactviewerdialog.h
--- /opt/kde-stable/include/akonadi/contact/contactviewerdialog.h	1970-01-01 01:00:00.000000000 +0100
+++ /opt/kde-trunk/include/akonadi/contact/contactviewerdialog.h	2009-09-20 16:00:56.000000000 +0200
@@ -0,0 +1,132 @@
+/*
+    This file is part of Akonadi Contact.
+
+    Copyright (c) 2009 Tobias Koenig <tokoe@kde.org>
+
+    This library is free software; you can redistribute it and/or modify it
+    under the terms of the GNU Library General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or (at your
+    option) any later version.
+
+    This library is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
+    License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to the
+    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+    02110-1301, USA.
+*/
+
+#ifndef AKONADI_CONTACTVIEWERDIALOG_H
+#define AKONADI_CONTACTVIEWERDIALOG_H
+
+#include "akonadi-contact_export.h"
+
+#include <kdialog.h>
+
+class QUrl;
+
+namespace KABC {
+class Address;
+class PhoneNumber;
+}
+
+namespace Akonadi {
+
+class Item;
+
+/**
+ * @short A dialog for displaying a contact in Akonadi.
+ *
+ * This dialog provides a way to show a contact from the
+ * Akonadi storage.
+ *
+ * Example:
+ *
+ * @code
+ *
+ * const Akonadi::Item contact = ...
+ *
+ * Akonadi::ContactViewerDialog dlg( this );
+ * dlg.setContact( contact );
+ * dlg.exec();
+ *
+ * @endcode
+ *
+ * @author Tobias Koenig <tokoe@kde.org>
+ * @since 4.4
+ */
+class AKONADI_CONTACT_EXPORT ContactViewerDialog : public KDialog
+{
+  Q_OBJECT
+
+  public:
+    /**
+     * Creates a new contact viewer dialog.
+     *
+     * @param parent The parent widget of the dialog.
+     */
+    ContactViewerDialog( QWidget *parent = 0 );
+
+    /**
+     * Destroys the contact viewer dialog.
+     */
+    ~ContactViewerDialog();
+
+    /**
+     * Returns the contact that is currently displayed.
+     */
+    Akonadi::Item contact() const;
+
+  public Q_SLOTS:
+    /**
+     * Sets the @p contact that shall be displayed in the dialog.
+     */
+    void setContact( const Akonadi::Item &contact );
+
+  Q_SIGNALS:
+    /**
+     * This signal is emitted whenever the user has clicked on
+     * a url (e.g. homepage or blog url) in the viewer dialog.
+     *
+     * @param url The url that has been clicked.
+     */
+    void urlClicked( const QUrl &url );
+
+    /**
+     * This signal is emitted whenever the user has clicked on
+     * an email address in the viewer dialog.
+     *
+     * @param name The name of the contact.
+     * @param email The plain email address of the contact.
+     */
+    void emailClicked( const QString &name, const QString &email );
+
+    /**
+     * This signal is emitted whenever the user has clicked on a
+     * phone number (that includes fax numbers as well) in the viewer dialog.
+     *
+     * @param number The corresponding phone number.
+     */
+    void phoneNumberClicked( const KABC::PhoneNumber &number );
+
+    /**
+     * This signal is emitted whenever the user has clicked on an
+     * address in the viewer dialog.
+     *
+     * @param address The corresponding address.
+     */
+    void addressClicked( const KABC::Address &address );
+
+  private:
+    //@cond PRIVATE
+    class Private;
+    Private* const d;
+    //@endcond
+};
+
+}
+
+#endif
diff -pubNr /opt/kde-stable/include/akonadi/contact/contactviewer.h /opt/kde-trunk/include/akonadi/contact/contactviewer.h
--- /opt/kde-stable/include/akonadi/contact/contactviewer.h	1970-01-01 01:00:00.000000000 +0100
+++ /opt/kde-trunk/include/akonadi/contact/contactviewer.h	2009-09-20 15:39:58.000000000 +0200
@@ -0,0 +1,148 @@
+/*
+    This file is part of Akonadi Contact.
+
+    Copyright (c) 2009 Tobias Koenig <tokoe@kde.org>
+
+    This library is free software; you can redistribute it and/or modify it
+    under the terms of the GNU Library General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or (at your
+    option) any later version.
+
+    This library is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
+    License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to the
+    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+    02110-1301, USA.
+*/
+
+#ifndef AKONADI_CONTACTVIEWER_H
+#define AKONADI_CONTACTVIEWER_H
+
+#include "akonadi-contact_export.h"
+
+#include <akonadi/itemmonitor.h>
+
+#include <QtGui/QWidget>
+
+class QUrl;
+
+namespace KABC {
+class Address;
+class PhoneNumber;
+}
+
+namespace Akonadi {
+
+/**
+ * @short A viewer component for contacts in Akonadi.
+ *
+ * This widgets provides a way to show a contact from the
+ * Akonadi storage.
+ *
+ * Example:
+ *
+ * @code
+ *
+ * using namespace Akonadi;
+ *
+ * const Item contact = ...
+ *
+ * ContactViewer *viewer = new ContactViewer( this );
+ * viewer->setContact( contact );
+ *
+ * @endcode
+ *
+ * @author Tobias Koenig <tokoe@kde.org>
+ * @since 4.4
+ */
+class AKONADI_CONTACT_EXPORT ContactViewer : public QWidget, public Akonadi::ItemMonitor
+{
+  Q_OBJECT
+
+  public:
+    /**
+     * Creates a new contact viewer.
+     *
+     * @param parent The parent widget.
+     */
+    ContactViewer( QWidget *parent = 0 );
+
+    /**
+     * Destroys the contact viewer.
+     */
+    ~ContactViewer();
+
+    /**
+     * Returns the contact that is currently displayed.
+     */
+    Akonadi::Item contact() const;
+
+  public Q_SLOTS:
+    /**
+     * Sets the @p contact that shall be displayed in the viewer.
+     */
+    void setContact( const Akonadi::Item &contact );
+
+  Q_SIGNALS:
+    /**
+     * This signal is emitted whenever the user has clicked on
+     * a url (e.g. homepage or blog url) in the viewer.
+     *
+     * @param url The url that has been clicked.
+     */
+    void urlClicked( const QUrl &url );
+
+    /**
+     * This signal is emitted whenever the user has clicked on
+     * an email address in the viewer.
+     *
+     * @param name The name of the contact.
+     * @param email The plain email address of the contact.
+     */
+    void emailClicked( const QString &name, const QString &email );
+
+    /**
+     * This signal is emitted whenever the user has clicked on a
+     * phone number (that includes fax numbers as well) in the viewer.
+     *
+     * @param number The corresponding phone number.
+     */
+    void phoneNumberClicked( const KABC::PhoneNumber &number );
+
+    /**
+     * This signal is emitted whenever the user has clicked on an
+     * address in the viewer.
+     *
+     * @param address The corresponding address.
+     */
+    void addressClicked( const KABC::Address &address );
+
+  private:
+    /**
+     * This method is called whenever the displayed contact has been changed.
+     */
+    virtual void itemChanged( const Item &contact );
+
+    /**
+     * This method is called whenever the displayed contact has been
+     * removed from Akonadi.
+     */
+    virtual void itemRemoved();
+
+  private:
+    //@cond PRIVATE
+    class Private;
+    Private* const d;
+
+    Q_PRIVATE_SLOT( d, void slotMailClicked( const QString&, const QString& ) )
+    Q_PRIVATE_SLOT( d, void slotUrlClicked( const QString& ) )
+    //@endcond
+};
+
+}
+
+#endif
diff -pubNr /opt/kde-stable/include/akonadi/control.h /opt/kde-trunk/include/akonadi/control.h
--- /opt/kde-stable/include/akonadi/control.h	2009-10-12 18:32:20.000000000 +0200
+++ /opt/kde-trunk/include/akonadi/control.h	2009-10-09 09:22:21.000000000 +0200
@@ -126,9 +126,6 @@ class AKONADI_EXPORT Control : public QO
      */
     Control();
 
-  private Q_SLOTS:
-    void cleanup();
-
   private:
     //@cond PRIVATE
     class Private;
@@ -137,6 +134,7 @@ class AKONADI_EXPORT Control : public QO
     Q_PRIVATE_SLOT( d, void serverStarted() )
     Q_PRIVATE_SLOT( d, void serverStopped() )
     Q_PRIVATE_SLOT( d, void createErrorOverlays() )
+    Q_PRIVATE_SLOT( d, void cleanup() )
     //@endcond
 };
 
diff -pubNr /opt/kde-stable/include/akonadi/entitydisplayattribute.h /opt/kde-trunk/include/akonadi/entitydisplayattribute.h
--- /opt/kde-stable/include/akonadi/entitydisplayattribute.h	2009-10-12 18:32:20.000000000 +0200
+++ /opt/kde-trunk/include/akonadi/entitydisplayattribute.h	2009-10-09 09:22:21.000000000 +0200
@@ -74,6 +74,21 @@ class AKONADI_EXPORT EntityDisplayAttrib
      */
     QString iconName() const;
 
+    /**
+     * Returns whether this object should be hidden. This is for purely view-based hiding,
+     * comparable to hidden files, the object will always be visible from the API POV.
+     * @since 4.4
+     */
+    bool isHidden() const;
+
+    /**
+     * Sets whether this object should be hidden.
+     * @param hide @c true to hide the object, @c false to show it
+     * @see isHidden
+     * @since 4.4
+     */
+    void setHidden( bool hide );
+
     /* reimpl */
     QByteArray type() const;
     EntityDisplayAttribute* clone() const;
diff -pubNr /opt/kde-stable/include/akonadi/entityfilterproxymodel.h /opt/kde-trunk/include/akonadi/entityfilterproxymodel.h
--- /opt/kde-stable/include/akonadi/entityfilterproxymodel.h	1970-01-01 01:00:00.000000000 +0100
+++ /opt/kde-trunk/include/akonadi/entityfilterproxymodel.h	2009-10-09 09:22:21.000000000 +0200
@@ -0,0 +1,162 @@
+/*
+    Copyright (c) 2007 Bruno Virlet <bruno.virlet@gmail.com>
+    Copyright (c) 2009 Stephen Kelly <steveire@gmail.com>
+
+    This library is free software; you can redistribute it and/or modify it
+    under the terms of the GNU Library General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or (at your
+    option) any later version.
+
+    This library is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
+    License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to the
+    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+    02110-1301, USA.
+*/
+
+#ifndef AKONADI_ENTITYFILTERPROXYMODEL_H
+#define AKONADI_ENTITYFILTERPROXYMODEL_H
+
+#include "akonadi_export.h"
+
+#include <QtGui/QSortFilterProxyModel>
+
+namespace Akonadi {
+
+class EntityFilterProxyModelPrivate;
+
+/**
+ * @short A proxy model that filters entities by mime type.
+ *
+ * This class can be used on top of an EntityTreeModel to exclude entities by mimetype
+ * or to include only certain mimetypes.
+ *
+ * @code
+ *
+ *   Akonadi::EntityTreeModel *model = new Akonadi::EntityTreeModel( this );
+ *
+ *   Akonadi::EntityFilterProxyModel *proxy = new Akonadi::EntityFilterProxyModel();
+ *   proxy->addMimeTypeInclusionFilter( "message/rfc822" );
+ *   proxy->setSourceModel( model );
+ *
+ *   Akonadi::EntityTreeView *view = new Akonadi::EntityTreeView( this );
+ *   view->setModel( proxy );
+ *
+ * @endcode
+ *
+ * @li If a mimetype is in both the exclusion list and the inclusion list, it is excluded.
+ * @li If the mimeTypeInclusionFilter is empty, all mimetypes are
+ *     accepted (except if they are in the exclusion filter of course).
+ *
+ *
+ * @author Bruno Virlet <bruno.virlet@gmail.com>
+ * @author Stephen Kelly <steveire@gmail.com>
+ * @since 4.4
+ */
+class AKONADI_EXPORT EntityFilterProxyModel : public QSortFilterProxyModel
+{
+  Q_OBJECT
+
+  public:
+    /**
+     * Creates a new proxy filter model.
+     *
+     * @param parent The parent object.
+     */
+    explicit EntityFilterProxyModel( QObject *parent = 0 );
+
+    /**
+     * Destroys the proxy filter model.
+     */
+    virtual ~EntityFilterProxyModel();
+
+    /**
+     * Add mime types to be shown by the filter.
+     *
+     * @param mimeTypes A list of mime types to be included.
+     */
+    void addMimeTypeInclusionFilters( const QStringList &mimeTypes );
+
+    /**
+     * Add mimetypes to filter out
+     *
+     * @param mimeTypes A list to exclude from the model.
+     */
+    void addMimeTypeExclusionFilters( const QStringList &mimeTypes );
+
+    /**
+     * Add mime type to be shown by the filter.
+     *
+     * @param mimeType A mime type to be shown.
+     */
+    void addMimeTypeInclusionFilter( const QString &mimeType );
+
+    /**
+     * Add mime type to be excluded by the filter.
+     *
+     * @param mimeType A mime type to be excluded.
+     */
+    void addMimeTypeExclusionFilter( const QString &mimeType );
+
+    /**
+     * Returns the list of mime type inclusion filters.
+     */
+    QStringList mimeTypeInclusionFilters() const;
+
+    /**
+     * Returns the list of mime type exclusion filters.
+     */
+    QStringList mimeTypeExclusionFilters() const;
+
+    /**
+     * Clear all mime type filters.
+     */
+    void clearFilters();
+
+    /**
+     * Sets the @p index that shall be used as the root for this model.
+     */
+    void setRootIndex( const QModelIndex &index );
+
+    /**
+     * Sets the header @p set of the filter model.
+     *
+     * \sa EntityTreeModel::HeaderGroup
+     */
+    void setHeaderSet( int set );
+
+    virtual QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const;
+
+    // QAbstractProxyModel does not proxy all methods...
+    virtual bool dropMimeData( const QMimeData * data, Qt::DropAction action, int row, int column, const QModelIndex & parent );
+    virtual QMimeData* mimeData( const QModelIndexList & indexes ) const;
+    virtual QStringList mimeTypes() const;
+
+    virtual bool hasChildren(const QModelIndex& parent = QModelIndex()) const;
+
+    virtual bool canFetchMore(const QModelIndex &parent) const;
+
+    /**
+      Reimplemented to handle the AmazingCompletionRole.
+    */
+    virtual QModelIndexList match( const QModelIndex& start, int role, const QVariant& value, int hits = 1, Qt::MatchFlags flags = Qt::MatchFlags( Qt::MatchStartsWith | Qt::MatchWrap ) ) const;
+
+    virtual int columnCount(const QModelIndex& parent = QModelIndex()) const;
+
+  protected:
+    virtual bool filterAcceptsRow( int sourceRow, const QModelIndex &sourceParent ) const;
+
+  private:
+    //@cond PRIVATE
+    Q_DECLARE_PRIVATE( EntityFilterProxyModel )
+    EntityFilterProxyModelPrivate * const d_ptr;
+    //@endcond
+};
+
+}
+
+#endif
diff -pubNr /opt/kde-stable/include/akonadi/entity.h /opt/kde-trunk/include/akonadi/entity.h
--- /opt/kde-stable/include/akonadi/entity.h	2009-10-12 18:32:20.000000000 +0200
+++ /opt/kde-trunk/include/akonadi/entity.h	2009-10-09 09:22:21.000000000 +0200
@@ -42,6 +42,7 @@ AKONADI_EXPORT uint qHash( const Akonadi
 
 namespace Akonadi {
 
+class Collection;
 class EntityPrivate;
 
 /**
@@ -110,6 +111,33 @@ class AKONADI_EXPORT Entity
     Entity& operator=( const Entity &other );
 
     /**
+     * Returns the parent collection of this object.
+     * @note This will of course only return a useful value if it was explictly retrieved
+     *       from the Akonadi server.
+     * @since 4.4
+     */
+    Collection parentCollection() const;
+
+    /**
+     * Returns a reference to the parent collection of this object.
+     * @note This will of course only return a useful value if it was explictly retrieved
+     *       from the Akonadi server.
+     * @since 4.4
+     */
+    Collection& parentCollection();
+
+    /**
+     * Set the parent collection of this object.
+     * @note Calling this method has no immediate effect for the object itself,
+     *       such as being moved to another collection.
+     *       It is mainly relevant to provide a context for RID-based operations
+     *       inside resources.
+     * @param parent The parent collection.
+     * @since 4.4
+     */
+    void setParentCollection( const Collection &parent );
+
+    /**
      * Adds an attribute to the entity.
      *
      * If an attribute of the same type name already exists, it is deleted and
diff -pubNr /opt/kde-stable/include/akonadi/entityhiddenattribute.h /opt/kde-trunk/include/akonadi/entityhiddenattribute.h
--- /opt/kde-stable/include/akonadi/entityhiddenattribute.h	1970-01-01 01:00:00.000000000 +0100
+++ /opt/kde-trunk/include/akonadi/entityhiddenattribute.h	2009-10-09 09:22:21.000000000 +0200
@@ -0,0 +1,83 @@
+/******************************************************************************
+ *
+ *  Copyright (c) 2009 Szymon Stefanek <s.stefanek at gmail dot com>
+ *
+ *  This library is free software; you can redistribute it and/or modify it
+ *  under the terms of the GNU Library General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or (at your
+ *  option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful, but WITHOUT
+ *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ *  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
+ *  License for more details.
+ *
+ *  You should have received a copy of the GNU Library General Public License
+ *  along with this library; see the file COPYING.LIB.  If not, write to the
+ *  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ *  MA, 02110-1301, USA.
+ *
+ *****************************************************************************/
+
+#ifndef AKONADI_ENTITYHIDDENATTRIBUTE_H
+#define AKONADI_ENTITYHIDDENATTRIBUTE_H
+
+#include <akonadi/attribute.h>
+
+namespace Akonadi {
+
+/**
+ * @short Attribute signalling that an entity should be hidden in the UI
+ *
+ * This class represents the attribute of all hidden items. The hidden
+ * items shouldn't be displayed in UI applications (unless in some kind
+ * of "debug" mode).
+ *
+ * @seealso Attribute
+ *
+ * @author Szymon Stefanek <s.stefanek@gmail.com>
+ * @since 4.4
+ */
+class AKONADI_EXPORT EntityHiddenAttribute : public Attribute
+{
+  public:
+    /**
+     * Creates a new entity hidden attribute.
+     */
+    EntityHiddenAttribute();
+
+    /**
+     * Destroys the entity hidden attribute.
+     */
+    ~EntityHiddenAttribute();
+
+    /**
+     * Reimplemented from Attribute
+     */
+    QByteArray type() const;
+
+    /**
+     * Reimplemented from Attribute
+     */
+    EntityHiddenAttribute* clone() const;
+
+    /**
+     * Reimplemented from Attribute
+     */
+    QByteArray serialized() const;
+
+    /**
+     * Reimplemented from Attribute
+     */
+    void deserialize( const QByteArray &data );
+
+  private:
+    //@cond PRIVATE
+    class Private;
+    Private* const d;
+    //@endcond
+};
+
+}
+
+#endif
diff -pubNr /opt/kde-stable/include/akonadi/entitytreemodel.h /opt/kde-trunk/include/akonadi/entitytreemodel.h
--- /opt/kde-stable/include/akonadi/entitytreemodel.h	1970-01-01 01:00:00.000000000 +0100
+++ /opt/kde-trunk/include/akonadi/entitytreemodel.h	2009-10-09 09:22:21.000000000 +0200
@@ -0,0 +1,372 @@
+/*
+    Copyright (c) 2008 Stephen Kelly <steveire@gmail.com>
+
+    This library is free software; you can redistribute it and/or modify it
+    under the terms of the GNU Library General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or (at your
+    option) any later version.
+
+    This library is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
+    License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to the
+    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+    02110-1301, USA.
+*/
+
+#ifndef AKONADI_ENTITYTREEMODEL_H
+#define AKONADI_ENTITYTREEMODEL_H
+
+#include "akonadi_export.h"
+
+#include <akonadi/collection.h>
+#include <akonadi/item.h>
+
+#include <QtCore/QAbstractItemModel>
+#include <QtCore/QStringList>
+
+Q_DECLARE_METATYPE( QSet<QByteArray> )
+
+// TODO (Applies to all these 'new' models, not just EntityTreeModel):
+// * Figure out how LazyPopulation and signals from monitor containing items should
+//     fit together. Possibly store a list of collections whose items have already
+//     been lazily fetched.
+// * Fgure out whether DescendantEntitiesProxyModel needs to use fetchMore.
+// * Profile this and DescendantEntitiesProxyModel. Make sure it's faster than
+//     FlatCollectionProxyModel. See if the cache in that class can be cleared less often.
+// * Unit tests. Much of the stuff here is not covered by modeltest, and some of
+//     it is akonadi specific, such as setting root collection etc.
+// * Implement support for includeUnsubscribed.
+// * Use CollectionStatistics for item count stuff. Find out if I can get stats by mimetype.
+// * Make sure there are applications using it before committing to it until KDE5.
+//     Some API/ virtual methods might need to be added when real applications are made.
+// * Implement ordering support.
+// * Implement some proxy models for time-table like uses, eg KOrganizer events.
+// * Apidox++
+
+namespace Akonadi
+{
+
+class ChangeRecorder;
+class CollectionStatistics;
+class Item;
+class ItemFetchScope;
+class Monitor;
+class Session;
+
+class EntityTreeModelPrivate;
+
+/**
+ * @short A model for collections and items together.
+ *
+ * This class is a wrapper around a Akonadi::Monitor object. The model represents a
+ * part of the collection and item tree configured in the Monitor.
+ *
+ * @code
+ *
+ *   ChangeRecorder *monitor = new ChangeRecorder(this);
+ *   monitor->setCollectionMonitored(Collection::root());
+ *   monitor->setMimeTypeMonitored(KABC::addresseeMimeType());
+ *
+ *   EntityTreeModel *model = new EntityTreeModel( session, monitor, this );
+ *
+ *   EntityTreeView *view = new EntityTreeView( this );
+ *   view->setModel( model );
+ *
+ * @endcode
+ *
+ * @author Stephen Kelly <steveire@gmail.com>
+ * @since 4.4
+ */
+class AKONADI_EXPORT EntityTreeModel : public QAbstractItemModel
+{
+  Q_OBJECT
+
+  public:
+    /**
+     * Describes the roles for items. Roles for collections are defined by the superclass.
+     */
+    enum Roles {
+      //sebsauer, 2009-05-07; to be able here to keep the akonadi_next EntityTreeModel compatible with
+      //the akonadi_old ItemModel and CollectionModel, we need to use the same int-values for
+      //ItemRole, ItemIdRole and MimeTypeRole like the Akonadi::ItemModel is using and the same
+      //CollectionIdRole and CollectionRole like the Akonadi::CollectionModel is using.
+      ItemIdRole = Qt::UserRole + 1,          ///< The item id
+      ItemRole = Qt::UserRole + 2,            ///< The Item
+      MimeTypeRole = Qt::UserRole + 3,        ///< The mimetype of the entity
+
+      CollectionIdRole = Qt::UserRole + 10,   ///< The collection id.
+      CollectionRole = Qt::UserRole + 11,     ///< The collection.
+
+      RemoteIdRole,                           ///< The remoteId of the entity
+      CollectionChildOrderRole,               ///< Ordered list of child items if available
+      AmazingCompletionRole,                  ///< Role used to implement amazing completion
+      ParentCollectionRole,                   ///< The parent collection of the entity
+      ColumnCountRole,                        ///< @internal Used by proxies to determine the number of columns for a header group.
+      LoadedPartsRole,                        ///< Parts available in the model for the item
+      AvailablePartsRole,                     ///< Parts available in the Akonadi server for the item
+      SessionRole,                            ///< @internal The Session used by this model
+      CollectionRefRole,                      ///< @internal Used to increase the reference count on a Collection
+      CollectionDerefRole,                    ///< @internal Used to decrease the reference count on a Collection
+      UserRole = Qt::UserRole + 1000,         ///< Role for user extensions.
+      TerminalUserRole = 10000                ///< Last role for user extensions. Don't use a role beyond this or headerData will break.
+    };
+
+    /**
+     * Describes what header information the model shall return.
+     */
+    enum HeaderGroup {
+      EntityTreeHeaders,      ///< Header information for a tree with collections and items
+      CollectionTreeHeaders,  ///< Header information for a collection-only tree
+      ItemListHeaders,        ///< Header information for a list of items
+      UserHeaders = 1000      ///< Last header information for submodel extensions
+    };
+
+    /**
+     * Creates a new entity tree model.
+     *
+     * @param session The Session to use to communicate with Akonadi.
+     * @param monitor The ChangeRecorder whose entities should be represented in the model.
+     * @param parent The parent object.
+     */
+    EntityTreeModel( Session *session, ChangeRecorder *monitor, QObject *parent = 0 );
+
+    /**
+     * Destroys the entity tree model.
+     */
+    virtual ~EntityTreeModel();
+
+    /**
+     * Describes how the model should populated its items.
+     */
+    enum ItemPopulationStrategy {
+      NoItemPopulation,    ///< Do not include items in the model.
+      ImmediatePopulation, ///< Retrieve items immediately when their parent is in the model. This is the default.
+      LazyPopulation       ///< Fetch items only when requested (using canFetchMore/fetchMore)
+    };
+
+    /**
+      Some Entities are hidden in the model, but exist for internal purposes, for example, custom object
+      directories in groupware resources.
+
+      They are hidden by default, but can be shown by setting @p show to true.
+
+      Most applications will not need to use this feature.
+    */
+    void setShowSystemEntities( bool show );
+
+    /**
+      @returns True if internal system entities are shown, and false otherwise.
+    */
+    bool systemEntitiesShown() const;
+
+    /**
+     * Sets the item population @p strategy of the model.
+     */
+    void setItemPopulationStrategy( ItemPopulationStrategy strategy );
+
+    /**
+     * Returns the item population strategy of the model.
+     */
+    ItemPopulationStrategy itemPopulationStrategy() const;
+
+    /**
+     * Sets the root collection to create an entity tree for.
+     * The @p collection must be a valid Collection object.
+     *
+     * By default the Collection::root() is used.
+     */
+    void setRootCollection( const Collection &collection );
+
+    /**
+     * Returns the root collection of the entity tree.
+     */
+    Collection rootCollection() const;
+
+    /**
+     * Sets whether the root collection shall be provided by the model.
+     *
+     * @see setRootCollectionDisplayName()
+     */
+    void setIncludeRootCollection( bool include );
+
+    /**
+     * Returns whether the root collection is provided by the model.
+     */
+    bool includeRootCollection() const;
+
+    /**
+     * Sets the display @p name of the root collection of the model.
+     * The default display name is "[*]".
+     *
+     * @note The display name for the root collection is only used if
+     *       the root collection has been included with setIncludeRootCollection().
+     */
+    void setRootCollectionDisplayName( const QString &name );
+
+    /**
+     * Returns the display name of the root collection.
+     */
+    QString rootCollectionDisplayName() const;
+
+    /**
+     * Describes what collections shall be fetched by and represent in the model.
+     */
+    enum CollectionFetchStrategy {
+      FetchNoCollections,               ///< Fetches nothing. This creates an empty model.
+      FetchFirstLevelChildCollections,  ///< Fetches first level collections in the root collection.
+      FetchCollectionsRecursive         ///< Fetches collections in the root collection recursively. This is the default.
+    };
+
+    /**
+     * Sets the collection fetch @p strategy of the model.
+     */
+    void setCollectionFetchStrategy( CollectionFetchStrategy strategy );
+
+    /**
+     * Returns the collection fetch strategy of the model.
+     */
+    CollectionFetchStrategy collectionFetchStrategy() const;
+
+    /**
+     * Returns the model index for the given @p collection.
+     */
+    QModelIndex indexForCollection( const Collection &collection ) const;
+
+    /**
+     * Returns the model indexes for the given @p item.
+     */
+    QModelIndexList indexesForItem( const Item &item ) const;
+
+    /**
+     * Returns the collection for the given collection @p id.
+     */
+    Collection collectionForId( Collection::Id id ) const;
+
+    /**
+     * Returns the item for the given item @p id.
+     */
+    Item itemForId( Item::Id id ) const;
+
+    // TODO: Remove these and use the Monitor instead. Need to add api to Monitor for this.
+    void setIncludeUnsubscribed( bool include );
+    bool includeUnsubscribed() const;
+
+    virtual int columnCount( const QModelIndex & parent = QModelIndex() ) const;
+    virtual int rowCount( const QModelIndex & parent = QModelIndex() ) const;
+
+    virtual QVariant data( const QModelIndex & index, int role = Qt::DisplayRole ) const;
+    virtual QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const;
+
+    virtual Qt::ItemFlags flags( const QModelIndex &index ) const;
+    virtual QStringList mimeTypes() const;
+
+    virtual Qt::DropActions supportedDropActions() const;
+    virtual QMimeData *mimeData( const QModelIndexList &indexes ) const;
+    virtual bool dropMimeData( const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent );
+    virtual bool setData( const QModelIndex &index, const QVariant &value, int role = Qt::EditRole );
+
+    virtual QModelIndex index( int row, int column, const QModelIndex & parent = QModelIndex() ) const;
+    virtual QModelIndex parent( const QModelIndex & index ) const;
+
+    // TODO: Review the implementations of these. I think they could be better.
+    virtual bool canFetchMore( const QModelIndex & parent ) const;
+    virtual void fetchMore( const QModelIndex & parent );
+    virtual bool hasChildren( const QModelIndex &parent = QModelIndex() ) const;
+
+    /**
+     * Reimplemented to handle the AmazingCompletionRole.
+     */
+    virtual QModelIndexList match( const QModelIndex& start, int role, const QVariant& value, int hits = 1, Qt::MatchFlags flags = Qt::MatchFlags( Qt::MatchStartsWith | Qt::MatchWrap ) ) const;
+
+    /**
+     * Reimplement this in a subclass to return true if @p item matches @p value with @p flags in the AmazingCompletionRole.
+     */
+    virtual bool match( const Item &item, const QVariant &value, Qt::MatchFlags flags ) const;
+
+    /**
+     * Reimplement this in a subclass to return true if @p collection matches @p value with @p flags in the AmazingCompletionRole.
+     */
+    virtual bool match( const Collection &collection, const QVariant &value, Qt::MatchFlags flags ) const;
+
+  protected:
+    /**
+     * Clears and resets the model. Always call this instead of the reset method in the superclass.
+     * Using the reset method will not reliably clear or refill the model.
+     */
+    void clearAndReset();
+
+    /**
+     * Provided for convenience of subclasses.
+     */
+    virtual QVariant getData( const Item &item, int column, int role = Qt::DisplayRole ) const;
+
+    /**
+     * Provided for convenience of subclasses.
+     */
+    virtual QVariant getData( const Collection &collection, int column, int role = Qt::DisplayRole ) const;
+
+    /**
+     * Reimplement this to provide different header data. This is needed when using one model
+     * with multiple proxies and views, and each should show different header data.
+     */
+    virtual QVariant getHeaderData( int section, Qt::Orientation orientation, int role, int headerSet ) const;
+
+    virtual int getColumnCount(int headerSet) const;
+
+    /**
+     * Removes the rows from @p start to @p end from @parent
+     */
+    virtual bool removeRows( int start, int end, const QModelIndex &parent = QModelIndex() );
+
+  private:
+    //@cond PRIVATE
+    Q_DECLARE_PRIVATE( EntityTreeModel )
+    EntityTreeModelPrivate * const d_ptr;
+
+    // Make these private, they shouldn't be called by applications
+    virtual bool insertRows( int , int, const QModelIndex& = QModelIndex() );
+    virtual bool insertColumns( int, int, const QModelIndex& = QModelIndex() );
+    virtual bool removeColumns( int, int, const QModelIndex& = QModelIndex() );
+
+    Q_PRIVATE_SLOT( d_func(), void monitoredCollectionStatisticsChanged( Akonadi::Collection::Id,
+                                                                         const Akonadi::CollectionStatistics& ) )
+
+    Q_PRIVATE_SLOT( d_func(), void startFirstListJob() )
+    // Q_PRIVATE_SLOT( d_func(), void slotModelReset() )
+
+    // TODO: Can I merge these into one jobResult slot?
+    Q_PRIVATE_SLOT( d_func(), void fetchJobDone( KJob *job ) )
+    Q_PRIVATE_SLOT( d_func(), void pasteJobDone( KJob *job ) )
+    Q_PRIVATE_SLOT( d_func(), void updateJobDone( KJob *job ) )
+
+    Q_PRIVATE_SLOT( d_func(), void itemsFetched( Akonadi::Item::List ) )
+    Q_PRIVATE_SLOT( d_func(), void collectionsFetched( Akonadi::Collection::List ) )
+    Q_PRIVATE_SLOT( d_func(), void topLevelCollectionsFetched( Akonadi::Collection::List ) )
+    Q_PRIVATE_SLOT( d_func(), void ancestorsFetched( Akonadi::Collection::List ) )
+
+    Q_PRIVATE_SLOT( d_func(), void monitoredMimeTypeChanged( const QString&, bool ) )
+
+    Q_PRIVATE_SLOT( d_func(), void monitoredCollectionAdded( const Akonadi::Collection&, const Akonadi::Collection& ) )
+    Q_PRIVATE_SLOT( d_func(), void monitoredCollectionRemoved( const Akonadi::Collection& ) )
+    Q_PRIVATE_SLOT( d_func(), void monitoredCollectionChanged( const Akonadi::Collection& ) )
+    Q_PRIVATE_SLOT( d_func(), void monitoredCollectionMoved( const Akonadi::Collection&, const Akonadi::Collection&,
+                                                             const Akonadi::Collection&) )
+
+    Q_PRIVATE_SLOT( d_func(), void monitoredItemAdded( const Akonadi::Item&, const Akonadi::Collection& ) )
+    Q_PRIVATE_SLOT( d_func(), void monitoredItemRemoved( const Akonadi::Item& ) )
+    Q_PRIVATE_SLOT( d_func(), void monitoredItemChanged( const Akonadi::Item&, const QSet<QByteArray>& ) )
+    Q_PRIVATE_SLOT( d_func(), void monitoredItemMoved( const Akonadi::Item&, const Akonadi::Collection&,
+                                                       const Akonadi::Collection& ) )
+
+    Q_PRIVATE_SLOT( d_func(), void monitoredItemLinked( const Akonadi::Item&, const Akonadi::Collection& ) )
+    Q_PRIVATE_SLOT( d_func(), void monitoredItemUnlinked( const Akonadi::Item&, const Akonadi::Collection& ) )
+    //@endcond
+};
+
+} // namespace
+
+#endif
diff -pubNr /opt/kde-stable/include/akonadi/entitytreeview.h /opt/kde-trunk/include/akonadi/entitytreeview.h
--- /opt/kde-stable/include/akonadi/entitytreeview.h	1970-01-01 01:00:00.000000000 +0100
+++ /opt/kde-trunk/include/akonadi/entitytreeview.h	2009-10-09 09:22:21.000000000 +0200
@@ -0,0 +1,180 @@
+/*
+    Copyright (c) 2006 - 2007 Volker Krause <vkrause@kde.org>
+    Copyright (c) 2008 Stephen Kelly <steveire@gmail.com>
+
+    This library is free software; you can redistribute it and/or modify it
+    under the terms of the GNU Library General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or (at your
+    option) any later version.
+
+    This library is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
+    License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to the
+    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+    02110-1301, USA.
+*/
+
+#ifndef AKONADI_ENTITY_TREE_VIEW
+#define AKONADI_ENTITY_TREE_VIEW
+
+#include "akonadi_export.h"
+
+#include <QtGui/QTreeView>
+
+class KXMLGUIClient;
+class QDragMoveEvent;
+
+namespace Akonadi
+{
+
+class Collection;
+class Item;
+
+/**
+ * @short A view to show a collection tree provided by a CollectionModel.
+ *
+ * When a KXmlGuiWindow is passed to the constructor, the XMLGUI
+ * defined context menu @c akonadi_collectionview_contextmenu is
+ * used if available.
+ *
+ * Example:
+ *
+ * @code
+ *
+ * class MyWindow : public KXmlGuiWindow
+ * {
+ *   public:
+ *    MyWindow()
+ *      : KXmlGuiWindow()
+ *    {
+ *      Akonadi::CollectionView *view = new Akonadi::CollectionView( this, this );
+ *      setCentralWidget( view );
+ *
+ *      Akonadi::CollectionModel *model = new Akonadi::CollectionModel( this );
+ *      view->setModel( model );
+ *    }
+ * }
+ *
+ * @endcode
+ *
+ * @author Volker Krause <vkrause@kde.org>
+ * @author Stephen Kelly <steveire@gmail.com>
+ * @since 4.4
+ */
+class AKONADI_EXPORT EntityTreeView : public QTreeView
+{
+  Q_OBJECT
+
+  public:
+    /**
+     * Creates a new entity tree view.
+     *
+     * @param parent The parent widget.
+     */
+    explicit EntityTreeView( QWidget *parent = 0 );
+
+    /**
+     * Creates a new entity tree view.
+     *
+     * @param xmlGuiClient The KXMLGUIClient the view is used in.
+     *                     This is needed for the XMLGUI based context menu.
+     *                     Passing 0 is ok and will disable the builtin context menu.
+     * @param parent The parent widget.
+     */
+    explicit EntityTreeView( KXMLGUIClient *xmlGuiClient, QWidget *parent = 0 );
+
+    /**
+     * Destroys the entity tree view.
+     */
+    virtual ~EntityTreeView();
+
+    /**
+     * Sets the XML GUI client which the view is used in.
+     *
+     * This is needed if you want to use the built-in context menu.
+     *
+     * @param xmlGuiClient The KXMLGUIClient the view is used in.
+     */
+    void setXmlGuiClient( KXMLGUIClient *xmlGuiClient );
+
+    /**
+     * @reimplemented
+     */
+    virtual void setModel( QAbstractItemModel * model );
+
+  Q_SIGNALS:
+    /**
+     * This signal is emitted whenever the user has clicked
+     * a collection in the view.
+     *
+     * @param collection The clicked collection.
+     */
+    void clicked( const Akonadi::Collection &collection );
+
+    /**
+     * This signal is emitted whenever the user has clicked
+     * an item in the view.
+     *
+     * @param item The clicked item.
+     */
+    void clicked( const Akonadi::Item &item );
+
+    /**
+     * This signal is emitted whenever the user has double clicked
+     * a collection in the view.
+     *
+     * @param collection The double clicked collection.
+     */
+    void doubleClicked( const Akonadi::Collection &collection );
+
+    /**
+     * This signal is emitted whenever the user has double clicked
+     * an item in the view.
+     *
+     * @param item The double clicked item.
+     */
+    void doubleClicked( const Akonadi::Item &item );
+
+    /**
+     * This signal is emitted whenever the current collection
+     * in the view has changed.
+     *
+     * @param collection The new current collection.
+     */
+    void currentChanged( const Akonadi::Collection &collection );
+
+    /**
+     * This signal is emitted whenever the current item
+     * in the view has changed.
+     *
+     * @param item The new current item.
+     */
+    void currentChanged( const Akonadi::Item &item );
+
+  protected:
+    using QTreeView::currentChanged;
+    virtual void dragMoveEvent( QDragMoveEvent *event );
+    virtual void timerEvent( QTimerEvent *event );
+    virtual void dropEvent( QDropEvent *event );
+    virtual void contextMenuEvent( QContextMenuEvent *event );
+    virtual void startDrag( Qt::DropActions supportedActions );
+
+  private:
+    //@cond PRIVATE
+    class Private;
+    Private * const d;
+
+    Q_PRIVATE_SLOT( d, void itemClicked( const QModelIndex& ) )
+    Q_PRIVATE_SLOT( d, void itemDoubleClicked( const QModelIndex& ) )
+    Q_PRIVATE_SLOT( d, void itemCurrentChanged( const QModelIndex& ) )
+    Q_PRIVATE_SLOT( d, void slotSelectionChanged( const QItemSelection &, const QItemSelection & ) )
+    //@endcond
+};
+
+}
+
+#endif
diff -pubNr /opt/kde-stable/include/akonadi/entitytreeviewstatesaver.h /opt/kde-trunk/include/akonadi/entitytreeviewstatesaver.h
--- /opt/kde-stable/include/akonadi/entitytreeviewstatesaver.h	1970-01-01 01:00:00.000000000 +0100
+++ /opt/kde-trunk/include/akonadi/entitytreeviewstatesaver.h	2009-10-09 09:22:21.000000000 +0200
@@ -0,0 +1,130 @@
+/*
+    Copyright (c) 2009 Volker Krause <vkrause@kde.org>
+
+    This library is free software; you can redistribute it and/or modify it
+    under the terms of the GNU Library General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or (at your
+    option) any later version.
+
+    This library is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
+    License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to the
+    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+    02110-1301, USA.
+*/
+
+#ifndef AKONADI_ENTITYTREEVIEWSTATESAVER_H
+#define AKONADI_ENTITYTREEVIEWSTATESAVER_H
+
+#include "akonadi_export.h"
+
+#include <QtCore/QObject>
+
+class QTreeView;
+class KConfigGroup;
+
+namespace Akonadi {
+
+class EntityTreeViewStateSaverPrivate;
+
+/**
+ * @short A helper class that saves and restores state of an EntityTreeView
+ *
+ * This class saves and restores the state of a QTreeView showing an EntityTreeModel,
+ * or whatever proxies are stacked on top of one. State so far means the current selection
+ * and expansion of the items and collections.
+ *
+ * The EntityTreeViewStateSaver is needed because populating the EntityTreeModel
+ * is asynchronous and finding the right point in time to restore the state is a
+ * difficult task that is hidden inside this class.
+ *
+ * Example:
+ *
+ * @code
+ *
+ * class MyWidget : public QWidget
+ * {
+ *   public:
+ *      MyWidget( QWidget* parent );
+ *      ~MyWidget();
+ *
+ *      ...
+ *
+ *   private:
+ *     KConfig *mGlobalConfig;
+ *     QTreeView *mTreeView;
+ *     Akonadi::EntityTreeViewStateSaver *mStateSaver;
+ * };
+ *
+ * MyWidget::MyWidget( QWidget *parent )
+ *   : QWidget( parent )
+ * {
+ *   mGlobalConfig = ...
+ *   mTreeView = new QTreeView( this );
+ *   ...
+ *
+ *   mStateSaver = new Akonadi::EntityTreeViewStateSaver( mTreeView );
+ *
+ *   KConfigGroup group( mGlobalConfig, "treeViewState" );
+ *   mStateSaver->restoreState( group );
+ * }
+ *
+ * MyWidget::~MyWidget()
+ * {
+ *   KConfigGroup group( mGlobalConfig, "treeViewState" );
+ *   mStateSaver->saveState( group );
+ * }
+ *
+ * @endcode
+ *
+ * @author Volker Krause <vkrause@kde.org>
+ * @since 4.4
+ */
+class AKONADI_EXPORT EntityTreeViewStateSaver : public QObject
+{
+  Q_OBJECT
+
+  public:
+    /**
+     * Creates a new state saver, for saving or restoring.
+     *
+     * @param view The QTreeView which state should be saved/restored.
+     */
+    EntityTreeViewStateSaver( QTreeView* view );
+
+    /**
+     * Destroys this state saver.
+     */
+    ~EntityTreeViewStateSaver();
+
+    /**
+     * Stores the current state in the given config group.
+     *
+     * @param configGroup Config file group into which the state is supposed to be stored.
+     */
+    void saveState( KConfigGroup &configGroup ) const;
+
+    /**
+     * Restore the state stored in @p configGroup as soon as the corresponding entities
+     * become available in the model (the model is populated asynchronously, which is the
+     * main reason why you want to use this class).
+     *
+     * @param configGroup Config file group containing a previously stored ETM state.
+     */
+    void restoreState( const KConfigGroup &configGroup ) const;
+
+  private:
+    //@cond PRIVATE
+    EntityTreeViewStateSaverPrivate* const d;
+    Q_PRIVATE_SLOT( d, void rowsInserted( const QModelIndex&, int, int ) )
+    Q_PRIVATE_SLOT( d, void restoreScrollBarState() )
+    //@endcond PRIVATE
+};
+
+}
+
+#endif
diff -pubNr /opt/kde-stable/include/akonadi/favoritecollectionsmodel.h /opt/kde-trunk/include/akonadi/favoritecollectionsmodel.h
--- /opt/kde-stable/include/akonadi/favoritecollectionsmodel.h	1970-01-01 01:00:00.000000000 +0100
+++ /opt/kde-trunk/include/akonadi/favoritecollectionsmodel.h	2009-10-09 09:22:21.000000000 +0200
@@ -0,0 +1,84 @@
+/*
+    Copyright (c) 2009 Kevin Ottens <ervin@kde.org>
+
+    This library is free software; you can redistribute it and/or modify it
+    under the terms of the GNU Library General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or (at your
+    option) any later version.
+
+    This library is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
+    License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to the
+    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+    02110-1301, USA.
+*/
+
+#ifndef AKONADI_FAVORITECOLLECTIONSMODEL_H
+#define AKONADI_FAVORITECOLLECTIONSMODEL_H
+
+#include "akonadi_export.h"
+
+#include <akonadi/selectionproxymodel.h>
+
+#include <akonadi/collection.h>
+
+namespace Akonadi {
+
+class EntityTreeModel;
+
+/**
+ * @short A model that lists a set of favorite collections.
+ *
+ * @author Kevin Ottens <ervin@kde.org>
+ * @since 4.4
+ */
+class AKONADI_EXPORT FavoriteCollectionsModel : public Akonadi::SelectionProxyModel
+{
+  Q_OBJECT
+
+  public:
+    /**
+     * Creates a new model listing a chosen set of favorite collections.
+     *
+     * @param parent The parent object.
+     */
+    explicit FavoriteCollectionsModel( EntityTreeModel *source, QObject *parent = 0 );
+
+    /**
+     * Destroys the favorite collections model.
+     */
+    virtual ~FavoriteCollectionsModel();
+
+    /**
+     * Returns the list of favorite collections.
+     */
+    Collection::List collections() const;
+
+    virtual QVariant data( const QModelIndex & index, int role = Qt::DisplayRole ) const;
+    virtual QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const;
+
+  public Q_SLOTS:
+    void setCollections( const Collection::List &collections );
+    void addCollection( const Collection &collection );
+    void removeCollection( const Collection &collection );
+    void setFavoriteLabel( const Collection &collection, const QString &label );
+
+  private:
+    using KSelectionProxyModel::setSourceModel;
+
+    Q_PRIVATE_SLOT( d, void clearAndUpdateSelection() )
+    Q_PRIVATE_SLOT( d, void updateSelection() )
+
+    //@cond PRIVATE
+    class Private;
+    Private* const d;
+    //@endcond
+};
+
+}
+
+#endif
diff -pubNr /opt/kde-stable/include/akonadi/favoritecollectionsview.h /opt/kde-trunk/include/akonadi/favoritecollectionsview.h
--- /opt/kde-stable/include/akonadi/favoritecollectionsview.h	1970-01-01 01:00:00.000000000 +0100
+++ /opt/kde-trunk/include/akonadi/favoritecollectionsview.h	2009-10-09 09:22:21.000000000 +0200
@@ -0,0 +1,163 @@
+/*
+    Copyright (c) 2006 - 2007 Volker Krause <vkrause@kde.org>
+    Copyright (c) 2008 Stephen Kelly <steveire@gmail.com>
+    Copyright (c) 2009 Kevin Ottens <ervin@kde.org>
+
+    This library is free software; you can redistribute it and/or modify it
+    under the terms of the GNU Library General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or (at your
+    option) any later version.
+
+    This library is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
+    License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to the
+    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+    02110-1301, USA.
+*/
+
+#ifndef AKONADI_FAVORITE_COLLECTIONS_VIEW
+#define AKONADI_FAVORITE_COLLECTIONS_VIEW
+
+#include "akonadi_export.h"
+
+#include <QtGui/QListView>
+
+class KXMLGUIClient;
+class QDragMoveEvent;
+
+namespace Akonadi
+{
+
+class Collection;
+class Item;
+
+/**
+ * @short A view to show a list of collections provided by a FavoriteCollectionsModel.
+ *
+ * When a KXmlGuiWindow is passed to the constructor, the XMLGUI
+ * defined context menu @c akonadi_collectionview_contextmenu is
+ * used if available.
+ *
+ * Example:
+ *
+ * @code
+ *
+ * class MyWindow : public KXmlGuiWindow
+ * {
+ *   public:
+ *    MyWindow()
+ *      : KXmlGuiWindow()
+ *    {
+ *      Akonadi::FavoriteCollectionsView *view = new Akonadi::FavoriteCollectionsView( this, this );
+ *      setCentralWidget( view );
+ *
+ *      Akonadi::FavoriteCollectionsModel *model = new Akonadi::FavoriteCollectionsModel( ... );
+ *      view->setModel( model );
+ *    }
+ * }
+ *
+ * @endcode
+ *
+ * @author Volker Krause <vkrause@kde.org>
+ * @author Stephen Kelly <steveire@gmail.com>
+ * @since 4.4
+ */
+class AKONADI_EXPORT FavoriteCollectionsView : public QListView
+{
+  Q_OBJECT
+
+  public:
+    /**
+     * Creates a new favorite collections view.
+     *
+     * @param parent The parent widget.
+     */
+    explicit FavoriteCollectionsView( QWidget *parent = 0 );
+
+    /**
+     * Creates a new favorite collections view.
+     *
+     * @param xmlGuiClient The KXMLGUIClient the view is used in.
+     *                     This is needed for the XMLGUI based context menu.
+     *                     Passing 0 is ok and will disable the builtin context menu.
+     * @param parent The parent widget.
+     */
+    explicit FavoriteCollectionsView( KXMLGUIClient *xmlGuiClient, QWidget *parent = 0 );
+
+    /**
+     * Destroys the favorite collections view.
+     */
+    virtual ~FavoriteCollectionsView();
+
+    /**
+     * Sets the XML GUI client which the view is used in.
+     *
+     * This is needed if you want to use the built-in context menu.
+     *
+     * @param xmlGuiClient The KXMLGUIClient the view is used in.
+     */
+    void setXmlGuiClient( KXMLGUIClient *xmlGuiClient );
+
+    /**
+     * @reimplemented
+     */
+    virtual void setModel( QAbstractItemModel * model );
+
+  Q_SIGNALS:
+    /**
+     * This signal is emitted whenever the user has clicked
+     * a collection in the view.
+     *
+     * @param collection The clicked collection.
+     */
+    void clicked( const Akonadi::Collection &collection );
+
+    /**
+     * This signal is emitted whenever the user has double clicked
+     * a collection in the view.
+     *
+     * @param collection The double clicked collection.
+     */
+    void doubleClicked( const Akonadi::Collection &collection );
+
+    /**
+     * This signal is emitted whenever the current collection
+     * in the view has changed.
+     *
+     * @param collection The new current collection.
+     */
+    void currentChanged( const Akonadi::Collection &collection );
+
+    /**
+     * This signal is emitted whenever the current item
+     * in the view has changed.
+     *
+     * @param item The new current item.
+     */
+    void currentChanged( const Akonadi::Item &item );
+
+  protected:
+    using QListView::currentChanged;
+    virtual void dragMoveEvent( QDragMoveEvent *event );
+    virtual void dropEvent( QDropEvent *event );
+    virtual void contextMenuEvent( QContextMenuEvent *event );
+    virtual void startDrag( Qt::DropActions supportedActions );
+
+  private:
+    //@cond PRIVATE
+    class Private;
+    Private * const d;
+
+    Q_PRIVATE_SLOT( d, void itemClicked( const QModelIndex& ) )
+    Q_PRIVATE_SLOT( d, void itemDoubleClicked( const QModelIndex& ) )
+    Q_PRIVATE_SLOT( d, void itemCurrentChanged( const QModelIndex& ) )
+    //@endcond
+};
+
+}
+
+#endif
diff -pubNr /opt/kde-stable/include/akonadi/filteractionjob.h /opt/kde-trunk/include/akonadi/filteractionjob.h
--- /opt/kde-stable/include/akonadi/filteractionjob.h	1970-01-01 01:00:00.000000000 +0100
+++ /opt/kde-trunk/include/akonadi/filteractionjob.h	2009-10-09 09:22:21.000000000 +0200
@@ -0,0 +1,176 @@
+/*
+    Copyright (c) 2009 Constantin Berzan <exit3219@gmail.com>
+
+    This library is free software; you can redistribute it and/or modify it
+    under the terms of the GNU Library General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or (at your
+    option) any later version.
+
+    This library is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
+    License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to the
+    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+    02110-1301, USA.
+*/
+
+#ifndef AKONADI_FILTERACTIONJOB_H
+#define AKONADI_FILTERACTIONJOB_H
+
+#include "item.h"
+#include "transactionsequence.h"
+
+namespace Akonadi {
+
+class Collection;
+class ItemFetchScope;
+class Job;
+
+/**
+ * @short Base class for a filter/action for FilterActionJob.
+ *
+ * Abstract class defining an interface for a filter and an action for
+ * FilterActionJob.  The virtual methods must be implemented in subclasses.
+ *
+ * @code
+ * class ClearErrorAction : public Akonadi::FilterAction
+ * {
+ *   public:
+ *     // reimpl
+ *     virtual Akonadi::ItemFetchScope fetchScope() const
+ *     {
+ *       ItemFetchScope scope;
+ *       scope.fetchFullPayload( false );
+ *       scope.fetchAttribute<ErrorAttribute>();
+ *       return scope;
+ *     }
+ *
+ *     virtual bool itemAccepted( const Akonadi::Item &item ) const
+ *     {
+ *       return item.hasAttribute<ErrorAttribute>();
+ *     }
+ *
+ *     virtual Akonadi::Job *itemAction( const Akonadi::Item &item ) const
+ *     {
+ *       Item cp = item;
+ *       cp.removeAttribute<ErrorAttribute>();
+ *       return new ItemModifyJob( cp );
+ *     }
+ * };
+ * @endcode
+ *
+ * @see FilterActionJob
+ *
+ * @author Constantin Berzan <exit3219@gmail.com>
+ * @since 4.4
+ */
+class AKONADI_EXPORT FilterAction
+{
+  public:
+    /**
+     * Destroys this filter action.
+     *
+     * A FilterActionJob will delete its FilterAction automatically.
+     */
+    virtual ~FilterAction();
+
+    /**
+     * Returns an ItemFetchScope to use if the FilterActionJob needs
+     * to fetch the items from a collection.
+     *
+     * @note The items are not fetched unless FilterActionJob is
+     *       constructed with a Collection parameter.
+     */
+    virtual Akonadi::ItemFetchScope fetchScope() const = 0;
+
+    /**
+     * Returns @c true if the @p item is accepted by the filter and should be
+     * acted upon by the FilterActionJob.
+     */
+    virtual bool itemAccepted( const Akonadi::Item &item ) const = 0;
+
+    /**
+     * Returns a job to act on the @p item.
+     * The FilterActionJob will finish when all such jobs are finished.
+     */
+    virtual Akonadi::Job *itemAction( const Akonadi::Item &item ) const = 0;
+};
+
+/**
+ * @short Job to filter and apply an action on a set of items.
+ *
+ * This jobs filters through a set of items, and applies an action to the
+ * items which are accepted by the filter.  The filter and action
+ * are provided by a functor class derived from FilterAction.
+ *
+ * For example, a MarkAsRead action/filter may be used to mark all messages
+ * in a folder as read.
+ *
+ * @code
+ * FilterActionJob *mjob = new FilterActionJob( LocalFolders::self()->outbox(),
+ *                                              new ClearErrorAction, this );
+ * connect( mjob, SIGNAL( result( KJob* ) ), this, SLOT( massModifyResult( KJob* ) ) );
+ * @endcode
+ *
+ * @see FilterAction
+ *
+ * @author Constantin Berzan <exit3219@gmail.com>
+ * @since 4.4
+ */
+class AKONADI_EXPORT FilterActionJob : public TransactionSequence
+{
+  Q_OBJECT
+
+  public:
+    /**
+     * Creates a filter action job to act on a single item.
+     *
+     * @param item The item to act on. The item is not re-fetched.
+     * @param functor The FilterAction to use.
+     * @param parent The parent object.
+     */
+    FilterActionJob( const Item &item, FilterAction *functor, QObject *parent = 0 );
+
+    /**
+     * Creates a filter action job to act on a set of items.
+     *
+     * @param items The items to act on. The items are not re-fetched.
+     * @param functor The FilterAction to use.
+     * @param parent The parent object.
+     */
+    FilterActionJob( const Item::List &items, FilterAction *functor, QObject *parent = 0 );
+
+    /**
+     * Creates a filter action job to act on items in a collection.
+     *
+     * @param collection The collection to act on.
+     *                   The items of the collection are fetched using functor->fetchScope().
+     * @param functor The FilterAction to use.
+     * @param parent The parent object.
+     */
+    FilterActionJob( const Collection &collection, FilterAction *functor, QObject *parent = 0 );
+
+    /**
+     * Destroys the filter action job.
+     */
+    ~FilterActionJob();
+
+  protected:
+    /* reimpl */
+    virtual void doStart();
+
+  private:
+    //@cond PRIVATE
+    class Private;
+    Private *const d;
+
+    Q_PRIVATE_SLOT( d, void fetchResult( KJob* ) )
+    //@endcond
+};
+
+} // namespace Akonadi
+
+#endif // AKONADI_FILTERACTIONJOB_H
diff -pubNr /opt/kde-stable/include/akonadi/itemdeletejob.h /opt/kde-trunk/include/akonadi/itemdeletejob.h
--- /opt/kde-stable/include/akonadi/itemdeletejob.h	2009-10-12 18:32:20.000000000 +0200
+++ /opt/kde-trunk/include/akonadi/itemdeletejob.h	2009-10-09 09:22:21.000000000 +0200
@@ -105,6 +105,12 @@ class AKONADI_EXPORT ItemDeleteJob : pub
      */
     ~ItemDeleteJob();
 
+    /**
+     * Returns the items passed on in the constructor.
+     * @since 4.4
+     */
+     Item::List deletedItems() const;
+
   protected:
     virtual void doStart();
 
diff -pubNr /opt/kde-stable/include/akonadi/itemfetchjob.h /opt/kde-trunk/include/akonadi/itemfetchjob.h
--- /opt/kde-stable/include/akonadi/itemfetchjob.h	2009-10-12 18:32:20.000000000 +0200
+++ /opt/kde-trunk/include/akonadi/itemfetchjob.h	2009-10-09 09:22:21.000000000 +0200
@@ -83,6 +83,20 @@ class AKONADI_EXPORT ItemFetchJob : publ
     explicit ItemFetchJob( const Item &item, QObject *parent = 0 );
 
     /**
+     * Creates a new item fetch job that retrieves the specified items.
+     * If the items have an uid set, this is used to identify the item on the Akonadi
+     * server. If only a remote identifier is available, that one is used.
+     * However, as remote identifier are not necessarily globally unique, you
+     * need to specify the resource and/or collection to search in in that case,
+     * using setCollection() or Akonadi::ResourceSelectJob.
+     *
+     * @param items The items to fetch.
+     * @param parent The parent object.
+     * @since 4.4
+     */
+    explicit ItemFetchJob( const Item::List &items, QObject *parent = 0 );
+
+    /**
      * Destroys the item fetch job.
      */
     virtual ~ItemFetchJob();
@@ -106,7 +120,21 @@ class AKONADI_EXPORT ItemFetchJob : publ
      *
      * @see fetchScope()
      */
-    void setFetchScope( ItemFetchScope &fetchScope );
+    void setFetchScope( ItemFetchScope &fetchScope ); // KDE5: remove
+
+    /**
+     * Sets the item fetch scope.
+     *
+     * The ItemFetchScope controls how much of an item's data is fetched
+     * from the server, e.g. whether to fetch the full item payload or
+     * only meta data.
+     *
+     * @param fetchScope The new scope for item fetch operations.
+     *
+     * @see fetchScope()
+     * @since 4.4
+     */
+    void setFetchScope( const ItemFetchScope &fetchScope );
 
     /**
      * Returns the item fetch scope.
@@ -123,17 +151,21 @@ class AKONADI_EXPORT ItemFetchJob : publ
     ItemFetchScope &fetchScope();
 
     /**
-      Specifies the collection the item is in.
-      This is only required when retrieving an item based on its remote id which might not be
-      unique globally.
-
-      @see Akonadi::ResourceSelectJob
+     * Specifies the collection the item is in.
+     * This is only required when retrieving an item based on its remote id which might not be
+     * unique globally.
+     *
+     * @see Akonadi::ResourceSelectJob
     */
     void setCollection( const Collection &collection );
 
   Q_SIGNALS:
     /**
-     * This signal is emitted when the items are fetched completely.
+     * This signal is emitted whenever new items have been fetched completely.
+     *
+     * @note This is an optimization, instead of waiting for the end of the job
+     *       and calling items(), you can connect to this signal and get the items
+     *       incrementally.
      *
      * @param items The fetched items.
      */
diff -pubNr /opt/kde-stable/include/akonadi/itemfetchscope.h /opt/kde-trunk/include/akonadi/itemfetchscope.h
--- /opt/kde-stable/include/akonadi/itemfetchscope.h	2009-10-12 18:32:20.000000000 +0200
+++ /opt/kde-trunk/include/akonadi/itemfetchscope.h	2009-10-09 09:22:21.000000000 +0200
@@ -68,6 +68,16 @@ class AKONADI_EXPORT ItemFetchScope
 {
   public:
     /**
+     * Describes the ancestor retrieval depth.
+     * @since 4.4
+     */
+    enum AncestorRetrieval {
+      None, ///< No ancestor retrieval at all (the default)
+      Parent, ///< Only retrieve the immediate parent collection
+      All ///< Retrieve all ancestors, up to Collection::root()
+    };
+
+    /**
      * Creates an empty item fetch scope.
      *
      * Using an empty scope will only fetch the very basic meta data of items,
@@ -180,6 +190,22 @@ class AKONADI_EXPORT ItemFetchScope
     void setCacheOnly( bool cacheOnly );
 
     /**
+     * Sets how many levels of ancestor collections should be included in the retrieval.
+     *
+     * @param ancestorDepth The desired ancestor retrieval depth.
+     * @since 4.4
+     */
+    void setAncestorRetrieval( AncestorRetrieval ancestorDepth );
+
+    /**
+     * Returns the ancestor retrieval depth.
+     *
+     * @see setAncestorRetrieval()
+     * @since 4.4
+     */
+    AncestorRetrieval ancestorRetrieval() const;
+
+    /**
      * Returns @c true if there is nothing to fetch.
      */
     bool isEmpty() const;
diff -pubNr /opt/kde-stable/include/akonadi/item.h /opt/kde-trunk/include/akonadi/item.h
--- /opt/kde-stable/include/akonadi/item.h	2009-10-12 18:32:20.000000000 +0200
+++ /opt/kde-trunk/include/akonadi/item.h	2009-10-09 09:22:21.000000000 +0200
@@ -317,10 +317,33 @@ class AKONADI_EXPORT Item : public Entit
      */
     KUrl url( UrlType type = UrlShort ) const;
 
+    /**
+     * Returns the parts available for this item.
+     *
+     * @since 4.4
+     */
+    QSet<QByteArray> availablePayloadParts() const;
+
+    /**
+     * Merges the Item @p other into this item.
+     * Any parts or attributes available in other, will be merged into this item,
+     * and the payload parts of other will be inserted into this item, overwriting
+     * any existing parts with the same part name.
+     *
+     * If there is an ItemSerialzerPluginV2 for the type, the merge method in that plugin is
+     * used to perform the merge. If only an ItemSerialzerPlugin class is found, or the merge
+     * method of the -V2 plugin is not implemented, the merge is performed with multiple deserializations
+     * of the payload.
+     *
+     * @since 4.4
+     */
+    void merge( const Item &other );
+
   private:
     //@cond PRIVATE
+    friend class ItemCreateJob;
     friend class ItemModifyJob;
-    friend class ItemFetchJob;
+    friend class ProtocolHelper;
     PayloadBase* payloadBase() const;
     void setPayloadBase( PayloadBase* );
     /**
diff -pubNr /opt/kde-stable/include/akonadi/itemmodel.h /opt/kde-trunk/include/akonadi/itemmodel.h
--- /opt/kde-stable/include/akonadi/itemmodel.h	2009-10-12 18:32:20.000000000 +0200
+++ /opt/kde-trunk/include/akonadi/itemmodel.h	2009-10-09 09:22:21.000000000 +0200
@@ -102,6 +102,8 @@ class AKONADI_EXPORT ItemModel : public 
 
     virtual QStringList mimeTypes() const;
 
+    virtual Qt::DropActions supportedDropActions() const;
+
     /**
      * Sets the item fetch scope.
      *
diff -pubNr /opt/kde-stable/include/akonadi/itemmovejob.h /opt/kde-trunk/include/akonadi/itemmovejob.h
--- /opt/kde-stable/include/akonadi/itemmovejob.h	2009-10-12 18:32:20.000000000 +0200
+++ /opt/kde-trunk/include/akonadi/itemmovejob.h	2009-10-09 09:22:21.000000000 +0200
@@ -79,6 +79,7 @@ class AKONADI_EXPORT ItemMoveJob : publi
 
   private:
     Q_DECLARE_PRIVATE( ItemMoveJob )
+    template <typename T, typename MoveJob> friend class MoveJobImpl;
 };
 
 }
diff -pubNr /opt/kde-stable/include/akonadi/itemsearchjob.h /opt/kde-trunk/include/akonadi/itemsearchjob.h
--- /opt/kde-stable/include/akonadi/itemsearchjob.h	1970-01-01 01:00:00.000000000 +0100
+++ /opt/kde-trunk/include/akonadi/itemsearchjob.h	2009-10-13 13:40:44.000000000 +0200
@@ -0,0 +1,137 @@
+/*
+    Copyright (c) 2009 Tobias Koenig <tokoe@kde.org>
+
+    This library is free software; you can redistribute it and/or modify it
+    under the terms of the GNU Library General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or (at your
+    option) any later version.
+
+    This library is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
+    License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to the
+    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+    02110-1301, USA.
+*/
+
+#ifndef AKONADI_ITEMSEARCHJOB_H
+#define AKONADI_ITEMSEARCHJOB_H
+
+#include <akonadi/item.h>
+#include <akonadi/job.h>
+
+namespace Akonadi {
+
+class ItemFetchScope;
+class ItemSearchJobPrivate;
+
+/**
+ * @short Job that searches for items in the Akonadi storage.
+ *
+ * This job searches for items that match a given search query and returns
+ * the list of matching item.
+ *
+ * @code
+ *
+ * const QString query = "..."; // some sparql query
+ *
+ * Akonadi::ItemSearchJob *job = new Akonadi::ItemSearchJob( query );
+ * job->fetchScope().fetchFullPayload();
+ * connect( job, SIGNAL( result( KJob* ) ), this, SLOT( searchResult( KJob* ) ) );
+ *
+ * ...
+ *
+ * MyClass::searchResult( KJob *job )
+ * {
+ *   Akonadi::ItemSearchJob *searchJob = qobject_cast<Akonadi::ItemSearchJob*>( job );
+ *   const Akonadi::Item::List items = searchJob->items();
+ *   foreach ( const Akonadi::Item &item, items ) {
+ *     // extract the payload and do further stuff
+ *   }
+ * }
+ *
+ * @endcode
+ *
+ * @author Tobias Koenig <tokoe@kde.org>
+ * @since 4.4
+ */
+class AKONADI_EXPORT ItemSearchJob : public Job
+{
+  Q_OBJECT
+
+  public:
+    /**
+     * Creates an item search job.
+     *
+     * @param query The search query in SPARQL format.
+     * @param parent The parent object.
+     */
+    explicit ItemSearchJob( const QString &query, QObject *parent = 0 );
+
+    /**
+     * Destroys the item search job.
+     */
+    ~ItemSearchJob();
+
+    /**
+     * Sets the item fetch scope.
+     *
+     * The ItemFetchScope controls how much of an matching item's data is fetched
+     * from the server, e.g. whether to fetch the full item payload or
+     * only meta data.
+     *
+     * @param fetchScope The new scope for item fetch operations.
+     *
+     * @see fetchScope()
+     */
+    void setFetchScope( const ItemFetchScope &fetchScope );
+
+    /**
+     * Returns the item fetch scope.
+     *
+     * Since this returns a reference it can be used to conveniently modify the
+     * current scope in-place, i.e. by calling a method on the returned reference
+     * without storing it in a local variable. See the ItemFetchScope documentation
+     * for an example.
+     *
+     * @return a reference to the current item fetch scope
+     *
+     * @see setFetchScope() for replacing the current item fetch scope
+     */
+    ItemFetchScope &fetchScope();
+
+    /**
+     * Returns the items that matched the search query.
+     */
+    Item::List items() const;
+
+  Q_SIGNALS:
+    /**
+     * This signal is emitted whenever new matching items have been fetched completely.
+     *
+     * @note This is an optimization, instead of waiting for the end of the job
+     *       and calling items(), you can connect to this signal and get the items
+     *       incrementally.
+     *
+     * @param items The matching items.
+     */
+    void itemsReceived( const Akonadi::Item::List &items );
+
+  protected:
+    void doStart();
+    virtual void doHandleResponse( const QByteArray &tag, const QByteArray &data );
+
+  private:
+    //@cond PRIVATE
+    Q_DECLARE_PRIVATE( ItemSearchJob )
+
+    Q_PRIVATE_SLOT( d_func(), void timeout() )
+    //@endcond
+};
+
+}
+
+#endif
diff -pubNr /opt/kde-stable/include/akonadi/itemserializerplugin.h /opt/kde-trunk/include/akonadi/itemserializerplugin.h
--- /opt/kde-stable/include/akonadi/itemserializerplugin.h	2009-10-12 18:32:20.000000000 +0200
+++ /opt/kde-trunk/include/akonadi/itemserializerplugin.h	2009-10-09 09:22:21.000000000 +0200
@@ -24,13 +24,13 @@
 #include <QtCore/QByteArray>
 #include <QtCore/QSet>
 
+#include "item.h"
 #include "akonadi_export.h"
 
 class QIODevice;
 
 namespace Akonadi {
 
-class Item;
 
 /**
  * @short The base class for item type serializer plugins.
@@ -119,7 +119,7 @@ class Item;
  */
 class AKONADI_EXPORT ItemSerializerPlugin
 {
-public:
+  public:
     /**
      * Destroys the item serializer plugin.
      */
@@ -172,10 +172,48 @@ public:
      * @param item The item.
      */
     virtual QSet<QByteArray> parts( const Item &item ) const;
+
+};
+
+/**
+ * @short The extended base class for item type serializer plugins.
+ *
+ * @since 4.4
+ */
+class AKONADI_EXPORT ItemSerializerPluginV2 : public ItemSerializerPlugin
+{
+  public:
+    /**
+     * Destroys the item serializer plugin.
+     */
+    virtual ~ItemSerializerPluginV2();
+
+    /**
+     * Merges the payload parts in @p other into @p item.
+     *
+     * The default implementation is slow as it requires serializing @p other, and deserializing @p item multiple times.
+     * Reimplementing this is recommended if your type uses payload parts.
+     *
+     * @since 4.4
+     */
+    virtual void merge( Item &item, const Item &other );
+
+    /**
+     * Returns the parts available in the item @p item.
+     *
+     * This should be reimplemented to return available parts.
+     *
+     * The default implementation returns an empty set if the item has a payload,
+     * and a set containing Item::FullPayload if the item has no payload.
+     *
+     * @since 4.4
+     */
+    virtual QSet<QByteArray> availableParts( const Item &item ) const;
 };
 
 }
 
 Q_DECLARE_INTERFACE( Akonadi::ItemSerializerPlugin, "org.freedesktop.Akonadi.ItemSerializerPlugin/1.0" )
+Q_DECLARE_INTERFACE( Akonadi::ItemSerializerPluginV2, "org.freedesktop.Akonadi.ItemSerializerPlugin/1.1" )
 
 #endif
diff -pubNr /opt/kde-stable/include/akonadi/kmime/addressattribute.h /opt/kde-trunk/include/akonadi/kmime/addressattribute.h
--- /opt/kde-stable/include/akonadi/kmime/addressattribute.h	1970-01-01 01:00:00.000000000 +0100
+++ /opt/kde-trunk/include/akonadi/kmime/addressattribute.h	2009-10-09 09:22:09.000000000 +0200
@@ -0,0 +1,112 @@
+/*
+    Copyright 2009 Constantin Berzan <exit3219@gmail.com>
+
+    This library is free software; you can redistribute it and/or modify it
+    under the terms of the GNU Library General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or (at your
+    option) any later version.
+
+    This library is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
+    License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to the
+    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+    02110-1301, USA.
+*/
+
+#ifndef AKONADI_ADDRESSATTRIBUTE_H
+#define AKONADI_ADDRESSATTRIBUTE_H
+
+#include "akonadi-kmime_export.h"
+
+#include <QtCore/QString>
+#include <QtCore/QStringList>
+
+#include <akonadi/attribute.h>
+
+namespace MailTransport {
+  class Transport;
+}
+
+namespace Akonadi {
+
+/**
+  Attribute storing the From, To, Cc, Bcc addresses of a message.
+
+  @author Constantin Berzan <exit3219@gmail.com>
+  @since 4.4
+*/
+class AKONADI_KMIME_EXPORT AddressAttribute : public Akonadi::Attribute
+{
+  public:
+    /**
+      Creates a new AddressAttribute.
+    */
+    explicit AddressAttribute( const QString &from = QString(),
+                               const QStringList &to = QStringList(),
+                               const QStringList &cc = QStringList(),
+                               const QStringList &bcc = QStringList() );
+    /**
+      Destroys the AddressAttribute.
+    */
+    virtual ~AddressAttribute();
+
+    
+    /* reimpl */
+    virtual AddressAttribute* clone() const;
+    virtual QByteArray type() const;
+    virtual QByteArray serialized() const;
+    virtual void deserialize( const QByteArray &data );
+
+    /**
+      Returns the address of the sender.
+    */
+    QString from() const;
+
+    /**
+      Sets the address of the sender.
+    */
+    void setFrom( const QString &from );
+
+    /**
+      Returns the addresses of the "To:" receivers.
+    */
+    QStringList to() const;
+    
+    /**
+      Sets the addresses of the "To:" receivers."
+    */
+    void setTo( const QStringList &to );
+
+    /**
+      Returns the addresses of the "Cc:" receivers.
+    */
+    QStringList cc() const;
+
+    /**
+      Sets the addresses of the "Cc:" receivers."
+    */
+    void setCc( const QStringList &cc );
+
+    /**
+      Returns the addresses of the "Bcc:" receivers.
+    */
+    QStringList bcc() const;
+
+    /**
+      Sets the addresses of the "Bcc:" receivers."
+    */
+    void setBcc( const QStringList &bcc );
+
+  private:
+    class Private;
+    Private *const d;
+
+};
+
+} // namespace Akonadi
+
+#endif // AKONADI_ADDRESSATTRIBUTE_H
diff -pubNr /opt/kde-stable/include/akonadi/kmime/akonadi-kmime_export.h /opt/kde-trunk/include/akonadi/kmime/akonadi-kmime_export.h
--- /opt/kde-stable/include/akonadi/kmime/akonadi-kmime_export.h	2009-10-12 18:32:15.000000000 +0200
+++ /opt/kde-trunk/include/akonadi/kmime/akonadi-kmime_export.h	2009-10-09 09:22:09.000000000 +0200
@@ -33,4 +33,20 @@
 # endif
 #endif
 
+#ifdef COMPILING_TESTS
+# ifndef AKONADI_KMIME_TEST_EXPORT
+#  if defined(MAKE_AKONADI_KMIME_LIB)
+    /* We are building this library */
+#   define AKONADI_KMIME_TEST_EXPORT KDE_EXPORT
+#  else
+    /* We are using this library */
+#   define AKONADI_KMIME_TEST_EXPORT KDE_IMPORT
+#  endif
+# endif
+#else
+# ifndef AKONADI_KMIME_TEST_EXPORT
+#  define AKONADI_KMIME_TEST_EXPORT
+# endif
+#endif
+
 #endif
diff -pubNr /opt/kde-stable/include/akonadi/kmime/localfolderattribute.h /opt/kde-trunk/include/akonadi/kmime/localfolderattribute.h
--- /opt/kde-stable/include/akonadi/kmime/localfolderattribute.h	1970-01-01 01:00:00.000000000 +0100
+++ /opt/kde-trunk/include/akonadi/kmime/localfolderattribute.h	2009-10-09 09:22:09.000000000 +0200
@@ -0,0 +1,74 @@
+/*
+    Copyright 2009 Constantin Berzan <exit3219@gmail.com>
+
+    This library is free software; you can redistribute it and/or modify it
+    under the terms of the GNU Library General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or (at your
+    option) any later version.
+
+    This library is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
+    License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to the
+    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+    02110-1301, USA.
+*/
+
+#ifndef AKONADI_LOCALFOLDERATTRIBUTE_H
+#define AKONADI_LOCALFOLDERATTRIBUTE_H
+
+#include "akonadi-kmime_export.h"
+
+#include <akonadi/attribute.h>
+
+namespace Akonadi {
+
+/**
+  Attribute storing the LocalFolder type of a collection (e.g. Outbox,
+  Drafts, SentMail).  All collections registered with LocalFolders must
+  have this attribute.
+
+  @author Constantin Berzan <exit3219@gmail.com>
+  @since 4.4
+*/
+class AKONADI_KMIME_EXPORT LocalFolderAttribute : public Akonadi::Attribute
+{
+  public:
+    /**
+      Creates a new LocalFolderAttribute.
+    */
+    explicit LocalFolderAttribute( int type = -1 );
+
+    /**
+      Destroys the LocalFolderAttribute.
+    */
+    virtual ~LocalFolderAttribute();
+
+    /* reimpl */
+    virtual LocalFolderAttribute* clone() const;
+    virtual QByteArray type() const;
+    virtual QByteArray serialized() const;
+    virtual void deserialize( const QByteArray &data );
+
+    /**
+      Returns the LocalFolder type of the collection.
+    */
+    int folderType() const;
+
+    /**
+      Sets the LocalFolder type of the collection.
+    */
+    void setFolderType( int type );
+
+  private:
+    class Private;
+    Private *const d;
+
+};
+
+} // namespace Akonadi
+
+#endif // AKONADI_LOCALFOLDERATTRIBUTE_H
diff -pubNr /opt/kde-stable/include/akonadi/kmime/localfolders.h /opt/kde-trunk/include/akonadi/kmime/localfolders.h
--- /opt/kde-stable/include/akonadi/kmime/localfolders.h	1970-01-01 01:00:00.000000000 +0100
+++ /opt/kde-trunk/include/akonadi/kmime/localfolders.h	2009-10-09 09:22:09.000000000 +0200
@@ -0,0 +1,210 @@
+/*
+    Copyright (c) 2009 Constantin Berzan <exit3219@gmail.com>
+
+    This library is free software; you can redistribute it and/or modify it
+    under the terms of the GNU Library General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or (at your
+    option) any later version.
+
+    This library is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
+    License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to the
+    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+    02110-1301, USA.
+*/
+
+#ifndef AKONADI_LOCALFOLDERS_H
+#define AKONADI_LOCALFOLDERS_H
+
+#include "akonadi-kmime_export.h"
+
+#include <QtCore/QObject>
+
+#include "akonadi/collection.h"
+
+class KJob;
+
+namespace Akonadi {
+
+class LocalFoldersPrivate;
+
+/**
+  @short Interface to local folders such as inbox, outbox etc.
+
+  This class is the central interface to the local mail folders. These folders
+  can either be in the default resource (stored in ~/.local/share/local-mail)
+  or in any number of custom resources. LocalFolders of the following types
+  are supported: inbox, outbox, sent-mail, trash, drafts, and templates.
+
+  To check whether a LocalFolder is available, simply use the hasFolder() and
+  hasDefaultFolder() methods. Available LocalFolders are accessible through
+  the folder() and defaultFolder() methods.
+
+  There are two ways to create LocalFolders that are not yet available:
+  1) Use a LocalFoldersRequestJob. This will create the LocalFolders you
+     request and automatically register them with LocalFolders, so that it
+     now knows they are available.
+  2) Mark any collection as a LocalFolder, by giving it a LocalFolderAttribute,
+     and then register it manually with registerFolder(). After that it will
+     be known as a LocalFolder of the given type in the given resource.
+
+  This class monitors all LocalFolder collections known to it, and removes it
+  from the known list if they are deleted. Note that this class does not
+  automatically rebuild the folders that disappeared.
+
+  The defaultFoldersChanged() and foldersChanged() signals are emitted when
+  the LocalFolders for a resource change (i.e. some became available or some
+  become unavailable).
+
+  @code
+  if( LocalFolders::self()->hasDefaultFolder( LocalFolders::Outbox ) ) {
+    Collection col = LocalFolders::self()->defaultFolder( LocalFolders::Outbox );
+    // ...
+  } else {
+    // ... use LocalFoldersRequestJob to request the folder...
+  }
+  @endcode
+
+  @author Constantin Berzan <exit3219@gmail.com>
+  @since 4.4
+*/
+class AKONADI_KMIME_EXPORT LocalFolders : public QObject
+{
+  Q_OBJECT
+
+  public:
+    /**
+      Each LocalFolder has one of the types below.  Generally, there may not
+      be two LocalFolders of the same type in the same resource.
+    */
+    enum Type
+    {
+      Root,            ///< the root folder containing the local folders
+                       // TODO ^ do we even need this?
+      Inbox,           ///< inbox
+      Outbox,          ///< outbox
+      SentMail,        ///< sent-mail
+      Trash,           ///< trash
+      Drafts,          ///< drafts
+      Templates,       ///< templates
+      LastDefaultType  ///< @internal marker
+    };
+
+    /**
+      Returns the LocalFolders instance.
+    */
+    static LocalFolders *self();
+
+    /**
+      Returns whether the given resource had a LocalFolder of the given
+      @p type.
+      @param type The type of the LocalFolder.
+      @param resourceId The ID of the resource containing the LocalFolder.
+    */
+    bool hasFolder( int type, const QString &resourceId ) const;
+
+    /**
+      Returns the LocalFolder of given @p type in the given resource, or
+      an invalid Collection if such a folder is unknown.
+      @param type The type of the LocalFolder.
+      @param resourceId The ID of the resource containing the LocalFolder.
+    */
+    Akonadi::Collection folder( int type, const QString &resourceId ) const;
+
+    /**
+      Registers the given @p collection as a LocalFolder. The collection must
+      have a valid LocalFolderAttribute determining its LocalFolder type, and
+      it must be owned by a valid resource.
+      Registering a new collection of a previously registered type forgets the
+      old collection.
+      @param collection The folder to register.
+      @return Whether registration was successful.
+    */
+    bool registerFolder( const Akonadi::Collection &collection );
+
+    /**
+      Returns the ID of the default LocalFolders resource.
+      This resource is normally stored in ~/.local/share/local-mail, and its
+      ID is stored in a config file named localfoldersrc.
+    */
+    QString defaultResourceId() const;
+
+    /**
+      Returns whether the default resource had a LocalFolder of the given
+      @p type.
+      @param type The type of the LocalFolder.
+    */
+    bool hasDefaultFolder( int type ) const;
+
+    /**
+      Returns the LocalFolder of given @p type in the default resource, or
+      an invalid Collection if such a folder is unknown.
+      @param type The type of the LocalFolder.
+    */
+    Akonadi::Collection defaultFolder( int type ) const;
+
+  Q_SIGNALS:
+    /**
+      Emitted when the LocalFolders for a resource are changed (for example,
+      some become available, or some become unavailable).
+      @param resourceId The ID of the resource for which the folders changed.
+    */
+    // TODO: Currently when a resource is deleted, all its collections are
+    // deleted too, and foldersChanged() is emitted multiple times. This
+    // doesn't seem to be a problem, but it would be nice if this signal was
+    // delayed and emitted only once.
+    void foldersChanged( const QString &resourceId );
+
+    /**
+      Emitted when the LocalFolders for the default resource are changed (for
+      example, some become available, or some become unavailable).
+      Note that when the default folders change, both defaultFoldersChanged()
+      and foldersChanged( LocalFolders::self()->defaultResourceId() ) are
+      emitted.
+    */
+    void defaultFoldersChanged();
+
+  private:
+    friend class LocalFoldersRequestJob;
+    friend class LocalFoldersRequestJobPrivate;
+    friend class LocalFoldersPrivate;
+
+#if 1 // TODO do this only if building tests:
+    friend class LocalFoldersTesting;
+#endif
+
+    // singleton class; the only instance resides in sInstance->instance
+    LocalFolders( LocalFoldersPrivate *dd );
+
+    /**
+      Forgets all folders owned by the given resource.
+      This method is used by LocalFoldersRequestJob.
+    */
+    void forgetFoldersForResource( const QString &resourceId );
+
+    /**
+      Avoids emitting the foldersChanged() signal until endBatchRegister()
+      is called. This is used to avoid emitting repeated signals when multiple
+      folders are registered in a row.
+      This method is used by LocalFoldersRequestJob.
+    */
+    void beginBatchRegister();
+
+    /**
+      @see beginBatchRegister()
+      This method is used by LocalFoldersRequestJob.
+    */
+    void endBatchRegister();
+
+    LocalFoldersPrivate *const d;
+
+    Q_PRIVATE_SLOT( d, void collectionRemoved( Akonadi::Collection ) )
+};
+
+} // namespace Akonadi
+
+#endif // AKONADI_LOCALFOLDERS_H
diff -pubNr /opt/kde-stable/include/akonadi/kmime/localfoldersrequestjob.h /opt/kde-trunk/include/akonadi/kmime/localfoldersrequestjob.h
--- /opt/kde-stable/include/akonadi/kmime/localfoldersrequestjob.h	1970-01-01 01:00:00.000000000 +0100
+++ /opt/kde-trunk/include/akonadi/kmime/localfoldersrequestjob.h	2009-10-09 09:22:09.000000000 +0200
@@ -0,0 +1,113 @@
+/*
+    Copyright (c) 2009 Constantin Berzan <exit3219@gmail.com>
+
+    This library is free software; you can redistribute it and/or modify it
+    under the terms of the GNU Library General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or (at your
+    option) any later version.
+
+    This library is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
+    License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to the
+    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+    02110-1301, USA.
+*/
+
+#ifndef AKONADI_LOCALFOLDERSREQUESTJOB_H
+#define AKONADI_LOCALFOLDERSREQUESTJOB_H
+
+#include "akonadi-kmime_export.h"
+
+#include <akonadi/collection.h>
+#include <akonadi/transactionsequence.h>
+
+namespace Akonadi {
+
+class LocalFoldersRequestJobPrivate;
+
+/**
+  @short A job to request LocalFolders.
+
+  Use this job to request the LocalFolders you need. You can request both
+  default LocalFolders and LocalFolders in a given resource. The default
+  LocalFolders resource is created when the first default LocalFolder is
+  requested, but if a LocalFolder in a custom resource is requested, this
+  job expects that resource to exist already.
+
+  If the folders you requested already exist, this job simply succeeds.
+  Otherwise, it creates the required collections and registers them with
+  LocalFolders.
+
+  Example of usage:
+
+  In your class constructor:
+  @code
+  LocalFoldersRequestJob *rjob = new LocalFoldersRequestJob( this );
+  rjob->requestDefaultFolder( LocalFolders::Outbox );
+  connect( rjob, SIGNAL(result(KJob*)), this, SLOT(localFoldersRequestResult(KJob*)) );
+  rjob->start();
+  @endcode
+
+  And in your localFoldersRequestResult( KJob *job ) slot:
+  @code
+  if( job->error() ) { ... }
+  Collection col = LocalFolders::self()->defaultFolder( LocalFolders::Outbox );
+  Q_ASSERT( col.isValid() );
+  @endcode
+
+  @author Constantin Berzan <exit3219@gmail.com>
+  @since 4.4
+*/
+class AKONADI_KMIME_EXPORT LocalFoldersRequestJob : public TransactionSequence
+{
+  Q_OBJECT
+
+  friend class LocalFoldersRequestJobPrivate;
+
+  public:
+    /**
+      Creates a new LocalFoldersRequestJob.
+    */
+    explicit LocalFoldersRequestJob( QObject *parent = 0 );
+
+    /**
+      Destroys this LocalFoldersRequestJob.
+    */
+    ~LocalFoldersRequestJob();
+
+    /**
+      Requests a LocalFolder of type @p type in the default resource.
+      @param type The type of LocalFolder requested.
+    */
+    void requestDefaultFolder( int type );
+
+    /**
+      Requests a LocalFolder of type @p type in the given resource.
+      @param type The type of LocalFolder requested.
+      @param resourceId The resource ID of the LocalFolder requested.
+    */
+    void requestFolder( int type, const QString &resourceId );
+
+  protected:
+    /* reimpl */
+    virtual void doStart();
+    /* reimpl */
+    virtual void slotResult( KJob *job );
+
+  private:
+    LocalFoldersRequestJobPrivate *const d;
+
+    Q_PRIVATE_SLOT( d, void lockResult( KJob* ) )
+    Q_PRIVATE_SLOT( d, void releaseLock() )
+    Q_PRIVATE_SLOT( d, void resourceScanResult( KJob* ) )
+    Q_PRIVATE_SLOT( d, void collectionCreateResult( KJob* ) )
+
+};
+
+} // namespace Akonadi
+
+#endif // AKONADI_LOCALFOLDERSREQUESTJOB_H
diff -pubNr /opt/kde-stable/include/akonadi/kmime/messagefolderattribute.h /opt/kde-trunk/include/akonadi/kmime/messagefolderattribute.h
--- /opt/kde-stable/include/akonadi/kmime/messagefolderattribute.h	1970-01-01 01:00:00.000000000 +0100
+++ /opt/kde-trunk/include/akonadi/kmime/messagefolderattribute.h	2009-10-09 09:22:09.000000000 +0200
@@ -0,0 +1,79 @@
+/*
+    Copyright (c) 2009 Kevin Ottens <ervin@kde.org>
+
+    This library is free software; you can redistribute it and/or modify it
+    under the terms of the GNU Library General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or (at your
+    option) any later version.
+
+    This library is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
+    License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to the
+    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+    02110-1301, USA.
+*/
+
+#ifndef AKONADI_MESSAGEFOLDERATTRIBUTE_H
+#define AKONADI_MESSAGEFOLDERATTRIBUTE_H
+
+#include "akonadi-kmime_export.h"
+#include <akonadi/attribute.h>
+
+#include <QtCore/QByteArray>
+
+namespace Akonadi {
+
+/**
+  Message folder information. Used eg. by mail clients to decide how to display the content of such collections
+  @since 4.4
+*/
+class AKONADI_KMIME_EXPORT MessageFolderAttribute : public Attribute
+{
+  public:
+    /**
+      Creates an empty folder attribute.
+    */
+    MessageFolderAttribute();
+
+    /**
+      Copy constructor.
+    */
+    MessageFolderAttribute( const MessageFolderAttribute &other );
+
+    /**
+      Destructor.
+    */
+    ~MessageFolderAttribute();
+
+    /**
+      Indicates if the folder is supposed to contain mostly outbound messages.
+      In such a case mail clients display the recipient address, otherwise they
+      display the sender address.
+
+      @return true if the folder contains outbound messages
+    */
+    bool isOutboundFolder() const;
+
+    /**
+      Set if the folder should be considered as containing mostly outbound messages.
+     */
+    void setOutboundFolder(bool outbound);
+
+    // reimpl.
+    QByteArray type() const;
+    MessageFolderAttribute* clone() const;
+    QByteArray serialized() const;
+    void deserialize( const QByteArray &data );
+
+  private:
+    class Private;
+    Private * const d;
+};
+
+}
+
+#endif
diff -pubNr /opt/kde-stable/include/akonadi/linkjob.h /opt/kde-trunk/include/akonadi/linkjob.h
--- /opt/kde-stable/include/akonadi/linkjob.h	2009-10-12 18:32:20.000000000 +0200
+++ /opt/kde-trunk/include/akonadi/linkjob.h	2009-10-09 09:22:21.000000000 +0200
@@ -81,6 +81,7 @@ class AKONADI_EXPORT LinkJob : public Jo
 
   private:
     Q_DECLARE_PRIVATE( LinkJob )
+    template <typename T> friend class LinkJobImpl;
 };
 
 }
diff -pubNr /opt/kde-stable/include/akonadi/monitor.h /opt/kde-trunk/include/akonadi/monitor.h
--- /opt/kde-stable/include/akonadi/monitor.h	2009-10-12 18:32:20.000000000 +0200
+++ /opt/kde-trunk/include/akonadi/monitor.h	2009-10-09 09:22:21.000000000 +0200
@@ -27,6 +27,7 @@
 
 namespace Akonadi {
 
+class CollectionFetchScope;
 class CollectionStatistics;
 class Item;
 class ItemFetchScope;
@@ -40,10 +41,10 @@ class Session;
  * removed or new ones are added to the Akonadi storage.
  *
  * Optionally, the changed objects can be fetched automatically from the server.
- * To enable this, see fetchCollection(), fetchItemMetaData(), fetchItemData().
+ * To enable this, see itemFetchScope() and collectionFetchScope().
  *
- * @todo: distinguish between monitoring collection properties and collection content.
- * @todo: special case for collection content counts changed
+ * @todo Distinguish between monitoring collection properties and collection content.
+ * @todo Special case for collection content counts changed
  *
  * @author Volker Krause <vkrause@kde.org>
  */
@@ -65,42 +66,72 @@ class AKONADI_EXPORT Monitor : public QO
     virtual ~Monitor();
 
     /**
-     * Sets whether the specified collection shall be monitored for changes.
+     * Sets whether the specified collection shall be monitored for changes. If
+     * monitoring is turned on for the collection, all notifications for items
+     * in that collection will be emitted, and its child collections will also
+     * be monitored. Note that move notifications will be emitted if either one
+     * of the collections involved is being monitored.
+     *
+     * Note that if a session is being ignored, this takes precedence over
+     * setCollectionMonitored() on that session.
      *
      * @param collection The collection to monitor.
      *                   If this collection is Collection::root(), all collections
      *                   in the Akonadi storage will be monitored.
+     * @param monitored Whether to monitor the collection.
      */
     void setCollectionMonitored( const Collection &collection, bool monitored = true );
 
     /**
      * Sets whether the specified item shall be monitored for changes.
      *
+     * Note that if a session is being ignored, this takes precedence over
+     * setItemMonitored() on that session.
+     *
      * @param item The item to monitor.
+     * @param monitored Whether to monitor the item.
      */
     void setItemMonitored( const Item &item, bool monitored = true );
 
     /**
-     * Sets whether the specified resource shall be monitored for changes.
+     * Sets whether the specified resource shall be monitored for changes. If
+     * monitoring is turned on for the resource, all notifications for
+     * collections and items in that resource will be emitted.
+     *
+     * Note that if a session is being ignored, this takes precedence over
+     * setResourceMonitored() on that session.
      *
      * @param resource The resource identifier.
+     * @param monitored Whether to monitor the resource.
      */
     void setResourceMonitored( const QByteArray &resource, bool monitored = true );
 
     /**
-     * Sets whether objects of the specified mime type shall be monitored for changes.
+     * Sets whether items of the specified mime type shall be monitored for changes.
+     * If monitoring is turned on for the mime type, all notifications for items
+     * matching that mime type will be emitted, but notifications for collections
+     * matching that mime type will only be emitted if this is otherwise specified,
+     * for example by setCollectionMonitored().
+     *
+     * Note that if a session is being ignored, this takes precedence over
+     * setMimeTypeMonitored() on that session.
      *
      * @param mimetype The mime type to monitor.
+     * @param monitored Whether to monitor the mime type.
      */
     void setMimeTypeMonitored( const QString &mimetype, bool monitored = true );
 
     /**
      * Sets whether all items shall be monitored.
+     *
+     * Note that if a session is being ignored, this takes precedence over
+     * setAllMonitored() on that session.
      */
     void setAllMonitored( bool monitored = true );
 
     /**
-     * Ignores all change notifications caused by the given session.
+     * Ignores all change notifications caused by the given session. This
+     * overrides all other settings on this session.
      *
      * @param session The session you want to ignore.
      */
@@ -148,6 +179,35 @@ class AKONADI_EXPORT Monitor : public QO
     ItemFetchScope &itemFetchScope();
 
     /**
+     * Sets the collection fetch scope.
+     *
+     * Controls which collections are monitored and how much of a collection's data
+     * is fetched from the server.
+     *
+     * @param fetchScope The new scope for collection fetch operations.
+     *
+     * @see collectionFetchScope()
+     * @since 4.4
+     */
+    void setCollectionFetchScope( const CollectionFetchScope &fetchScope );
+
+    /**
+     * Returns the collection fetch scope.
+     *
+     * Since this returns a reference it can be used to conveniently modify the
+     * current scope in-place, i.e. by calling a method on the returned reference
+     * without storing it in a local variable. See the CollectionFetchScope documentation
+     * for an example.
+     *
+     * @return a reference to the current collection fetch scope
+     *
+     * @see setCollectionFetchScope() for replacing the current collection fetch scope
+     * @since 4.4
+     */
+    CollectionFetchScope &collectionFetchScope();
+
+
+    /**
      * Returns the list of collections being monitored.
      *
      * @since 4.3
@@ -246,14 +306,34 @@ class AKONADI_EXPORT Monitor : public QO
     void collectionAdded( const Akonadi::Collection &collection, const Akonadi::Collection &parent );
 
     /**
-     * This signal is emitted if a monitored collection has been changed (properties or content)
-     * or has been reparented.
+     * This signal is emitted if a monitored collection has been changed (properties or content).
      *
      * @param collection The changed collection.
      */
     void collectionChanged( const Akonadi::Collection &collection );
 
     /**
+     * This signal is emitted if a monitored collection has been changed (properties or content).
+     *
+     * @param collection The changed collection.
+     * @param partIdentifiers The identifiers of the collection parts that has been changed.
+     *
+     * @since 4.4
+     */
+    void collectionChanged( const Akonadi::Collection &collection, const QSet<QByteArray> &partIdentifiers );
+
+    /**
+     * This signals is emitted if a monitored collection has been moved.
+     *
+     * @param collection The moved collection.
+     * @param source The previous parent collection.
+     * @param distination The new parent collection.
+     *
+     * @since 4.4
+     */
+    void collectionMoved( const Akonadi::Collection &collection, const Akonadi::Collection &source, const Akonadi::Collection &destination );
+
+    /**
      * This signal is emitted if a monitored collection has been removed from the Akonadi storage.
      *
      * @param collection The removed collection.
@@ -317,6 +397,8 @@ class AKONADI_EXPORT Monitor : public QO
 
   protected:
     //@cond PRIVATE
+    friend class EntityTreeModel;
+    friend class EntityTreeModelPrivate;
     MonitorPrivate *d_ptr;
     explicit Monitor( MonitorPrivate *d, QObject *parent = 0 );
     //@endcond
@@ -325,11 +407,13 @@ class AKONADI_EXPORT Monitor : public QO
     Q_DECLARE_PRIVATE( Monitor )
 
     //@cond PRIVATE
+    Q_PRIVATE_SLOT( d_ptr, void slotSessionDestroyed( QObject* ) )
     Q_PRIVATE_SLOT( d_ptr, void slotStatisticsChangedFinished( KJob* ) )
     Q_PRIVATE_SLOT( d_ptr, void slotFlushRecentlyChangedCollections() )
     Q_PRIVATE_SLOT( d_ptr, void slotNotify( const Akonadi::NotificationMessage::List& ) )
-    Q_PRIVATE_SLOT( d_ptr, void slotItemJobFinished( KJob* ) )
-    Q_PRIVATE_SLOT( d_ptr, void slotCollectionJobFinished( KJob* ) )
+    Q_PRIVATE_SLOT( d_ptr, void dataAvailable() )
+
+    friend class ResourceBasePrivate;
     //@endcond
 };
 
diff -pubNr /opt/kde-stable/include/akonadi/partfetcher.h /opt/kde-trunk/include/akonadi/partfetcher.h
--- /opt/kde-stable/include/akonadi/partfetcher.h	1970-01-01 01:00:00.000000000 +0100
+++ /opt/kde-trunk/include/akonadi/partfetcher.h	2009-10-09 09:22:21.000000000 +0200
@@ -0,0 +1,118 @@
+/*
+    Copyright (c) 2009 Stephen Kelly <steveire@gmail.com>
+
+    This library is free software; you can redistribute it and/or modify it
+    under the terms of the GNU Library General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or (at your
+    option) any later version.
+
+    This library is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
+    License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to the
+    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+    02110-1301, USA.
+*/
+
+#ifndef AKONADI_PART_FETCHER_H
+#define AKONADI_PART_FETCHER_H
+
+#include <kjob.h>
+
+#include "akonadi_export.h"
+
+class QModelIndex;
+
+namespace Akonadi
+{
+
+class Item;
+class PartFetcherPrivate;
+
+/**
+ * @short Convenience class for getting payload parts from an Akonadi Model.
+ *
+ * This class can be used to retrieve individual payload parts from an EntityTreeModel,
+ * and fetch them asynchronously from the Akonadi storage if necessary.
+ *
+ * The requested part is emitted though the partFetched signal.
+ *
+ * Example:
+ *
+ * @code
+ *
+ * const QModelIndex index = view->selectionModel()->currentIndex();
+ *
+ * PartFetcher *fetcher = new PartFetcher( index, Akonadi::MessagePart::Envelope );
+ * connect( fetcher, SIGNAL( result( KJob* ) ), SLOT( fetchResult( KJob* ) ) );
+ * fetcher->start();
+ *
+ * ...
+ *
+ * MyClass::fetchResult( KJob *job )
+ * {
+ *   if ( job->error() ) {
+ *     qDebug() << job->errorText();
+ *     return;
+ *   }
+ *
+ *   PartFetcher *fetcher = qobject_cast<PartFetcher>( job );
+ *
+ *   const Item item = fetcher->item();
+ *   // do something with the item
+ * }
+ *
+ * @endcode
+ *
+ * @author Stephen Kelly <steveire@gmail.com>
+ * @since 4.4
+ */
+class AKONADI_EXPORT PartFetcher : public KJob
+{
+  Q_OBJECT
+
+  public:
+    /**
+     * Creates a new part fetcher.
+     *
+     * @param index The index of the item to fetch the part from.
+     * @param partName The name of the payload part to fetch.
+     * @param parent The parent object.
+     */
+    explicit PartFetcher( const QModelIndex &index, const QByteArray &partName, QObject *parent = 0 );
+
+    /**
+     * Starts the fetch operation.
+     */
+    virtual void start();
+
+    /**
+     * Returns the index of the item the part was fetched from.
+     */
+    QModelIndex index() const;
+
+    /**
+     * Returns the name of the part that has been fetched.
+     */
+    QByteArray partName() const;
+
+    /**
+     * Returns the item that contains the fetched payload part.
+     */
+    Item item() const;
+
+  private:
+    //@cond PRIVATE
+    Q_DECLARE_PRIVATE( Akonadi::PartFetcher )
+    PartFetcherPrivate *const d_ptr;
+
+    Q_PRIVATE_SLOT( d_func(), void fetchJobDone( KJob *job ) )
+    //@endcond
+};
+
+}
+
+#endif
diff -pubNr /opt/kde-stable/include/akonadi/preprocessorbase.h /opt/kde-trunk/include/akonadi/preprocessorbase.h
--- /opt/kde-stable/include/akonadi/preprocessorbase.h	1970-01-01 01:00:00.000000000 +0100
+++ /opt/kde-trunk/include/akonadi/preprocessorbase.h	2009-10-09 09:22:21.000000000 +0200
@@ -0,0 +1,183 @@
+/******************************************************************************
+ *
+ *  Copyright (c) 2009 Szymon Stefanek <s.stefanek at gmail dot com>
+ *
+ *  This library is free software; you can redistribute it and/or modify it
+ *  under the terms of the GNU Library General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or (at your
+ *  option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful, but WITHOUT
+ *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ *  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
+ *  License for more details.
+ *
+ *  You should have received a copy of the GNU Library General Public License
+ *  along with this library; see the file COPYING.LIB.  If not, write to the
+ *  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ *  MA, 02110-1301, USA.
+ *
+ *****************************************************************************/
+
+#ifndef AKONADI_PREPROCESSORBASE_H
+#define AKONADI_PREPROCESSORBASE_H
+
+#include "akonadi_export.h"
+
+#include <akonadi/agentbase.h>
+#include <akonadi/collection.h>
+#include <akonadi/item.h>
+
+class PreprocessorAdaptor;
+
+namespace Akonadi
+{
+
+class PreprocessorBasePrivate;
+
+/**
+ * @short The base class for all Akonadi preprocessor agents.
+ *
+ * This class should be used as a base class by all preprocessor agents
+ * since it encapsulates large parts of the protocol between
+ * preprocessor agent, agent manager and the Akonadi storage.
+ *
+ * Preprocessor agents are special agents that are informed about newly
+ * added items before any other agents. This allows them to do filtering
+ * on the items or any other task that shall be done before the new item
+ * is visible in the Akonadi storage system.
+ *
+ * The method all the preprocessors must implement is processItem().
+ *
+ * @author Szymon Stefanek <s.stefanek@gmail.com>
+ * @since 4.4
+ */
+class AKONADI_EXPORT PreprocessorBase : public AgentBase
+{
+  Q_OBJECT
+
+  public:
+    /**
+     * Describes the possible return values of the processItem() method.
+     */
+    enum ProcessingResult
+    {
+      /**
+       * Processing completed successfully for this item.
+       * The Akonadi server will push in a new item when it's available.
+       */
+      ProcessingCompleted,
+
+      /**
+       * Processing was delayed to a later stage.
+       * This must be returned when implementing asynchronous preprocessing.
+       *
+       * If this value is returned, terminateProcessing() has to be called
+       * when processing is done.
+       */
+      ProcessingDelayed,
+
+      /**
+       * Processing for this item failed (and the failure is unrecoverable).
+       * The Akonadi server will push in a new item when it's available,
+       * after possibly logging the failure.
+       */
+      ProcessingFailed,
+
+      /**
+       * Processing for this item was refused. This is very
+       * similar to ProcessingFailed above but additionally remarks
+       * that the item that the Akonadi server pushed in wasn't
+       * meant for this Preprocessor.
+       * The Akonadi server will push in a new item when it's available,
+       * after possibly logging the failure and maybe taking some additional action.
+       */
+      ProcessingRefused
+    };
+
+    /**
+     * This method must be implemented by every preprocessor subclass.
+     *
+     * It must realize the preprocessing of the item with the specified itemId,
+     * which is actually in the collection with collectionId and has the specified mimetype.
+     *
+     * The Akonadi server will push in for preprocessing any newly created item:
+     * it's your responsibility to decide if you want to process the item or not.
+     *
+     * The method should return ProcessingCompleted on success, ProcessingDelayed
+     * if processing is implemented asynchronously and
+     * ProcessingRefused or ProcessingFailed if the processing
+     * didn't complete.
+     *
+     * If your operation is asynchronous then you should also
+     * connect to the abortRequested() signal and handle it
+     * appropriately (as the server MAY abort your async job
+     * if it decides that it's taking too long).
+     */
+    virtual ProcessingResult processItem( Item::Id itemId, Collection::Id collectionId, const QString &mimeType ) = 0;
+
+    /**
+     * This method must be called if processing is implemented asynchronously.
+     *
+     * You should call it when you have completed the processing
+     * or if an abortRequest() signal arrives (and in this case you
+     * will probably use ProcessingFailed as result).
+     *
+     * Valid values for @p result are ProcessingCompleted,
+     * PocessingRefused and ProcessingFailed. Passing any
+     * other value will lead to a runtime assertion.
+     */
+    void terminateProcessing( ProcessingResult result );
+
+  Q_SIGNALS:
+    /**
+     * This signal is emitted to report item processing termination
+     * to the Akonadi server.
+     *
+     * @note This signal is only for internal use.
+     */
+    void itemProcessed( qlonglong id );
+
+  protected:
+    /**
+     * Creates a new preprocessor base agent.
+     *
+     * @param id The instance id of the preprocessor base agent.
+     */
+    PreprocessorBase( const QString &id );
+
+    /**
+     * Destroys the preprocessor base agent.
+     */
+    virtual ~PreprocessorBase();
+
+    /**
+     * This dbus method is called by the Akonadi server
+     * in order to trigger the processing of an item.
+     *
+     * @note Do not call it manually!
+     */
+    void beginProcessItem( qlonglong itemId, qlonglong collectionId, const QString &mimeType );
+
+  private:
+    // dbus Preprocessor interface
+    friend class ::PreprocessorAdaptor;
+
+    Q_DECLARE_PRIVATE( PreprocessorBase )
+
+}; // class PreprocessorBase
+
+} // namespace Akonadi
+
+#ifndef AKONADI_PREPROCESSOR_MAIN
+/**
+ * Convenience Macro for the most common main() function for Akonadi preprocessors.
+ */
+#define AKONADI_PREPROCESSOR_MAIN( preProcessorClass )                       \
+  int main( int argc, char **argv )                                          \
+  {                                                                          \
+    return Akonadi::PreprocessorBase::init<preProcessorClass>( argc, argv ); \
+  }
+#endif //!AKONADI_RESOURCE_MAIN
+
+#endif //!_PREPROCESSORBASE_H_
diff -pubNr /opt/kde-stable/include/akonadi/private/capabilities_p.h /opt/kde-trunk/include/akonadi/private/capabilities_p.h
--- /opt/kde-stable/include/akonadi/private/capabilities_p.h	1970-01-01 01:00:00.000000000 +0100
+++ /opt/kde-trunk/include/akonadi/private/capabilities_p.h	2009-10-09 08:10:32.000000000 +0200
@@ -0,0 +1,36 @@
+/*
+    Copyright (c) 2009 Volker Krause <vkrause@kde.org>
+
+    This library is free software; you can redistribute it and/or modify it
+    under the terms of the GNU Library General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or (at your
+    option) any later version.
+
+    This library is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
+    License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to the
+    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+    02110-1301, USA.
+*/
+
+#ifndef AKONADI_CAPABILITIES_P_H
+#define AKONADI_CAPABILITIES_P_H
+
+/**
+  @file capabilites_p.h Shared constants for agent capabilities.
+
+  @todo Fill this file with the missing capabilites.
+*/
+
+#define AKONADI_AGENT_CAPABILITY_AUTOSTART "Autostart"
+#define AKONADI_AGENT_CAPABILITY_NOCONFIG "NoConfig"
+#define AKONADI_AGENT_CAPABILITY_PREPROCESSOR "Preprocessor"
+#define AKONADI_AGENT_CAPABILITY_RESOURCE "Resource"
+#define AKONADI_AGENT_CAPABILITY_UNIQUE "Unique"
+#define AKONADI_AGENT_CAPABILITY_VIRTUAL "Virtual"
+
+#endif
diff -pubNr /opt/kde-stable/include/akonadi/private/protocol_p.h /opt/kde-trunk/include/akonadi/private/protocol_p.h
--- /opt/kde-stable/include/akonadi/private/protocol_p.h	2009-10-12 18:10:37.000000000 +0200
+++ /opt/kde-trunk/include/akonadi/private/protocol_p.h	2009-10-09 08:10:32.000000000 +0200
@@ -43,12 +43,15 @@
 #define AKONADI_CMD_ITEMCREATE "X-AKAPPEND"
 #define AKONADI_CMD_ITEMDELETE "REMOVE"
 #define AKONADI_CMD_ITEMFETCH "FETCH"
+#define AKONADI_CMD_ITEMLINK "LINK"
 #define AKONADI_CMD_ITEMMODIFY "STORE"
 #define AKONADI_CMD_ITEMMOVE "MOVE"
+#define AKONADI_CMD_ITEMUNLINK "UNLINK"
 
 #define AKONADI_CMD_UID "UID"
 #define AKONADI_CMD_RESOURCESELECT "RESSELECT"
 #define AKONADI_CMD_RID "RID"
+#define AKONADI_CMD_HRID "HRID"
 
 // Command parameters
 #define AKONADI_PARAM_FULLPAYLOAD "FULLPAYLOAD"
@@ -63,5 +66,7 @@
 #define AKONADI_PARAM_MIMETYPE "MIMETYPE"
 #define AKONADI_PARAM_CACHEPOLICY "CACHEPOLICY"
 #define AKONADI_PARAM_NAME "NAME"
+#define AKONADI_PARAM_RESOURCE "RESOURCE"
+#define AKONADI_PARAM_ANCESTORS "ANCESTORS"
 
 #endif
diff -pubNr /opt/kde-stable/include/akonadi/resourcebase.h /opt/kde-trunk/include/akonadi/resourcebase.h
--- /opt/kde-stable/include/akonadi/resourcebase.h	2009-10-12 18:32:20.000000000 +0200
+++ /opt/kde-trunk/include/akonadi/resourcebase.h	2009-10-09 09:22:21.000000000 +0200
@@ -182,6 +182,7 @@ class AKONADI_EXPORT ResourceBase : publ
       Observer *observer = dynamic_cast<Observer*>( r );
       if ( observer != 0 )
         r->registerObserver( observer );
+
       return init( r );
     }
 
@@ -224,19 +225,19 @@ class AKONADI_EXPORT ResourceBase : publ
      * If incremental retrieval is not possible, provide the full listing by calling
      * itemsRetrieved( const Item::List& ).
      * In any case, ensure that all items have a correctly set remote identifier
-     * to allow synchronizing with already locally existing items.
-     * In case you don't want to use the built-in item syncing code, store the retrived
+     * to allow synchronizing with items already existing locally.
+     * In case you don't want to use the built-in item syncing code, store the retrieved
      * items manually and call itemsRetrieved() once you are done.
-     * @param collection The collection to sync.
-     * @see itemsRetrieved( const Item::List &), itemsRetrievedIncremental(), itemsRetrieved(), currentCollection()
+     * @param collection The collection whose items to retrieve.
+     * @see itemsRetrieved( const Item::List& ), itemsRetrievedIncremental(), itemsRetrieved(), currentCollection()
      */
     virtual void retrieveItems( const Akonadi::Collection &collection ) = 0;
 
     /**
      * Retrieve a single item from the backend. The item to retrieve is provided as @p item.
      * Add the requested payload parts and call itemRetrieved() when done.
-     * @param item The empty item which payload should be retrieved. Use this object when delivering
-     * the result instead of creating a new item to ensure conflict detection to work.
+     * @param item The empty item whose payload should be retrieved. Use this object when delivering
+     * the result instead of creating a new item to ensure conflict detection will work.
      * @param parts The item parts that should be retrieved.
      * @return false if there is an immediate error when retrieving the item.
      * @see itemRetrieved()
@@ -427,6 +428,34 @@ class AKONADI_EXPORT ResourceBase : publ
      */
     void doSetOnline( bool online );
 
+    /**
+     * Indicate the use of hierarchical remote identifiers.
+     * @since 4.4
+     */
+    void setHierarchicalRemoteIdentifiersEnabled( bool enable );
+
+    /**
+     * Schedules a custom task in the internal scheduler. It will be queued with
+     * all other tasks such as change replays and retrieval requests and eventually
+     * executed by calling the specified method.
+     * @param receiver The object the slot should be called on.
+     * @param methodName The name of the method (and only the name, not signature, not SLOT(...) macro),
+     * that should be called to execute this task. The method has to be a slot and take a QVariant as
+     * argument.
+     * @param argument A QVariant argument passed to the method specified above. Use this to pass task
+     * parameters.
+     * @since 4.4
+     */
+    void scheduleCustomTask( QObject* receiver, const char* method, const QVariant &argument );
+
+    /**
+     * Indicate that the current task is finished. Use this method from the slot called via scheduleCustomTaks().
+     * As with all the other callbacks, make sure to either call taskDone() or cancelTask()/deferTask() on all
+     * exit paths, otherwise the resource will hang.
+     * @since 4.4
+     */
+    void taskDone();
+
   private:
     static QString parseArguments( int, char** );
     static int init( ResourceBase *r );
@@ -449,6 +478,9 @@ class AKONADI_EXPORT ResourceBase : publ
     Q_PRIVATE_SLOT( d_func(), void slotCollectionListDone( KJob* ) )
     Q_PRIVATE_SLOT( d_func(), void slotItemSyncDone( KJob* ) )
     Q_PRIVATE_SLOT( d_func(), void slotPercent( KJob*, unsigned long ) )
+    Q_PRIVATE_SLOT( d_func(), void slotPrepareItemRetrieval( const Akonadi::Item& item ) )
+    Q_PRIVATE_SLOT( d_func(), void slotPrepareItemRetrievalResult( KJob* ) )
+    Q_PRIVATE_SLOT( d_func(), void changeCommittedResult( KJob* ) )
 };
 
 }
diff -pubNr /opt/kde-stable/include/akonadi/resourcesynchronizationjob.h /opt/kde-trunk/include/akonadi/resourcesynchronizationjob.h
--- /opt/kde-stable/include/akonadi/resourcesynchronizationjob.h	1970-01-01 01:00:00.000000000 +0100
+++ /opt/kde-trunk/include/akonadi/resourcesynchronizationjob.h	2009-10-09 09:22:21.000000000 +0200
@@ -0,0 +1,90 @@
+/*
+ * Copyright (c) 2009 Volker Krause <vkrause@kde.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef AKONADI_RESOURCESYNCHRONIZATIONJOB_H
+#define AKONADI_RESOURCESYNCHRONIZATIONJOB_H
+
+#include "akonadi_export.h"
+
+#include <kjob.h>
+
+namespace Akonadi {
+
+class AgentInstance;
+class ResourceSynchronizationJobPrivate;
+
+/**
+ * @short Job that synchronizes a resource.
+ *
+ * This job will trigger a resource to synchronize the backend it is
+ * responsible for (e.g. a local file or a groupware server) with the
+ * Akonadi storage.
+ *
+ * If you only want to trigger the synchronization without being
+ * interested in the result, using Akonadi::AgentInstance::synchronize() is enough.
+ * If you want to wait until it's finished, use this class.
+ *
+ * Example:
+ *
+ * @code
+ * using namespace Akonadi;
+ *
+ * const AgentInstance resource = AgentManager::self()->instance( "myresourceidentifier" );
+ *
+ * ResourceSynchronizationJob *job = new ResourceSynchronizationJob( resource );
+ * connect( job, SIGNAL( result( KJob* ) ), SLOT( synchronizationFinished( KJob* ) ) );
+ *
+ * @endcode
+ *
+ * @note This is a KJob not an Akonadi::Job, so it wont auto-start!
+ *
+ * @author Volker Krause <vkrause@kde.org>
+ * @since 4.4
+ */
+class AKONADI_EXPORT ResourceSynchronizationJob : public KJob
+{
+  Q_OBJECT
+
+  public:
+    /**
+     * Creates a new synchronization job for the given resource.
+     *
+     * @param instance The resource instance to synchronize.
+     */
+    explicit ResourceSynchronizationJob( const AgentInstance &instance, QObject *parent = 0 );
+
+    /**
+     * Destroys the synchronization job.
+     */
+    ~ResourceSynchronizationJob();
+
+    /* reimpl */
+    void start();
+
+  private:
+    //@cond PRIVATE
+    ResourceSynchronizationJobPrivate* const d;
+    friend class ResourceSynchronizationJobPrivate;
+
+    Q_PRIVATE_SLOT( d, void slotSynchronized() )
+    Q_PRIVATE_SLOT( d, void slotTimeout() )
+    //@endcond
+};
+
+}
+
+#endif
diff -pubNr /opt/kde-stable/include/akonadi/selectionproxymodel.h /opt/kde-trunk/include/akonadi/selectionproxymodel.h
--- /opt/kde-stable/include/akonadi/selectionproxymodel.h	1970-01-01 01:00:00.000000000 +0100
+++ /opt/kde-trunk/include/akonadi/selectionproxymodel.h	2009-10-09 09:22:21.000000000 +0200
@@ -0,0 +1,65 @@
+/*
+  Copyright (c) 2009 Stephen Kelly <steveire@gmail.com>
+
+  This library is free software; you can redistribute it and/or modify it
+  under the terms of the GNU Library General Public License as published by
+  the Free Software Foundation; either version 2 of the License, or (at your
+  option) any later version.
+
+  This library is distributed in the hope that it will be useful, but WITHOUT
+  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
+  License for more details.
+
+  You should have received a copy of the GNU Library General Public License
+  along with this library; see the file COPYING.LIB.  If not, write to the
+  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+  02110-1301, USA.
+*/
+
+#ifndef AKONADI_SELECTIONPROXYMODEL_H
+#define AKONADI_SELECTIONPROXYMODEL_H
+
+// #include <KDE/SelectionProxyModel>
+
+#include <kselectionproxymodel.h>
+
+#include "akonadi_export.h"
+
+namespace Akonadi
+{
+
+class SelectionProxyModelPrivate;
+
+/**
+  @brief A Proxy Model used to reference count selected Akonadi::Collection in a view
+
+  This model extends KSelectionProxyModel implement reference counting on the Collections
+  in an EntityTreeModel. This should only be used if the EntityTreeModel uses LazyPopulation.
+
+  By selecting a Collection, its reference count will be increased. A Collection in the
+  EntityTreeModel which has a reference count of zero will ignore all signals from Monitor
+  about items changed, inserted, removed etc, which can be expensive operations.
+
+  @since 4.4
+*/
+class AKONADI_EXPORT SelectionProxyModel : public KSelectionProxyModel
+{
+  Q_OBJECT
+public:
+  /**
+    Constructor
+  */
+  explicit SelectionProxyModel( QItemSelectionModel *selectionModel, QObject *parent = 0 );
+
+private:
+  Q_PRIVATE_SLOT( d_func(), void rootIndexAdded( const QModelIndex & ) )
+  Q_PRIVATE_SLOT( d_func(), void rootIndexAboutToBeRemoved( const QModelIndex & ) )
+
+  Q_DECLARE_PRIVATE( SelectionProxyModel )
+  SelectionProxyModelPrivate *d_ptr;
+};
+
+}
+
+#endif
diff -pubNr /opt/kde-stable/include/akonadi/standardactionmanager.h /opt/kde-trunk/include/akonadi/standardactionmanager.h
--- /opt/kde-stable/include/akonadi/standardactionmanager.h	2009-10-12 18:32:20.000000000 +0200
+++ /opt/kde-trunk/include/akonadi/standardactionmanager.h	2009-10-09 09:22:21.000000000 +0200
@@ -32,6 +32,8 @@ class QWidget;
 
 namespace Akonadi {
 
+class FavoriteCollectionsModel;
+
 /**
  * @short Manages generic actions for collection and item views.
  *
@@ -103,6 +105,11 @@ class AKONADI_EXPORT StandardActionManag
       Paste,                     ///< Paste collections or items
       DeleteItems,               ///< Deletes items
       ManageLocalSubscriptions,  ///< Manages local subscriptions
+      AddToFavoriteCollections,  ///< Add the collection to the favorite collections model
+      RemoveFromFavoriteCollections,  ///< Remove the collection from the favorite collections model
+      RenameFavoriteCollection,  ///< Rename the collection of the favorite collections model
+      CopyCollectionToMenu,      ///< Menu allowing to quickly copy a collection into another collection
+      CopyItemToMenu,            ///< Menu allowing to quickly copy an item into a collection
       LastType                   ///< Marks last action
     };
 
@@ -133,6 +140,24 @@ class AKONADI_EXPORT StandardActionManag
     void setItemSelectionModel( QItemSelectionModel* selectionModel );
 
     /**
+     * Sets the favorite collections model based on which the collection
+     * relatedactions should operate. If none is set, the "Add to Favorite Folders" action
+     * will be disabled.
+     *
+     * @since 4.4
+     */
+    void setFavoriteCollectionsModel( FavoriteCollectionsModel *favoritesModel );
+
+    /**
+     * Sets the favorite collection selection model based on which the favorite
+     * collection related actions should operate. If none is set, all favorite modifications
+     * actions will be disabled.
+     *
+     * @since 4.4
+     */
+    void setFavoriteSelectionModel( QItemSelectionModel *selectionModel );
+
+    /**
      * Creates the action of the given type and adds it to the action collection
      * specified in the constructor if it does not exist yet. The action is
      * connected to its default implementation provided by this class.
@@ -179,6 +204,8 @@ class AKONADI_EXPORT StandardActionManag
 
     Q_PRIVATE_SLOT( d, void updateActions() )
     Q_PRIVATE_SLOT( d, void clipboardChanged(QClipboard::Mode) )
+    Q_PRIVATE_SLOT( d, void collectionSelectionChanged() )
+    Q_PRIVATE_SLOT( d, void favoriteSelectionChanged() )
 
     Q_PRIVATE_SLOT( d, void slotCreateCollection() )
     Q_PRIVATE_SLOT( d, void slotCopyCollections() )
@@ -189,10 +216,16 @@ class AKONADI_EXPORT StandardActionManag
     Q_PRIVATE_SLOT( d, void slotPaste() )
     Q_PRIVATE_SLOT( d, void slotDeleteItems() )
     Q_PRIVATE_SLOT( d, void slotLocalSubscription() )
+    Q_PRIVATE_SLOT( d, void slotAddToFavorites() )
+    Q_PRIVATE_SLOT( d, void slotRemoveFromFavorites() )
+    Q_PRIVATE_SLOT( d, void slotRenameFavorite() )
+    Q_PRIVATE_SLOT( d, void slotCopyCollectionTo(QAction*) )
+    Q_PRIVATE_SLOT( d, void slotCopyItemTo(QAction*) )
 
     Q_PRIVATE_SLOT( d, void collectionCreationResult(KJob*) )
     Q_PRIVATE_SLOT( d, void collectionDeletionResult(KJob*) )
     Q_PRIVATE_SLOT( d, void pasteResult(KJob*) )
+    Q_PRIVATE_SLOT( d, void copyToResult(KJob*) )
     //@endcond
 };
 
diff -pubNr /opt/kde-stable/include/akonadi/statisticsproxymodel.h /opt/kde-trunk/include/akonadi/statisticsproxymodel.h
--- /opt/kde-stable/include/akonadi/statisticsproxymodel.h	1970-01-01 01:00:00.000000000 +0100
+++ /opt/kde-trunk/include/akonadi/statisticsproxymodel.h	2009-10-09 09:22:21.000000000 +0200
@@ -0,0 +1,87 @@
+/*
+    Copyright (c) 2009 Kevin Ottens <ervin@kde.org>
+
+    This library is free software; you can redistribute it and/or modify it
+    under the terms of the GNU Library General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or (at your
+    option) any later version.
+
+    This library is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
+    License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to the
+    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+    02110-1301, USA.
+*/
+
+#ifndef AKONADI_STATISTICSPROXYMODEL_H
+#define AKONADI_STATISTICSPROXYMODEL_H
+
+#include "akonadi_export.h"
+
+#include <QtGui/QSortFilterProxyModel>
+
+namespace Akonadi {
+
+/**
+ * @short A proxy model that exposes collection statistics through extra columns.
+ *
+ * This class can be used on top of an EntityTreeModel to display extra columns
+ * summarizing statistics of collections.
+ *
+ * @code
+ *
+ *   Akonadi::EntityTreeModel *model = new Akonadi::EntityTreeModel( ... );
+ *
+ *   Akonadi::StatisticsProxyModel *proxy = new Akonadi::StatisticsProxyModel();
+ *   proxy->setSourceModel( model );
+ *
+ *   Akonadi::EntityTreeView *view = new Akonadi::EntityTreeView( this );
+ *   view->setModel( proxy );
+ *
+ * @endcode
+ *
+ * @author Kevin Ottens <ervin@kde.org>
+ * @since 4.4
+ */
+class AKONADI_EXPORT StatisticsProxyModel : public QSortFilterProxyModel
+{
+  Q_OBJECT
+
+  public:
+    /**
+     * Creates a new statistics proxy model.
+     *
+     * @param parent The parent object.
+     */
+    explicit StatisticsProxyModel( QObject *parent = 0 );
+
+    /**
+     * Destroys the statistics proxy model.
+     */
+    virtual ~StatisticsProxyModel();
+
+    virtual QModelIndex index ( int row, int column, const QModelIndex & parent = QModelIndex() ) const;
+    virtual QVariant data( const QModelIndex & index, int role = Qt::DisplayRole ) const;
+    virtual QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const;
+    virtual Qt::ItemFlags flags ( const QModelIndex & index ) const;
+    virtual int columnCount( const QModelIndex & parent = QModelIndex() ) const;
+
+    // QAbstractProxyModel does not proxy all methods...
+    virtual bool dropMimeData( const QMimeData * data, Qt::DropAction action, int row, int column, const QModelIndex & parent );
+    virtual QMimeData* mimeData( const QModelIndexList & indexes ) const;
+    virtual QStringList mimeTypes() const;
+
+  private:
+    //@cond PRIVATE
+    class Private;
+    Private* const d;
+    //@endcond
+};
+
+}
+
+#endif
diff -pubNr /opt/kde-stable/include/akonadi/statisticstooltipproxymodel.h /opt/kde-trunk/include/akonadi/statisticstooltipproxymodel.h
--- /opt/kde-stable/include/akonadi/statisticstooltipproxymodel.h	1970-01-01 01:00:00.000000000 +0100
+++ /opt/kde-trunk/include/akonadi/statisticstooltipproxymodel.h	2009-10-09 09:22:21.000000000 +0200
@@ -0,0 +1,81 @@
+/*
+    Copyright (c) 2009 Kevin Ottens <ervin@kde.org>
+
+    This library is free software; you can redistribute it and/or modify it
+    under the terms of the GNU Library General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or (at your
+    option) any later version.
+
+    This library is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
+    License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to the
+    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+    02110-1301, USA.
+*/
+
+#ifndef AKONADI_STATISTICSTOOLTIPPROXYMODEL_H
+#define AKONADI_STATISTICSTOOLTIPPROXYMODEL_H
+
+#include <QtGui/QSortFilterProxyModel>
+#include "akonadi_export.h"
+namespace Akonadi {
+
+/**
+ * @short A proxy model that exposes collection statistics through a tooltip.
+ *
+ * This class can be used on top of an EntityTreeModel to display a tooltip
+ * summarizing statistics of collections.
+ *
+ * @code
+ *
+ *   Akonadi::EntityTreeModel *model = new Akonadi::EntityTreeModel( ... );
+ *
+ *   Akonadi::StatisticsToolTipProxyModel *proxy = new Akonadi::StatisticsToolTipProxyModel();
+ *   proxy->setSourceModel( model );
+ *
+ *   Akonadi::EntityTreeView *view = new Akonadi::EntityTreeView( this );
+ *   view->setModel( proxy );
+ *
+ * @endcode
+ *
+ * @author Kevin Ottens <ervin@kde.org>
+ * @since 4.4
+ */
+class AKONADI_EXPORT StatisticsToolTipProxyModel : public QSortFilterProxyModel
+{
+  Q_OBJECT
+
+  public:
+    /**
+     * Creates a new statistics tooltip proxy model.
+     *
+     * @param parent The parent object.
+     */
+    explicit StatisticsToolTipProxyModel( QObject *parent = 0 );
+
+    /**
+     * Destroys the statistics tooltip proxy model.
+     */
+    virtual ~StatisticsToolTipProxyModel();
+
+    virtual QVariant data( const QModelIndex & index, int role = Qt::DisplayRole ) const;
+
+    // QAbstractProxyModel does not proxy all methods...
+    virtual bool dropMimeData( const QMimeData * data, Qt::DropAction action, int row, int column, const QModelIndex & parent );
+    virtual QMimeData* mimeData( const QModelIndexList & indexes ) const;
+    virtual QStringList mimeTypes() const;
+
+  private:
+    //@cond PRIVATE
+    class Private;
+    Private* const d;
+    //@endcond
+};
+
+}
+
+#endif
diff -pubNr /opt/kde-stable/include/akonadi/transportresourcebase.h /opt/kde-trunk/include/akonadi/transportresourcebase.h
--- /opt/kde-stable/include/akonadi/transportresourcebase.h	1970-01-01 01:00:00.000000000 +0100
+++ /opt/kde-trunk/include/akonadi/transportresourcebase.h	2009-10-09 09:22:21.000000000 +0200
@@ -0,0 +1,81 @@
+/*
+    Copyright (c) 2009 Constantin Berzan <exit3219@gmail.com>
+
+    This library is free software; you can redistribute it and/or modify it
+    under the terms of the GNU Library General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or (at your
+    option) any later version.
+
+    This library is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
+    License for more details.
+
+    You should have received a copy of the GNU Library General Public License
+    along with this library; see the file COPYING.LIB.  If not, write to the
+    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+    02110-1301, USA.
+*/
+
+#ifndef AKONADI_TRANSPORTRESOURCEBASE_H
+#define AKONADI_TRANSPORTRESOURCEBASE_H
+
+#include "akonadi_export.h"
+
+#include <QtCore/QString>
+
+#include <akonadi/item.h>
+
+class KJob;
+
+namespace Akonadi {
+
+class TransportResourceBasePrivate;
+
+/**
+  * @short Resource implementing mail transport capability.
+  *
+  * To implement a transport-enabled resource, inherit from both
+  * ResourceBase and TransportResourceBase, implement the virtual method
+  * sendItem(), and call emitTransportResult() when finished sending.
+  * The resource must also have the "MailTransport" capability flag.
+  *
+  * For an example of a transport-enabled resource, see
+  * kdepim/akonadi/resources/mailtransport_dummy.
+  *
+  * @author Constantin Berzan <exit3219@gmail.com>
+  * @since 4.4
+ */
+class AKONADI_EXPORT TransportResourceBase
+{
+  public:
+    TransportResourceBase();
+    virtual ~TransportResourceBase();
+
+    /**
+      Reimplement in your resource, to begin the actual sending operation.
+      Call emitTransportResult() when finished.
+      @param message The ID of the message to be sent.
+      @see emitTransportResult.
+    */
+    virtual void sendItem( Akonadi::Item::Id message ) = 0;
+
+    // TODO add void emitSendProgress( int percent );
+
+    /**
+     * Emits the transportResult() DBus signal with the given arguments.
+     * @param item The id of the item that was sent.
+     * @param success True if the sending operation succeeded.
+     * @param message An optional textual explanation of the result.
+     * @see Transport.
+     */
+    void emitTransportResult( Akonadi::Item::Id &item, bool success,
+                              const QString &message = QString() );
+
+  private:
+    TransportResourceBasePrivate *const d;
+};
+
+} // namespace Akonadi
+
+#endif // AKONADI_TRANSPORTRESOURCEBASE_H
diff -pubNr /opt/kde-stable/include/akonadi/unlinkjob.h /opt/kde-trunk/include/akonadi/unlinkjob.h
--- /opt/kde-stable/include/akonadi/unlinkjob.h	2009-10-12 18:32:20.000000000 +0200
+++ /opt/kde-trunk/include/akonadi/unlinkjob.h	2009-10-09 09:22:21.000000000 +0200
@@ -81,6 +81,7 @@ class AKONADI_EXPORT UnlinkJob : public 
 
   private:
     Q_DECLARE_PRIVATE( UnlinkJob )
+    template <typename T> friend class LinkJobImpl;
 };
 
 }
