diff -pubNr /opt/kde-stable/include/mailtransport/dispatcherinterface.h /opt/kde-trunk/include/mailtransport/dispatcherinterface.h
--- /opt/kde-stable/include/mailtransport/dispatcherinterface.h	1970-01-01 01:00:00.000000000 +0100
+++ /opt/kde-trunk/include/mailtransport/dispatcherinterface.h	2009-10-09 09:21:57.000000000 +0200
@@ -0,0 +1,87 @@
+/*
+    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 MAILTRANSPORT_DISPATCHERINTERFACE_H
+#define MAILTRANSPORT_DISPATCHERINTERFACE_H
+
+#include <mailtransport/mailtransport_export.h>
+
+#include <QtCore/QObject>
+
+#include <akonadi/agentinstance.h>
+
+namespace MailTransport {
+
+class DispatcherInterfacePrivate;
+
+/**
+  @short An interface for applications to interact with the dispatcher agent.
+
+  This class provides methods such as send queued messages (@see
+  dispatchManually) and retry sending (@see retryDispatching).
+
+  This class also takes care of registering the attributes that the MDA and
+  MailTransport use.  The attributes are registered the first time you call
+  self(), so do that early in your application.
+
+  @author Constantin Berzan <exit3219@gmail.com>
+  @since 4.4
+*/
+class MAILTRANSPORT_EXPORT DispatcherInterface : public QObject
+{
+  Q_OBJECT
+
+  public:
+    /**
+      Returns the DispatcherInterface instance.
+    */
+    static DispatcherInterface *self();
+
+    /**
+      Returns the current instance of the MDA.  May return an invalid
+      AgentInstance in case it cannot find the MDA.
+    */
+    Akonadi::AgentInstance dispatcherInstance() const;
+
+    /**
+      Looks for messages in the outbox with DispatchMode::Never and marks them
+      DispatchMode::Immediately for sending.
+    */
+    void dispatchManually();
+
+    /**
+      Looks for messages in the outbox with ErrorAttribute, and clears them and
+      queues them again for sending.
+    */
+    void retryDispatching();
+
+  private:
+    friend class DispatcherInterfacePrivate;
+    DispatcherInterfacePrivate *const d;
+
+    // singleton class; the only instance resides in sInstance->instance
+    DispatcherInterface( DispatcherInterfacePrivate *dd );
+
+    Q_PRIVATE_SLOT( d, void massModifyResult( KJob* ) )
+
+};
+
+} // namespace MailTransport
+
+#endif // MAILTRANSPORT_DISPATCHERINTERFACE_H
diff -pubNr /opt/kde-stable/include/mailtransport/dispatchmodeattribute.h /opt/kde-trunk/include/mailtransport/dispatchmodeattribute.h
--- /opt/kde-stable/include/mailtransport/dispatchmodeattribute.h	1970-01-01 01:00:00.000000000 +0100
+++ /opt/kde-trunk/include/mailtransport/dispatchmodeattribute.h	2009-10-09 09:21:57.000000000 +0200
@@ -0,0 +1,101 @@
+/*
+    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 MAILTRANSPORT_DISPATCHMODEATTRIBUTE_H
+#define MAILTRANSPORT_DISPATCHMODEATTRIBUTE_H
+
+#include <mailtransport/mailtransport_export.h>
+
+#include <QtCore/QDateTime>
+
+#include <akonadi/attribute.h>
+
+namespace MailTransport {
+
+/**
+  Attribute determining how and when a message from the outbox should be
+  dispatched.  Messages can be sent immediately, sent only when the user
+  explicitly requests it, or sent automatically at a certain date and time.
+
+  @author Constantin Berzan <exit3219@gmail.com>
+  @since 4.4
+*/
+class MAILTRANSPORT_EXPORT DispatchModeAttribute : public Akonadi::Attribute
+{
+  public:
+    /**
+      Determines how the message is sent.
+    */
+    enum DispatchMode {
+      Immediately,  ///< Send message as soon as possible.
+      AfterDueDate, ///< Send message at a certain date/time.
+      Never         ///< Send message only when the user requests so.
+    };
+
+    /**
+      Creates a new DispatchModeAttribute.
+    */
+    explicit DispatchModeAttribute( DispatchMode mode = Immediately,
+                                    const QDateTime &date = QDateTime() );
+
+    /**
+      Destroys the DispatchModeAttribute.
+    */
+    virtual ~DispatchModeAttribute();
+
+    /* reimpl */
+    virtual DispatchModeAttribute *clone() const;
+    virtual QByteArray type() const;
+    virtual QByteArray serialized() const;
+    virtual void deserialize( const QByteArray &data );
+
+    /**
+      Returns the dispatch mode for the message.
+      @see DispatchMode.
+    */
+    DispatchMode dispatchMode() const;
+
+    /**
+      Sets the dispatch mode for the message.
+      @see DispatchMode.
+    */
+    void setDispatchMode( DispatchMode mode );
+
+    /**
+      Returns the date and time when the message should be sent.
+      Only valid if dispatchMode() is AfterDueDate.
+    */
+    QDateTime dueDate() const;
+
+    /**
+      Sets the date and time when the message should be sent.
+      Make sure you set the DispatchMode to AfterDueDate first.
+      @see setDispatchMode.
+    */
+    void setDueDate( const QDateTime &date );
+
+  private:
+    class Private;
+    Private *const d;
+
+};
+
+} // namespace MailTransport
+
+#endif // MAILTRANSPORT_DISPATCHMODEATTRIBUTE_H
diff -pubNr /opt/kde-stable/include/mailtransport/errorattribute.h /opt/kde-trunk/include/mailtransport/errorattribute.h
--- /opt/kde-stable/include/mailtransport/errorattribute.h	1970-01-01 01:00:00.000000000 +0100
+++ /opt/kde-trunk/include/mailtransport/errorattribute.h	2009-10-09 09:21:58.000000000 +0200
@@ -0,0 +1,75 @@
+/*
+    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 MAILTRANSPORT_ERRORATTRIBUTE_H
+#define MAILTRANSPORT_ERRORATTRIBUTE_H
+
+#include <mailtransport/mailtransport_export.h>
+
+#include <QtCore/QString>
+
+#include <akonadi/attribute.h>
+
+namespace MailTransport {
+
+/**
+  Attribute given to the messages that failed to be sent.  Contains the error
+  message encountered.
+
+  @author Constantin Berzan <exit3219@gmail.com>
+  @since 4.4
+*/
+class MAILTRANSPORT_EXPORT ErrorAttribute : public Akonadi::Attribute
+{
+  public:
+    /**
+      Creates a new ErrorAttribute.
+    */
+    ErrorAttribute( const QString &msg = QString() );
+
+    /**
+      Destroys this ErrorAttribute.
+    */
+    virtual ~ErrorAttribute();
+
+    /* reimpl */
+    virtual ErrorAttribute *clone() const;
+    virtual QByteArray type() const;
+    virtual QByteArray serialized() const;
+    virtual void deserialize( const QByteArray &data );
+
+    /**
+      Returns the i18n'ed error message.
+    */
+    QString message() const;
+
+    /**
+      Sets the error message.
+    */
+    void setMessage( const QString &msg );
+
+  private:
+    class Private;
+    Private *const d;
+
+};
+
+} // namespace MailTransport
+
+#endif // MAILTRANSPORT_ERRORATTRIBUTE_H
diff -pubNr /opt/kde-stable/include/mailtransport/mailtransport_export.h /opt/kde-trunk/include/mailtransport/mailtransport_export.h
--- /opt/kde-stable/include/mailtransport/mailtransport_export.h	2009-10-12 18:32:09.000000000 +0200
+++ /opt/kde-trunk/include/mailtransport/mailtransport_export.h	2009-10-09 09:21:58.000000000 +0200
@@ -32,4 +32,19 @@
 # endif
 #endif
 
+// TODO KDE5: Get rid of all this.
+#ifndef MAILTRANSPORT_DEPRECATED
+# if defined( USES_DEPRECATED_MAILTRANSPORT_API )
+   /* Avoid deprecated warnings from ourselves and the MDA. */
+#  define MAILTRANSPORT_DEPRECATED
+# else
+   /* Show deprecated warnings for anyone else. */
+#  define MAILTRANSPORT_DEPRECATED KDE_DEPRECATED
+# endif
+#endif
+
+#ifndef MAILTRANSPORT_EXPORT_DEPRECATED
+# define MAILTRANSPORT_EXPORT_DEPRECATED MAILTRANSPORT_DEPRECATED MAILTRANSPORT_EXPORT
+#endif
+
 #endif
diff -pubNr /opt/kde-stable/include/mailtransport/messagequeuejob.h /opt/kde-trunk/include/mailtransport/messagequeuejob.h
--- /opt/kde-stable/include/mailtransport/messagequeuejob.h	1970-01-01 01:00:00.000000000 +0100
+++ /opt/kde-trunk/include/mailtransport/messagequeuejob.h	2009-10-09 09:21:58.000000000 +0200
@@ -0,0 +1,255 @@
+/*
+    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 MAILTRANSPORT_MESSAGEQUEUEJOB_H
+#define MAILTRANSPORT_MESSAGEQUEUEJOB_H
+
+#include <mailtransport/mailtransport_export.h>
+
+#include "dispatchmodeattribute.h"
+#include "sentbehaviourattribute.h"
+
+#include <QtCore/QDateTime>
+#include <QtCore/QString>
+#include <QtCore/QStringList>
+
+#include <KDE/KCompositeJob>
+
+#include <akonadi/collection.h>
+
+#include <kmime/kmime_message.h>
+#include <boost/shared_ptr.hpp>
+
+namespace MailTransport {
+
+/**
+  @short Provides an interface for sending email.
+
+  This class takes a KMime::Message and some related info such as sender and
+  recipient addresses, and places the message in the outbox.  The mail
+  dispatcher agent will then take it from there and send it.
+
+  This is the preferred way for applications to send email.
+
+  This job requires some options to be set before being started.  These are
+  setMessage, setTransportId, setFrom, and one of setTo, setCc, or setBcc.
+  Other settings are optional: setDispatchMode, setSentBehaviour.
+
+  Example:
+  @code
+
+  MessageQueueJob *job = new MessageQueueJob( this );
+  job->setMessage( msg ); // msg is a Message::Ptr
+  job->setTransportId( TransportManager::self()->defaultTransportId() );
+  // Use the default dispatch mode.
+  // Use the default sent-behaviour.
+  job->setFrom( from ); // from is a QString
+  job->setTo( to ); // to is a QStringList
+  connect( job, SIGNAL(result(KJob*)), this, SLOT(jobResult(KJob*)) );
+  job->start();
+
+  @endcode
+
+  @see DispatchModeAttribute
+  @see SentBehaviourAttribute
+
+  @author Constantin Berzan <exit3219@gmail.com>
+  @since 4.4
+*/
+class MAILTRANSPORT_EXPORT MessageQueueJob : public KCompositeJob
+{
+  Q_OBJECT
+
+  public:
+    /**
+      Creates a new MessageQueueJob.
+      This is not an autostarting job; you need to call start() yourself.
+    */
+    explicit MessageQueueJob( QObject *parent = 0 );
+
+    /**
+      Destroys the MessageQueueJob.
+      This job deletes itself after finishing.
+    */
+    virtual ~MessageQueueJob();
+
+    /**
+      Returns the message to be sent.
+    */
+    KMime::Message::Ptr message() const;
+
+    /**
+      Returns the transport id to use for sending the message.
+      @see TransportManager.
+    */
+    int transportId() const;
+
+    /**
+      Returns the dispatch mode for this message.
+      @see DispatchModeAttribute.
+    */
+    DispatchModeAttribute::DispatchMode dispatchMode() const;
+
+    /**
+      Returns the date and time when this message should be sent.
+      Only valid if dispatchMode() is AfterDueDate.
+      @see DispatchModeAttribute.
+    */
+    QDateTime sendDueDate() const;
+
+    /**
+      Returns the sent-behaviour of this message.
+      This determines what will happen to the message after it is sent.
+      @see SentBehaviourAttribute.
+    */
+    SentBehaviourAttribute::SentBehaviour sentBehaviour() const;
+
+    /**
+      Returns the collection to which the message will be moved after it is
+      sent.
+      Only valid if sentBehaviour() is MoveToCollection.
+      @see SentBehaviourAttribute.
+    */
+    Akonadi::Collection::Id moveToCollection() const;
+
+    /**
+      Returns the address of the sender.
+    */
+    QString from() const;
+
+    /**
+      Returns the addresses of the "To:" receivers.
+    */
+    QStringList to() const;
+
+    /**
+      Returns the addresses of the "Cc:" receivers.
+    */
+    QStringList cc() const;
+
+    /**
+      Returns the addresses of the "Bcc:" receivers.
+    */
+    QStringList bcc() const;
+
+    /**
+      Sets the message to be sent.
+    */
+    void setMessage( KMime::Message::Ptr message );
+
+    /**
+      Sets the transport id to use for sending the message.  If you want to
+      use the default transport, you must specify so explicitly:
+
+      @code
+      job->setTransportId( TransportManager::self()->defaultTransportId() );
+      @endcode
+
+      @see TransportManager.
+    */
+    void setTransportId( int id );
+
+    /**
+      Sets the dispatch mode for this message.
+      The default dispatch mode is Immediately (meaning the message will be
+      sent as soon as possible).
+      @see DispatchModeAttribute.
+    */
+    void setDispatchMode( DispatchModeAttribute::DispatchMode mode );
+
+    /**
+      Sets the date and time when this message should be sent.
+
+      @code
+      job->setDispatchMode( DispatchModeAttribute::AfterDueDate );
+      job->setDueDate( ... );
+      @endcode
+
+      @see DispatchModeAttribute.
+    */
+    void setDueDate( const QDateTime &date );
+
+    /**
+      Sets the sent-behaviour of this message.
+      This determines what will happen to the message after it is sent.
+      The default sent-behaviour is MoveToDefaultSentCollection, which moves
+      the message to the default sent-mail collection.
+      @see SentBehaviourAttribute.
+    */
+    void setSentBehaviour( SentBehaviourAttribute::SentBehaviour beh );
+
+    /**
+      Sets the collection to which the message will be moved after it is
+      sent.
+
+      @code
+      job->setSentBehaviour( SentBehaviourAttribute::MoveToCollection );
+      job->setMoveToCollection( ... );
+      @endcode
+
+      @see SentBehaviourAttribute.
+    */
+    void setMoveToCollection( Akonadi::Collection::Id cid );
+
+    /**
+      Sets the address of the sender.
+    */
+    void setFrom( const QString &from );
+
+    /**
+      Sets the addresses of the "To:" receivers."
+    */
+    void setTo( const QStringList &to );
+
+    /**
+      Sets the addresses of the "Cc:" receivers."
+    */
+    void setCc( const QStringList &cc );
+
+    /**
+      Sets the addresses of the "Bcc:" receivers."
+    */
+    void setBcc( const QStringList &bcc );
+
+    /**
+      Creates the item and places it in the outbox.
+      It is now queued for sending by the mail dispatcher agent.
+    */
+    virtual void start();
+
+  protected Q_SLOTS:
+    /**
+      Called when the ItemCreateJob subjob finishes.
+
+      (reimplemented from KCompositeJob)
+    */
+    virtual void slotResult( KJob * );
+
+  private:
+    class Private;
+    friend class Private;
+    Private *const d;
+
+    Q_PRIVATE_SLOT( d, void outboxRequestResult( KJob* ) )
+
+};
+
+} // namespace MailTransport
+
+#endif // MAILTRANSPORT_MESSAGEQUEUEJOB_H
diff -pubNr /opt/kde-stable/include/mailtransport/outboxactions.h /opt/kde-trunk/include/mailtransport/outboxactions.h
--- /opt/kde-stable/include/mailtransport/outboxactions.h	1970-01-01 01:00:00.000000000 +0100
+++ /opt/kde-trunk/include/mailtransport/outboxactions.h	2009-10-09 09:21:57.000000000 +0200
@@ -0,0 +1,101 @@
+/*
+    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 MAILTRANSPORT_OUTBOXACTIONS_H
+#define MAILTRANSPORT_OUTBOXACTIONS_H
+
+#include <mailtransport/mailtransport_export.h>
+
+#include <akonadi/itemfetchscope.h>
+#include <akonadi/job.h>
+#include <akonadi/filteractionjob.h>
+
+namespace MailTransport {
+
+/**
+  FilterAction that finds all messages with a DispatchMode of Never
+  and assigns them a DispatchMode of Immediately.
+
+  This is used to send "queued" messages on demand.
+
+  @see FilterActionJob
+
+  @author Constantin Berzan <exit3219@gmail.com>
+  @since 4.4
+*/
+class MAILTRANSPORT_EXPORT SendQueuedAction : public Akonadi::FilterAction
+{
+  public:
+    /** Creates a SendQueuedAction. */
+    SendQueuedAction();
+
+    /** Destroys this object. */
+    virtual ~SendQueuedAction();
+
+    /* reimpl */
+    virtual Akonadi::ItemFetchScope fetchScope() const;
+
+    /* reimpl */
+    virtual bool itemAccepted( const Akonadi::Item &item ) const;
+
+    /* reimpl */
+    virtual Akonadi::Job *itemAction( const Akonadi::Item &item ) const;
+
+  private:
+    class Private;
+    Private *const d;
+};
+
+/**
+  FilterAction that finds all messages with an ErrorAttribute,
+  removes the attribute, and sets the "queued" flag.
+
+  This is used to retry sending messages that failed.
+
+  @see FilterActionJob
+
+  @author Constantin Berzan <exit3219@gmail.com>
+  @since 4.4
+*/
+class MAILTRANSPORT_EXPORT ClearErrorAction : public Akonadi::FilterAction
+{
+  public:
+    /** Creates a ClearErrorAction. */
+    ClearErrorAction();
+
+    /** Destroys this object. */
+    virtual ~ClearErrorAction();
+
+    /* reimpl */
+    virtual Akonadi::ItemFetchScope fetchScope() const;
+
+    /* reimpl */
+    virtual bool itemAccepted( const Akonadi::Item &item ) const;
+
+    /* reimpl */
+    virtual Akonadi::Job *itemAction( const Akonadi::Item &item ) const;
+
+  private:
+    class Private;
+    Private *const d;
+};
+
+} // namespace MailTransport
+
+#endif // MAILTRANSPORT_OUTBOXACTIONS_H
diff -pubNr /opt/kde-stable/include/mailtransport/resourcesendjob.h /opt/kde-trunk/include/mailtransport/resourcesendjob.h
--- /opt/kde-stable/include/mailtransport/resourcesendjob.h	1970-01-01 01:00:00.000000000 +0100
+++ /opt/kde-trunk/include/mailtransport/resourcesendjob.h	2009-10-09 09:21:57.000000000 +0200
@@ -0,0 +1,74 @@
+/*
+    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 MAILTRANSPORT_RESOURCESENDJOB_H
+#define MAILTRANSPORT_RESOURCESENDJOB_H
+
+#include <mailtransport/transportjob.h>
+
+#include <akonadi/item.h>
+
+namespace MailTransport {
+
+class ResourceSendJobPrivate;
+
+/**
+  Mail transport job for an Akonadi resource-based transport.
+
+  This is a wrapper job that makes old applications work with resource-based
+  transports.  It calls the appropriate methods in MessageQueueJob, and emits
+  result() as soon as the item is placed in the outbox, since there is no way
+  of monitoring the progress from here.
+
+  @deprecated Use MessageQueueJob for placing messages in the outbox.
+
+  @author Constantin Berzan <exit3219@gmail.com>
+  @since 4.4
+*/
+class MAILTRANSPORT_EXPORT_DEPRECATED ResourceSendJob : public TransportJob
+{
+  Q_OBJECT
+  public:
+    /**
+      Creates an ResourceSendJob.
+      @param transport The transport object to use.
+      @param parent The parent object.
+    */
+    explicit ResourceSendJob( Transport *transport, QObject *parent = 0 );
+
+    /**
+      Destroys this job.
+    */
+    virtual ~ResourceSendJob();
+
+  protected:
+    /** reimpl */
+    virtual void doStart();
+
+  private:
+    friend class ResourceSendJobPrivate;
+    ResourceSendJobPrivate *const d;
+
+    Q_PRIVATE_SLOT( d, void slotEmitResult() )
+
+};
+
+} // namespace MailTransport
+
+#endif // MAILTRANSPORT_RESOURCESENDJOB_H
diff -pubNr /opt/kde-stable/include/mailtransport/sendmailjob.h /opt/kde-trunk/include/mailtransport/sendmailjob.h
--- /opt/kde-stable/include/mailtransport/sendmailjob.h	2009-10-12 18:32:09.000000000 +0200
+++ /opt/kde-trunk/include/mailtransport/sendmailjob.h	2009-10-09 09:21:58.000000000 +0200
@@ -27,14 +27,17 @@
 #include <mailtransport/transportjob.h>
 
 #include <QtCore/QProcess>
+
 class SendMailJobPrivate;
 
 namespace MailTransport {
 
 /**
   Mail transport job for sendmail.
+
+  @deprecated Use MessageQueueJob for sending e-mail.
 */
-class MAILTRANSPORT_EXPORT SendmailJob : public TransportJob
+class MAILTRANSPORT_EXPORT_DEPRECATED SendmailJob : public TransportJob
 {
   Q_OBJECT
   public:
@@ -63,6 +66,6 @@ class MAILTRANSPORT_EXPORT SendmailJob :
     SendMailJobPrivate *const d;
 };
 
-}
+} // namespace MailTransport
 
-#endif
+#endif // MAILTRANSPORT_SENDMAILJOB_H
diff -pubNr /opt/kde-stable/include/mailtransport/sentbehaviourattribute.h /opt/kde-trunk/include/mailtransport/sentbehaviourattribute.h
--- /opt/kde-stable/include/mailtransport/sentbehaviourattribute.h	1970-01-01 01:00:00.000000000 +0100
+++ /opt/kde-trunk/include/mailtransport/sentbehaviourattribute.h	2009-10-09 09:21:57.000000000 +0200
@@ -0,0 +1,100 @@
+/*
+    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 MAILTRANSPORT_SENTBEHAVIOURATTRIBUTE_H
+#define MAILTRANSPORT_SENTBEHAVIOURATTRIBUTE_H
+
+#include <mailtransport/mailtransport_export.h>
+
+#include <akonadi/attribute.h>
+#include <akonadi/collection.h>
+
+namespace MailTransport {
+
+/**
+  Attribute determining what will happen to a message after it is sent.  The
+  message can be deleted from the Outbox, moved to the default sent-mail
+  collection, or moved to a custom collection.
+
+  @author Constantin Berzan <exit3219@gmail.com>
+  @since 4.4
+*/
+class MAILTRANSPORT_EXPORT SentBehaviourAttribute : public Akonadi::Attribute
+{
+  public:
+    /**
+      What to do with the item in the outbox after it has been sent successfully.
+    */
+    enum SentBehaviour {
+      Delete,                      ///< Delete the item from the outbox.
+      MoveToCollection,            ///< Move the item to a custom collection.
+      MoveToDefaultSentCollection  ///< Move the item to the default sent-mail collection.
+    };
+
+    /**
+      Creates a new SentBehaviourAttribute.
+    */
+    explicit SentBehaviourAttribute( SentBehaviour beh = MoveToDefaultSentCollection,
+        Akonadi::Collection::Id moveToCollection = -1 );
+
+    /**
+      Destroys the SentBehaviourAttribute.
+    */
+    virtual ~SentBehaviourAttribute();
+
+    /* reimpl */
+    virtual SentBehaviourAttribute *clone() const;
+    virtual QByteArray type() const;
+    virtual QByteArray serialized() const;
+    virtual void deserialize( const QByteArray &data );
+
+    /**
+      Returns the sent-behaviour of the message.
+      @see SentBehaviour.
+    */
+    SentBehaviour sentBehaviour() const;
+
+    /**
+      Sets the sent-behaviour of the message.
+      @see SentBehaviour.
+    */
+    void setSentBehaviour( SentBehaviour beh );
+
+    /**
+      Returns the collection to which the item should be moved after it is sent.
+      Only valid if sentBehaviour() is MoveToCollection.
+    */
+    Akonadi::Collection::Id moveToCollection() const;
+
+    /**
+      Sets the collection to which the item should be moved after it is sent.
+      Make sure you set the SentBehaviour to MoveToCollection first.
+      @see setSentBehaviour.
+    */
+    void setMoveToCollection( Akonadi::Collection::Id moveToCollection );
+
+  private:
+    class Private;
+    Private *const d;
+
+};
+
+} // namespace MailTransport
+
+#endif // MAILTRANSPORT_SENTBEHAVIOURATTRIBUTE_H
diff -pubNr /opt/kde-stable/include/mailtransport/servertest.h /opt/kde-trunk/include/mailtransport/servertest.h
--- /opt/kde-stable/include/mailtransport/servertest.h	2009-10-12 18:32:09.000000000 +0200
+++ /opt/kde-trunk/include/mailtransport/servertest.h	2009-10-09 09:21:57.000000000 +0200
@@ -209,6 +209,6 @@ class MAILTRANSPORT_EXPORT ServerTest : 
     Q_PRIVATE_SLOT( d, void slotUpdateProgress() )
 };
 
-}
+} // namespace MailTransport
 
-#endif
+#endif // MAILTRANSPORT_SERVERTEST_H
diff -pubNr /opt/kde-stable/include/mailtransport/smtpjob.h /opt/kde-trunk/include/mailtransport/smtpjob.h
--- /opt/kde-stable/include/mailtransport/smtpjob.h	2009-10-12 18:32:09.000000000 +0200
+++ /opt/kde-trunk/include/mailtransport/smtpjob.h	2009-10-09 09:21:57.000000000 +0200
@@ -26,8 +26,8 @@
 #include <mailtransport/transportjob.h>
 
 namespace KIO {
-class Job;
-class Slave;
+  class Job;
+  class Slave;
 }
 
 class SmtpJobPrivate;
@@ -43,13 +43,15 @@ namespace MailTransport {
 
   Precommands are automatically executed, once per opening a connection to the
   server (not necessarily once per message).
+
+  @deprecated Use MessageQueueJob for sending e-mail.
 */
-class MAILTRANSPORT_EXPORT SmtpJob : public TransportJob
+class MAILTRANSPORT_EXPORT_DEPRECATED SmtpJob : public TransportJob
 {
   Q_OBJECT
   public:
     /**
-      Creates a SendmailJob.
+      Creates a SmtpJob.
       @param transport The transport settings.
       @param parent The parent object.
     */
@@ -78,6 +80,6 @@ class MAILTRANSPORT_EXPORT SmtpJob : pub
     SmtpJobPrivate *const d;
 };
 
-}
+} // namespace MailTransport
 
-#endif
+#endif // MAILTRANSPORT_SMTPJOB_H
diff -pubNr /opt/kde-stable/include/mailtransport/transportattribute.h /opt/kde-trunk/include/mailtransport/transportattribute.h
--- /opt/kde-stable/include/mailtransport/transportattribute.h	1970-01-01 01:00:00.000000000 +0100
+++ /opt/kde-trunk/include/mailtransport/transportattribute.h	2009-10-09 09:21:58.000000000 +0200
@@ -0,0 +1,85 @@
+/*
+    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 MAILTRANSPORT_TRANSPORTATTRIBUTE_H
+#define MAILTRANSPORT_TRANSPORTATTRIBUTE_H
+
+#include <mailtransport/mailtransport_export.h>
+
+#include <akonadi/attribute.h>
+
+namespace MailTransport {
+
+class Transport;
+
+/**
+  Attribute determining which transport to use for sending a message.
+
+  @see mailtransport
+  @see TransportManager.
+
+  @author Constantin Berzan <exit3219@gmail.com>
+  @since 4.4
+*/
+class MAILTRANSPORT_EXPORT TransportAttribute : public Akonadi::Attribute
+{
+  public:
+    /**
+      Creates a new TransportAttribute.
+    */
+    TransportAttribute( int id = -1 );
+
+    /**
+      Destroys this TransportAttribute.
+    */
+    virtual ~TransportAttribute();
+
+    /* reimpl */
+    virtual TransportAttribute *clone() const;
+    virtual QByteArray type() const;
+    virtual QByteArray serialized() const;
+    virtual void deserialize( const QByteArray &data );
+
+    /**
+      Returns the transport id to use for sending this message.
+      @see TransportManager.
+    */
+    int transportId() const;
+
+    /**
+      Returns the transport object corresponding to the transport id contained
+      in this attribute.
+      @see Transport.
+    */
+    Transport *transport() const;
+
+    /**
+      Sets the transport id to use for sending this message.
+    */
+    void setTransportId( int id );
+
+  private:
+    class Private;
+    Private *const d;
+
+};
+
+} // namespace MailTransport
+
+#endif // MAILTRANSPORT_TRANSPORTATTRIBUTE_H
diff -pubNr /opt/kde-stable/include/mailtransport/transportbase.h /opt/kde-trunk/include/mailtransport/transportbase.h
--- /opt/kde-stable/include/mailtransport/transportbase.h	2009-10-12 19:59:16.000000000 +0200
+++ /opt/kde-trunk/include/mailtransport/transportbase.h	2009-10-09 11:59:48.000000000 +0200
@@ -16,7 +16,7 @@ class MAILTRANSPORT_EXPORT TransportBase
     class EnumType
     {
       public:
-      enum type { SMTP, Sendmail, COUNT };
+      enum type { SMTP, Sendmail, Akonadi, COUNT };
     };
     class EnumEncryption
     {
@@ -37,7 +37,7 @@ class MAILTRANSPORT_EXPORT TransportBase
     */
     void setId( int v )
     {
-      if (!isImmutable( QString::fromLatin1 ( "id" ) ))
+      if (!isImmutable( QString::fromLatin1( "id" ) ))
         mId = v;
     }
 
@@ -62,7 +62,7 @@ class MAILTRANSPORT_EXPORT TransportBase
     */
     void setName( const QString & v )
     {
-      if (!isImmutable( QString::fromLatin1 ( "name" ) ))
+      if (!isImmutable( QString::fromLatin1( "name" ) ))
         mName = v;
     }
 
@@ -87,7 +87,7 @@ class MAILTRANSPORT_EXPORT TransportBase
     */
     void setType( int v )
     {
-      if (!isImmutable( QString::fromLatin1 ( "type" ) ))
+      if (!isImmutable( QString::fromLatin1( "type" ) ))
         mType = v;
     }
 
@@ -112,7 +112,7 @@ class MAILTRANSPORT_EXPORT TransportBase
     */
     void setHost( const QString & v )
     {
-      if (!isImmutable( QString::fromLatin1 ( "host" ) ))
+      if (!isImmutable( QString::fromLatin1( "host" ) ))
         mHost = v;
     }
 
@@ -137,7 +137,7 @@ class MAILTRANSPORT_EXPORT TransportBase
     */
     void setPort( uint v )
     {
-      if (!isImmutable( QString::fromLatin1 ( "port" ) ))
+      if (!isImmutable( QString::fromLatin1( "port" ) ))
         mPort = v;
     }
 
@@ -162,7 +162,7 @@ class MAILTRANSPORT_EXPORT TransportBase
     */
     void setUserName( const QString & v )
     {
-      if (!isImmutable( QString::fromLatin1 ( "userName" ) ))
+      if (!isImmutable( QString::fromLatin1( "userName" ) ))
         mUserName = v;
     }
 
@@ -187,7 +187,7 @@ class MAILTRANSPORT_EXPORT TransportBase
     */
     void setPrecommand( const QString & v )
     {
-      if (!isImmutable( QString::fromLatin1 ( "precommand" ) ))
+      if (!isImmutable( QString::fromLatin1( "precommand" ) ))
         mPrecommand = v;
     }
 
@@ -212,7 +212,7 @@ class MAILTRANSPORT_EXPORT TransportBase
     */
     void setRequiresAuthentication( bool v )
     {
-      if (!isImmutable( QString::fromLatin1 ( "requiresAuthentication" ) ))
+      if (!isImmutable( QString::fromLatin1( "requiresAuthentication" ) ))
         mRequiresAuthentication = v;
     }
 
@@ -237,7 +237,7 @@ class MAILTRANSPORT_EXPORT TransportBase
     */
     void setStorePassword( bool v )
     {
-      if (!isImmutable( QString::fromLatin1 ( "storePassword" ) ))
+      if (!isImmutable( QString::fromLatin1( "storePassword" ) ))
         mStorePassword = v;
     }
 
@@ -262,7 +262,7 @@ class MAILTRANSPORT_EXPORT TransportBase
     */
     void setEncryption( int v )
     {
-      if (!isImmutable( QString::fromLatin1 ( "encryption" ) ))
+      if (!isImmutable( QString::fromLatin1( "encryption" ) ))
         mEncryption = v;
     }
 
@@ -287,7 +287,7 @@ class MAILTRANSPORT_EXPORT TransportBase
     */
     void setAuthenticationType( int v )
     {
-      if (!isImmutable( QString::fromLatin1 ( "authenticationType" ) ))
+      if (!isImmutable( QString::fromLatin1( "authenticationType" ) ))
         mAuthenticationType = v;
     }
 
@@ -312,7 +312,7 @@ class MAILTRANSPORT_EXPORT TransportBase
     */
     void setSpecifyHostname( bool v )
     {
-      if (!isImmutable( QString::fromLatin1 ( "specifyHostname" ) ))
+      if (!isImmutable( QString::fromLatin1( "specifyHostname" ) ))
         mSpecifyHostname = v;
     }
 
@@ -337,7 +337,7 @@ class MAILTRANSPORT_EXPORT TransportBase
     */
     void setLocalHostname( const QString & v )
     {
-      if (!isImmutable( QString::fromLatin1 ( "localHostname" ) ))
+      if (!isImmutable( QString::fromLatin1( "localHostname" ) ))
         mLocalHostname = v;
     }
 
diff -pubNr /opt/kde-stable/include/mailtransport/transportcombobox.h /opt/kde-trunk/include/mailtransport/transportcombobox.h
--- /opt/kde-stable/include/mailtransport/transportcombobox.h	2009-10-12 18:32:09.000000000 +0200
+++ /opt/kde-trunk/include/mailtransport/transportcombobox.h	2009-10-09 09:21:58.000000000 +0200
@@ -20,9 +20,10 @@
 #ifndef MAILTRANSPORT_TRANSPORTCOMBOBOX_H
 #define MAILTRANSPORT_TRANSPORTCOMBOBOX_H
 
-#include <mailtransport/transportbase.h>
 #include <mailtransport/mailtransport_export.h>
-#include <kcombobox.h>
+#include <mailtransport/transportbase.h>
+
+#include <KDE/KComboBox>
 
 class TransportComboBoxPrivate;
 
@@ -30,6 +31,7 @@ namespace MailTransport {
 
 /**
   A combo-box for selecting a mail transport.
+  It is updated automatically when transports are added, changed, or removed.
 */
 class MAILTRANSPORT_EXPORT TransportComboBox : public KComboBox
 {
@@ -67,6 +69,6 @@ class MAILTRANSPORT_EXPORT TransportComb
     TransportComboBoxPrivate *const d;
 };
 
-}
+} // namespace MailTransport
 
-#endif
+#endif // MAILTRANSPORT_TRANSPORTCOMBOBOX_H
diff -pubNr /opt/kde-stable/include/mailtransport/transportconfigdialog.h /opt/kde-trunk/include/mailtransport/transportconfigdialog.h
--- /opt/kde-stable/include/mailtransport/transportconfigdialog.h	2009-10-12 18:32:09.000000000 +0200
+++ /opt/kde-trunk/include/mailtransport/transportconfigdialog.h	2009-10-09 09:21:57.000000000 +0200
@@ -1,5 +1,6 @@
 /*
     Copyright (c) 2006 - 2007 Volker Krause <vkrause@kde.org>
+    Copyright (c) 2009 Constantin Berzan <exit3219@gmail.com>
 
     Based on KMail code by:
     Copyright (c) 2001-2002 Michael Haeckel <haeckel@kde.org>
@@ -24,7 +25,8 @@
 #define MAILTRANSPORT_TRANSPORTCONFIGDIALOG_H
 
 #include <mailtransport/mailtransport_export.h>
-#include <kdialog.h>
+
+#include <KDE/KDialog>
 
 namespace MailTransport {
 
@@ -32,8 +34,12 @@ class Transport;
 
 /**
   Configuration dialog for a mail transport.
+
+  @deprecated Use TransportManager::configureTransport() instead.
 */
-class MAILTRANSPORT_EXPORT TransportConfigDialog : public KDialog
+// TODO KDE5: this class should not be exported.
+// FIXME how to avoid deprecated warning from its own moc?
+class MAILTRANSPORT_EXPORT_DEPRECATED TransportConfigDialog : public KDialog
 {
   Q_OBJECT
 
@@ -41,6 +47,13 @@ class MAILTRANSPORT_EXPORT TransportConf
     /**
       Creates a new mail transport configuration dialog for the given
       Transport object.
+      The config dialog does not delete @p transport, you have to delete it
+      yourself.
+
+      Note that this class only works for transports that are handled directly
+      by MailTransport, i.e. SMTP and Sendmail.  This class cannot be used to
+      configure an Akonadi transport.
+
       @param transport The Transport object to configure. This must be a deep
       copy of a Transport object or a newly created one, which hasn't been
       added to the TransportManager yet.
@@ -53,25 +66,14 @@ class MAILTRANSPORT_EXPORT TransportConf
     */
     virtual ~TransportConfigDialog();
 
-  private Q_SLOTS:
-    void checkSmtpCapabilities();
-    void chooseSendmail();
-    void passwordsLoaded();
-    void save();
-    void slotUser3();
-    void slotFinished( QList<int> results );
-    void hostNameChanged( const QString &text );
-    void encryptionChanged( int enc );
-    void ensureValidAuthSelection();
-
   private:
     class Private;
     Private *const d;
 
-  Q_SIGNALS:
-    void sendmailClicked();
+    Q_PRIVATE_SLOT( d, void okClicked() )
+
 };
 
-}
+} // namespace MailTransport
 
-#endif
+#endif // MAILTRANSPORT_TRANSPORTCONFIGDIALOG_H
diff -pubNr /opt/kde-stable/include/mailtransport/transport.h /opt/kde-trunk/include/mailtransport/transport.h
--- /opt/kde-stable/include/mailtransport/transport.h	2009-10-12 18:32:09.000000000 +0200
+++ /opt/kde-trunk/include/mailtransport/transport.h	2009-10-09 09:21:57.000000000 +0200
@@ -20,18 +20,27 @@
 #ifndef MAILTRANSPORT_TRANSPORT_H
 #define MAILTRANSPORT_TRANSPORT_H
 
-#include <mailtransport/transportbase.h>
 #include <mailtransport/mailtransport_export.h>
+#include <mailtransport/transportbase.h>
+#include <mailtransport/transporttype.h>
 
 class TransportPrivate;
 
 namespace MailTransport {
 
+class TransportType;
+
 /**
   Represents the settings of a specific mail transport.
 
   To create a new empty Transport object, use TransportManager::createTransport().
 */
+// TODO KDE5: Do something about the kcfg-generated TransportBase.
+// Currently it has the config stuff as private members, which means it is
+// utterly inextensible.  Also the sendmail and akonadi-type transports use
+// the "host" setting for keeping the location of the sendmail executable and
+// the resource id, respectively.  This is a hack; they should have separate
+// config options... (cberzan)
 class MAILTRANSPORT_EXPORT Transport : public TransportBase
 {
   Q_OBJECT
@@ -62,6 +71,13 @@ class MAILTRANSPORT_EXPORT Transport : p
     void setPassword( const QString &passwd );
 
     /**
+      Makes sure the transport has a unique name.  Adds #1, #2, #3 etc. if
+      necessary.
+      @since 4.4
+    */
+    void forceUniqueName();
+
+    /**
       This function synchronizes the password of this transport with the
       password of the transport with the same ID that is managed by the
       transport manager. This is only useful for cloned transports, since
@@ -95,6 +111,20 @@ class MAILTRANSPORT_EXPORT Transport : p
     */
     Transport *clone() const;
 
+    /**
+      Returns the type of this transport.
+      @see TransportType.
+      @since 4.4
+    */
+    TransportType transportType() const;
+
+    /**
+      Sets the type of this transport.
+      @see TransportType.
+      @since 4.4
+    */
+    void setTransportType( const TransportType &type );
+
   protected:
     /**
       Creates a Transport object. Should only be used by TransportManager.
@@ -122,6 +152,6 @@ class MAILTRANSPORT_EXPORT Transport : p
     TransportPrivate *const d;
 };
 
-}
+} // namespace MailTransport
 
-#endif
+#endif // MAILTRANSPORT_TRANSPORT_H
diff -pubNr /opt/kde-stable/include/mailtransport/transportjob.h /opt/kde-trunk/include/mailtransport/transportjob.h
--- /opt/kde-stable/include/mailtransport/transportjob.h	2009-10-12 18:32:09.000000000 +0200
+++ /opt/kde-trunk/include/mailtransport/transportjob.h	2009-10-09 09:21:58.000000000 +0200
@@ -21,9 +21,11 @@
 #define MAILTRANSPORT_TRANSPORTJOB_H
 
 #include <mailtransport/mailtransport_export.h>
-#include <kcompositejob.h>
+
 #include <QtCore/QStringList>
 
+#include <KDE/KCompositeJob>
+
 class QBuffer;
 
 namespace MailTransport {
@@ -33,8 +35,10 @@ class Transport;
 /**
   Abstract base class for all mail transport jobs.
   This is a job that is supposed to send exactly one mail.
+
+  @deprecated Use MessageQueueJob for sending e-mail.
 */
-class MAILTRANSPORT_EXPORT TransportJob : public KCompositeJob
+class MAILTRANSPORT_EXPORT_DEPRECATED TransportJob : public KCompositeJob
 {
   friend class TransportManager;
 
@@ -137,6 +141,6 @@ class MAILTRANSPORT_EXPORT TransportJob 
     Private *const d;
 };
 
-}
+} // namespace MailTransport
 
-#endif
+#endif // MAILTRANSPORT_TRANSPORTJOB_H
diff -pubNr /opt/kde-stable/include/mailtransport/transportmanagementwidget.h /opt/kde-trunk/include/mailtransport/transportmanagementwidget.h
--- /opt/kde-stable/include/mailtransport/transportmanagementwidget.h	2009-10-12 18:32:09.000000000 +0200
+++ /opt/kde-trunk/include/mailtransport/transportmanagementwidget.h	2009-10-09 09:21:57.000000000 +0200
@@ -24,6 +24,7 @@
 #define MAILTRANSPORT_TRANSPORTMANAGEMENTWIDGET_H
 
 #include <mailtransport/mailtransport_export.h>
+
 #include <QtGui/QWidget>
 
 namespace MailTransport {
@@ -48,19 +49,18 @@ class MAILTRANSPORT_EXPORT TransportMana
     virtual ~TransportManagementWidget();
 
   private Q_SLOTS:
-    void fillTransportList();
     void updateButtonState();
     void addClicked();
     void editClicked();
+    void renameClicked();
     void removeClicked();
     void defaultClicked();
-    void slotSendmail();
 
   private:
     class Private;
     Private * const d;
 };
 
-}
+} // namespace MailTransport
 
-#endif
+#endif // MAILTRANSPORT_TRANSPORTMANAGEMENTWIDGET_H
diff -pubNr /opt/kde-stable/include/mailtransport/transportmanager.h /opt/kde-trunk/include/mailtransport/transportmanager.h
--- /opt/kde-stable/include/mailtransport/transportmanager.h	2009-10-12 18:32:09.000000000 +0200
+++ /opt/kde-trunk/include/mailtransport/transportmanager.h	2009-10-09 09:21:58.000000000 +0200
@@ -21,10 +21,13 @@
 #define MAILTRANSPORT_TRANSPORTMANAGER_H
 
 #include <mailtransport/mailtransport_export.h>
+#include <mailtransport/transporttype.h>
 
 #include <QtCore/QList>
 #include <QtCore/QObject>
 
+#include <akonadi/agenttype.h>
+
 class KJob;
 
 namespace KWallet {
@@ -34,11 +37,19 @@ namespace KWallet {
 namespace MailTransport {
 
 class Transport;
+class TransportConfigWidget;
 class TransportJob;
 
 /**
-  Takes care of loading and storing mail transport settings and
-  creating of transport jobs.
+  @short Central transport management interface.
+
+  This class manages the creation, configuration, and removal of mail
+  transports, as well as the loading and storing of mail transport settings.
+
+  It also handles the creation of transport jobs, although that behaviour is
+  deprecated and you are encouraged to use MessageQueueJob.
+
+  @see MessageQueueJob.
 */
 class MAILTRANSPORT_EXPORT TransportManager : public QObject
 {
@@ -97,6 +108,11 @@ class MAILTRANSPORT_EXPORT TransportMana
     QList<Transport *>transports() const;
 
     /**
+      Returns a list of all available transport types.
+    */
+    TransportType::List types() const;
+
+    /**
       Creates a new, empty Transport object. The object is owned by the caller.
       If you want to add the Transport permanently (eg. after configuring it)
       call addTransport().
@@ -114,24 +130,33 @@ class MAILTRANSPORT_EXPORT TransportMana
       Creates a mail transport job for the given transport identifier.
       Returns 0 if the specified transport is invalid.
       @param transportId The transport identifier.
+
+      @deprecated use MessageQueueJob to queue messages
+                  and rely on the Dispatcher Agent to send them.
     */
-    TransportJob *createTransportJob( int transportId );
+    MAILTRANSPORT_DEPRECATED TransportJob *createTransportJob( int transportId );
 
     /**
       Creates a mail transport job for the given transport identifer,
       or transport name.
       Returns 0 if the specified transport is invalid.
       @param transport A string defining a mail transport.
+
+      @deprecated use MessageQueueJob to queue messages
+                  and rely on the Dispatcher Agent to send them.
     */
-    TransportJob *createTransportJob( const QString &transport );
+    MAILTRANSPORT_DEPRECATED TransportJob *createTransportJob( const QString &transport );
 
     /**
       Executes the given transport job. This is the preferred way to start
       transport jobs. It takes care of asynchronously loading passwords from
       KWallet if necessary.
       @param job The completely configured transport job to execute.
+
+      @deprecated use MessageQueueJob to queue messages
+                  and rely on the Dispatcher Agent to send them.
     */
-    void schedule( TransportJob *job );
+    MAILTRANSPORT_DEPRECATED void schedule( TransportJob *job );
 
     /**
       Tries to create a transport based on KEMailSettings.
@@ -139,6 +164,33 @@ class MAILTRANSPORT_EXPORT TransportMana
     */
     void createDefaultTransport();
 
+    /**
+      Shows a dialog for creating and configuring a new transport.
+      @param parent Parent widget of the dialog.
+      @return True if a new transport has been created and configured.
+      @since 4.4
+    */
+    bool showNewTransportDialog( QWidget *parent );
+
+    /**
+      If no transport exists, asks the user to create and configure one.
+      Returns true if a transport exists or the user created one. Otherwise
+      returns false.
+      @param parent Parent widget of the dialog.
+      @since 4.4
+    */
+    bool promptCreateTransportIfNoneExists( QWidget *parent );
+
+    /**
+      Open a configuration dialog for an existing transport.
+      @param transport The transport to configure.  It can be a new transport,
+                       or one already managed by TransportManager.
+      @param parent The parent widget for the dialog.
+      @return True if the user clicked Ok, false if the user cancelled.
+      @since 4.4
+    */
+    bool configureTransport( Transport *transport, QWidget *parent );
+
   public Q_SLOTS:
     /**
       Returns true if there are no mail transports at all.
@@ -226,11 +278,15 @@ class MAILTRANSPORT_EXPORT TransportMana
     */
     void loadPasswords();
 
+    /**
+      Singleton class, the only instance resides in the static object sSelf.
+    */
     TransportManager();
 
   private:
     void readConfig();
     void writeConfig();
+    void fillTypes();
     void emitChangesCommitted();
     int createId() const;
     void prepareWallet();
@@ -243,12 +299,14 @@ class MAILTRANSPORT_EXPORT TransportMana
     void dbusServiceOwnerChanged( const QString &service,
                                   const QString &oldOwner,
                                   const QString &newOwner );
+    void agentTypeAdded( const Akonadi::AgentType &atype );
+    void agentTypeRemoved( const Akonadi::AgentType &atype );
     void jobResult( KJob *job );
 
   private:
     Private *const d;
 };
 
-}
+} // namespace MailTransport
 
-#endif
+#endif // MAILTRANSPORT_TRANSPORTMANAGER_H
diff -pubNr /opt/kde-stable/include/mailtransport/transporttype.h /opt/kde-trunk/include/mailtransport/transporttype.h
--- /opt/kde-stable/include/mailtransport/transporttype.h	1970-01-01 01:00:00.000000000 +0100
+++ /opt/kde-trunk/include/mailtransport/transporttype.h	2009-10-09 09:21:57.000000000 +0200
@@ -0,0 +1,128 @@
+/*
+    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 MAILTRANSPORT_TRANSPORTTYPE_H
+#define MAILTRANSPORT_TRANSPORTTYPE_H
+
+#include "mailtransport_export.h"
+#include "transport.h"
+
+#include <QtCore/QString>
+
+#include <akonadi/agenttype.h>
+
+namespace MailTransport {
+
+class AddTransportDialog;
+class TransportManager;
+
+/**
+  @short A representation of a transport type.
+
+  Represents an available transport type.  SMTP and Sendmail are available,
+  as well as a number of Akonadi-based types.  Each Akonadi-based type
+  corresponds to an Akonadi resource type that supports sending messages.
+
+  This class provides information about the type, such as name and
+  description.  Additionally, for Akonadi types, it provides the corresponding
+  Akonadi AgentType.
+
+  All available transport types can be retrieved via TransportManager::types().
+
+  @author Constantin Berzan <exit3219@gmail.com>
+  @since 4.4
+*/
+class MAILTRANSPORT_EXPORT TransportType
+{
+  friend class AddTransportDialog;
+  friend class Transport;
+  friend class TransportManager;
+
+  public:
+    /**
+      Describes a list of transport types.
+    */
+    typedef QList<TransportType> List;
+
+    /**
+      Constructs a new TransportType.
+    */
+    TransportType();
+
+    /**
+      Creates a copy of the @p other TransportType.
+    */
+    TransportType( const TransportType &other );
+
+    /**
+      Destroys the TransportType.
+    */
+    ~TransportType();
+
+    /**
+      @internal
+    */
+    TransportType &operator=( const TransportType &other );
+
+    /**
+      @internal
+      Compares two transport types.
+    */
+    bool operator==( const TransportType &other ) const;
+
+    /**
+      Returns whether the transport type is valid.
+    */
+    bool isValid() const;
+
+    /**
+      @internal
+      Returns the numeric type of the transport.  This corresponds to
+      Transport::EnumType::type.
+    */
+    // TODO should this be Transport::EnumType::type instead of int?
+    int type() const;
+
+    /**
+      Returns the i18n'ed name of the transport type.
+    */
+    QString name() const;
+
+    /**
+      Returns a description of the transport type.
+    */
+    QString description() const;
+
+    /**
+      Returns the corresponding Akonadi::AgentType that this transport type
+      represents.  Only valid if type() is Transport::EnumType::Akonadi.
+    */
+    Akonadi::AgentType agentType() const;
+
+  private:
+    class Private;
+    QSharedDataPointer<Private> d;
+
+};
+
+} // namespace MailTransport
+
+Q_DECLARE_METATYPE( MailTransport::TransportType )
+
+#endif // MAILTRANSPORT_TRANSPORTTYPE_H
