diff --git a/mailtransport/akonadiconfigwidget.cpp b/mailtransport/akonadiconfigwidget.cpp index b27aeb0cf..b196cb2c2 100644 --- a/mailtransport/akonadiconfigwidget.cpp +++ b/mailtransport/akonadiconfigwidget.cpp @@ -1,77 +1,77 @@ /* Copyright (c) 2009 Constantin Berzan 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. */ #include "akonadiconfigwidget.h" #include "transportconfigwidget_p.h" #include "ui_akonadisettings.h" #include -#include -#include +#include +#include using namespace Akonadi; using namespace MailTransport; class MailTransport::AkonadiConfigWidgetPrivate : public TransportConfigWidgetPrivate { public: Ui::AkonadiSettings ui; }; AkonadiConfigWidget::AkonadiConfigWidget( Transport *transport, QWidget *parent ) : TransportConfigWidget( *new AkonadiConfigWidgetPrivate, transport, parent ) { init(); } AkonadiConfigWidget::AkonadiConfigWidget( AkonadiConfigWidgetPrivate &dd, Transport *transport, QWidget *parent ) : TransportConfigWidget( dd, transport, parent ) { init(); } void AkonadiConfigWidget::init() { Q_D( AkonadiConfigWidget ); d->ui.setupUi( this ); // The KConfigDialogManager is useless here, it doesn't handle the Akonadi::AgentInstanceWidget //d->manager->addWidget( this ); // otherwise it doesn't find out about these widgets //d->manager->updateWidgets(); d->ui.agentInstances->agentFilterProxyModel()->addCapabilityFilter( QLatin1String( "MailTransport" ) ); } void AkonadiConfigWidget::apply() { Q_D( AkonadiConfigWidget ); const AgentInstance instance = d->ui.agentInstances->currentAgentInstance(); if( instance.isValid() ) { d->transport->setHost( instance.identifier() ); } TransportConfigWidget::apply(); } #include "akonadiconfigwidget.moc" diff --git a/mailtransport/akonadijob.cpp b/mailtransport/akonadijob.cpp index dc05dea3f..d47721d09 100644 --- a/mailtransport/akonadijob.cpp +++ b/mailtransport/akonadijob.cpp @@ -1,112 +1,110 @@ /* Copyright (c) 2009 Constantin Berzan 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. */ #include "akonadijob.h" #include "transport.h" #include #include #include #include #include -#include - using namespace Akonadi; using namespace MailTransport; /** * Private class that helps to provide binary compatibility between releases. * @internal */ class AkonadiJobPrivate { public: Item::Id itemId; QDBusInterface *iface; }; AkonadiJob::AkonadiJob( Transport *transport, QObject *parent ) : TransportJob( transport, parent ), d( new AkonadiJobPrivate ) { d->itemId = -1; d->iface = 0; } AkonadiJob::~ AkonadiJob() { delete d; } Akonadi::Item::Id AkonadiJob::itemId() const { return d->itemId; } void AkonadiJob::setItemId( Akonadi::Item::Id id ) { d->itemId = id; } void AkonadiJob::doStart() { if( !d->itemId < 0 ) { // TODO should this check be performed here or somewhere on a higher level? setError( UserDefinedError ); setErrorText( i18n( "Asked to send invalid item with id %1.", d->itemId ) ); emitResult(); return; } d->iface = new QDBusInterface( QLatin1String( "org.freedesktop.Akonadi.Resource." ) + transport()->host(), QLatin1String( "/" ), QLatin1String( "org.freedesktop.Akonadi.Resource.Transport" ), QDBusConnection::sessionBus(), this ); if( !d->iface->isValid() ) { setError( UserDefinedError ); setErrorText( i18n( "Failed to get D-Bus interface of resource %1.", transport()->host() ) ); emitResult(); return; } connect( d->iface, SIGNAL( transportResult( bool, const QString & ) ), this, SLOT( resourceResult( bool, const QString & ) ) ); // What TODO about timeouts? It is quite possible that the result D-Bus signal // will get lost, and then what? QDBusReply reply = d->iface->call( QLatin1String( "send" ), d->itemId ); if( !reply.isValid() ) { setError( UserDefinedError ); setErrorText( i18n( "Invalid D-Bus reply from resource %1.", transport()->host() ) ); emitResult(); return; } } void AkonadiJob::resourceResult( bool success, const QString &message ) { if( !success ) { setError( UserDefinedError ); setErrorText( message ); } emitResult(); } #include "akonadijob.moc" diff --git a/mailtransport/akonadijob.h b/mailtransport/akonadijob.h index b1fb61b3a..9c29b9c0f 100644 --- a/mailtransport/akonadijob.h +++ b/mailtransport/akonadijob.h @@ -1,77 +1,77 @@ /* Copyright (c) 2009 Constantin Berzan 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_AKONADIJOB_H #define MAILTRANSPORT_AKONADIJOB_H #include -#include +#include class AkonadiJobPrivate; namespace MailTransport { /** Mail transport job for an Akonadi resource. TODO docu... apps need to call setItem if it's an Akonadi job... */ class MAILTRANSPORT_EXPORT AkonadiJob : public TransportJob { Q_OBJECT public: /** Creates an AkonadiJob. @param transport The transport settings. @param parent The parent object. */ explicit AkonadiJob( Transport *transport, QObject *parent = 0 ); /** Destroys this job. */ virtual ~AkonadiJob(); // TODO have these here or in TransportJob? They are useless in {SMTP,Sendmail}Job... /** The id of the item to send. */ Akonadi::Item::Id itemId() const; /** Set the id of the item to send. @param itemId id of the item to send */ void setItemId( Akonadi::Item::Id id ); protected: virtual void doStart(); private Q_SLOTS: void resourceResult( bool success, const QString &message ); private: AkonadiJobPrivate *const d; }; } #endif