diff --git a/outboxinterface/CMakeLists.txt b/outboxinterface/CMakeLists.txt index 8a4578a8f..ae1eb123f 100644 --- a/outboxinterface/CMakeLists.txt +++ b/outboxinterface/CMakeLists.txt @@ -1,40 +1,38 @@ add_definitions( -DKDE_DEFAULT_DEBUG_AREA=5324 ) set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${KDE4_ENABLE_EXCEPTIONS}" ) add_subdirectory( tests ) set( outboxinterface_lib_srcs dispatcherinterface.cpp messagequeuejob.cpp outboxactions.cpp - addressattribute.cpp dispatchmodeattribute.cpp errorattribute.cpp sentbehaviourattribute.cpp transportattribute.cpp attributeregistrar.cpp ) kde4_add_library( outboxinterface SHARED ${outboxinterface_lib_srcs} ) target_link_libraries( outboxinterface ${KDE4_KIO_LIBS} akonadi-kde akonadi-kmime kmime mailtransport ) set_target_properties( outboxinterface PROPERTIES VERSION ${GENERIC_LIB_VERSION} SOVERSION ${GENERIC_LIB_SOVERSION} ) install( TARGETS outboxinterface ${INSTALL_TARGETS_DEFAULT_ARGS} ) install( FILES outboxinterface_export.h dispatcherinterface.h messagequeuejob.h outboxactions.h - addressattribute.h dispatchmodeattribute.h errorattribute.h sentbehaviourattribute.h transportattribute.h DESTINATION ${INCLUDE_INSTALL_DIR}/outboxinterface COMPONENT Devel ) diff --git a/outboxinterface/addressattribute.cpp b/outboxinterface/addressattribute.cpp deleted file mode 100644 index a54158f82..000000000 --- a/outboxinterface/addressattribute.cpp +++ /dev/null @@ -1,128 +0,0 @@ -/* - Copyright 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 "addressattribute.h" - -#include - -#include - -using namespace Akonadi; -using namespace OutboxInterface; - -/** - @internal -*/ -class AddressAttribute::Private -{ - public: - QString mFrom; - QStringList mTo; - QStringList mCc; - QStringList mBcc; -}; - -AddressAttribute::AddressAttribute( const QString &from, const QStringList &to, - const QStringList &cc, const QStringList &bcc ) - : d( new Private ) -{ - d->mFrom = from; - d->mTo = to; - d->mCc = cc; - d->mBcc = bcc; -} - -AddressAttribute::~AddressAttribute() -{ - delete d; -} - -AddressAttribute* AddressAttribute::clone() const -{ - return new AddressAttribute( d->mFrom, d->mTo, d->mCc, d->mBcc ); -} - -QByteArray AddressAttribute::type() const -{ - static const QByteArray sType( "AddressAttribute" ); - return sType; -} - -QByteArray AddressAttribute::serialized() const -{ - QByteArray serializedData; - QDataStream serializer( &serializedData, QIODevice::WriteOnly ); - serializer.setVersion( QDataStream::Qt_4_5 ); - serializer << d->mFrom; - serializer << d->mTo; - serializer << d->mCc; - serializer << d->mBcc; - return serializedData; -} - -void AddressAttribute::deserialize( const QByteArray &data ) -{ - QDataStream deserializer( data ); - deserializer.setVersion( QDataStream::Qt_4_5 ); - deserializer >> d->mFrom; - deserializer >> d->mTo; - deserializer >> d->mCc; - deserializer >> d->mBcc; -} - -QString AddressAttribute::from() const -{ - return d->mFrom; -} - -void AddressAttribute::setFrom( const QString &from ) -{ - d->mFrom = from; -} - -QStringList AddressAttribute::to() const -{ - return d->mTo; -} - -void AddressAttribute::setTo( const QStringList &to ) -{ - d->mTo = to; -} - -QStringList AddressAttribute::cc() const -{ - return d->mCc; -} - -void AddressAttribute::setCc( const QStringList &cc ) -{ - d->mCc = cc; -} - -QStringList AddressAttribute::bcc() const -{ - return d->mBcc; -} - -void AddressAttribute::setBcc( const QStringList &bcc ) -{ - d->mBcc = bcc; -} - diff --git a/outboxinterface/addressattribute.h b/outboxinterface/addressattribute.h deleted file mode 100644 index 7f4c8ac6a..000000000 --- a/outboxinterface/addressattribute.h +++ /dev/null @@ -1,112 +0,0 @@ -/* - Copyright 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 OUTBOXINTERFACE_ADDRESSATTRIBUTE_H -#define OUTBOXINTERFACE_ADDRESSATTRIBUTE_H - -#include - -#include -#include - -#include - -namespace MailTransport { - class Transport; -} - -namespace OutboxInterface { - -/** - Attribute storing the From, To, Cc, Bcc addresses of a message. - - @author Constantin Berzan - @since 4.4 -*/ -class OUTBOXINTERFACE_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 OutboxInterface - -#endif // OUTBOXINTERFACE_ADDRESSATTRIBUTE_H diff --git a/outboxinterface/attributeregistrar.cpp b/outboxinterface/attributeregistrar.cpp index ff424643e..6e89f02d1 100644 --- a/outboxinterface/attributeregistrar.cpp +++ b/outboxinterface/attributeregistrar.cpp @@ -1,46 +1,44 @@ /* 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 "addressattribute.h" #include "dispatchmodeattribute.h" #include "errorattribute.h" #include "sentbehaviourattribute.h" #include "transportattribute.h" #include namespace { // Anonymous namespace; function is invisible outside this file. bool dummy() { using namespace Akonadi; using namespace OutboxInterface; - AttributeFactory::registerAttribute(); AttributeFactory::registerAttribute(); AttributeFactory::registerAttribute(); AttributeFactory::registerAttribute(); AttributeFactory::registerAttribute(); return true; } // Called when this library is loaded. const bool registered = dummy(); } // namespace diff --git a/outboxinterface/messagequeuejob.cpp b/outboxinterface/messagequeuejob.cpp index 99c8d59a2..1b7cba438 100644 --- a/outboxinterface/messagequeuejob.cpp +++ b/outboxinterface/messagequeuejob.cpp @@ -1,292 +1,292 @@ /* 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 "messagequeuejob.h" -#include "addressattribute.h" #include "transportattribute.h" #include #include #include #include #include +#include #include #include #include using namespace Akonadi; using namespace KMime; using namespace MailTransport; using namespace OutboxInterface; /** @internal */ class OutboxInterface::MessageQueueJob::Private { public: Private( MessageQueueJob *qq ) : q( qq ) { transport = -1; dispatchMode = DispatchModeAttribute::Immediately; sentBehaviour = SentBehaviourAttribute::MoveToDefaultSentCollection; moveToCollection = -1; started = false; } MessageQueueJob *const q; Message::Ptr message; int transport; DispatchModeAttribute::DispatchMode dispatchMode; QDateTime dueDate; SentBehaviourAttribute::SentBehaviour sentBehaviour; Collection::Id moveToCollection; QString from; QStringList to; QStringList cc; QStringList bcc; bool started; /** Returns true if this message has everything it needs and is ready to be sent. */ bool validate(); // slot void doStart(); }; bool MessageQueueJob::Private::validate() { if( !message ) { q->setError( UserDefinedError ); q->setErrorText( i18n( "Empty message." ) ); q->emitResult(); return false; } if( to.count() + cc.count() + bcc.count() == 0 ) { q->setError( UserDefinedError ); q->setErrorText( i18n( "Message has no recipients." ) ); q->emitResult(); return false; } if( dispatchMode == DispatchModeAttribute::AfterDueDate && !dueDate.isValid() ) { q->setError( UserDefinedError ); q->setErrorText( i18n( "Message has invalid due date." ) ); q->emitResult(); return false; } if( TransportManager::self()->transportById( transport, false ) == 0 ) { q->setError( UserDefinedError ); q->setErrorText( i18n( "Message has invalid transport." ) ); q->emitResult(); return false; } if( sentBehaviour == SentBehaviourAttribute::MoveToCollection && moveToCollection < 0 ) { q->setError( UserDefinedError ); q->setErrorText( i18n( "Message has invalid sent-mail folder." ) ); q->emitResult(); return false; } else if( sentBehaviour == SentBehaviourAttribute::MoveToDefaultSentCollection ) { Q_ASSERT( LocalFolders::self()->isReady() ); Q_ASSERT( LocalFolders::self()->sentMail().isValid() ); } return true; // all ok } void MessageQueueJob::Private::doStart() { LocalFolders::self()->disconnect( q ); Q_ASSERT( !started ); started = true; if( !validate() ) { // The error has been set; the result has been emitted. return; } // Create item. Item item; item.setMimeType( "message/rfc822" ); item.setPayload( message ); // Set attributes. AddressAttribute *addrA = new AddressAttribute( from, to, cc, bcc ); DispatchModeAttribute *dmA = new DispatchModeAttribute( dispatchMode, dueDate ); SentBehaviourAttribute *sA = new SentBehaviourAttribute( sentBehaviour, moveToCollection ); TransportAttribute *tA = new TransportAttribute( transport ); item.addAttribute( addrA ); item.addAttribute( dmA ); item.addAttribute( sA ); item.addAttribute( tA ); // Set flags. item.setFlag( "queued" ); // Store the item in the outbox. Q_ASSERT( LocalFolders::self()->isReady() ); Collection col = LocalFolders::self()->outbox(); ItemCreateJob *job = new ItemCreateJob( item, col ); // job autostarts q->addSubjob( job ); } MessageQueueJob::MessageQueueJob( QObject *parent ) : KCompositeJob( parent ) , d( new Private( this ) ) { } MessageQueueJob::~MessageQueueJob() { delete d; } Message::Ptr MessageQueueJob::message() const { return d->message; } int MessageQueueJob::transportId() const { return d->transport; } DispatchModeAttribute::DispatchMode MessageQueueJob::dispatchMode() const { return d->dispatchMode; } QDateTime MessageQueueJob::sendDueDate() const { if( d->dispatchMode != DispatchModeAttribute::AfterDueDate ) { kWarning() << "Called when dispatchMode is not AfterDueDate."; } return d->dueDate; } Collection::Id MessageQueueJob::moveToCollection() const { if( d->sentBehaviour != SentBehaviourAttribute::MoveToCollection ) { kWarning() << "Called when sentBehaviour is not MoveToCollection."; } return d->moveToCollection; } QString MessageQueueJob::from() const { return d->from; } QStringList MessageQueueJob::to() const { return d->to; } QStringList MessageQueueJob::cc() const { return d->cc; } QStringList MessageQueueJob::bcc() const { return d->bcc; } void MessageQueueJob::setMessage( Message::Ptr message ) { d->message = message; } void MessageQueueJob::setTransportId( int id ) { d->transport = id; } void MessageQueueJob::setDispatchMode( DispatchModeAttribute::DispatchMode mode ) { d->dispatchMode = mode; } void MessageQueueJob::setDueDate( const QDateTime &date ) { d->dueDate = date; } void MessageQueueJob::setSentBehaviour( SentBehaviourAttribute::SentBehaviour beh ) { d->sentBehaviour = beh; } void MessageQueueJob::setMoveToCollection( Collection::Id cid ) { d->moveToCollection = cid; } void MessageQueueJob::setFrom( const QString &from ) { d->from = from; } void MessageQueueJob::setTo( const QStringList &to ) { d->to = to; } void MessageQueueJob::setCc( const QStringList &cc ) { d->cc = cc; } void MessageQueueJob::setBcc( const QStringList &bcc ) { d->bcc = bcc; } void MessageQueueJob::start() { LocalFolders *folders = LocalFolders::self(); connect( folders, SIGNAL( foldersReady() ), this, SLOT( doStart() ) ); folders->fetch(); // will emit foldersReady() } void MessageQueueJob::slotResult( KJob *job ) { // error handling KCompositeJob::slotResult( job ); if( !error() ) { emitResult(); } } #include "messagequeuejob.moc" diff --git a/outboxinterface/tests/attributetest.cpp b/outboxinterface/tests/attributetest.cpp index 5dd0577d7..61ff5c00c 100644 --- a/outboxinterface/tests/attributetest.cpp +++ b/outboxinterface/tests/attributetest.cpp @@ -1,139 +1,139 @@ /* Copyright 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 "attributetest.h" #include #include +#include -#include #include #include #include #include using namespace Akonadi; using namespace OutboxInterface; void AttributeTest::initTestCase() { } void AttributeTest::testRegistrar() { // The attributes should have been registered without any effort on our part. { Attribute *a = AttributeFactory::createAttribute( "AddressAttribute" ); QVERIFY( dynamic_cast( a ) ); } { Attribute *a = AttributeFactory::createAttribute( "DispatchModeAttribute" ); QVERIFY( dynamic_cast( a ) ); } { Attribute *a = AttributeFactory::createAttribute( "ErrorAttribute" ); QVERIFY( dynamic_cast( a ) ); } { Attribute *a = AttributeFactory::createAttribute( "SentBehaviourAttribute" ); QVERIFY( dynamic_cast( a ) ); } { Attribute *a = AttributeFactory::createAttribute( "TransportAttribute" ); QVERIFY( dynamic_cast( a ) ); } } void AttributeTest::testSerialization() { { QString from( "from@me.org" ); QStringList to( "to1@me.org" ); to << "to2@me.org"; QStringList cc( "cc1@me.org" ); cc << "cc2@me.org"; QStringList bcc( "bcc1@me.org" ); bcc << "bcc2@me.org"; AddressAttribute *a = new AddressAttribute( from, to, cc, bcc ); QByteArray data = a->serialized(); delete a; a = new AddressAttribute; a->deserialize( data ); QCOMPARE( from, a->from() ); QCOMPARE( to, a->to() ); QCOMPARE( cc, a->cc() ); QCOMPARE( bcc, a->bcc() ); } { DispatchModeAttribute::DispatchMode mode = DispatchModeAttribute::AfterDueDate; QDateTime date = QDateTime::currentDateTime(); // The serializer does not keep track of milliseconds, so forget them. kDebug() << "ms" << date.toString( "z" ); int ms = date.toString( "z" ).toInt(); date = date.addMSecs( -ms ); DispatchModeAttribute *a = new DispatchModeAttribute( mode, date ); QByteArray data = a->serialized(); delete a; a = new DispatchModeAttribute; a->deserialize( data ); QCOMPARE( mode, a->dispatchMode() ); QCOMPARE( date, a->dueDate() ); } { QString msg( "The #!@$ing thing failed!" ); ErrorAttribute *a = new ErrorAttribute( msg ); QByteArray data = a->serialized(); delete a; a = new ErrorAttribute; a->deserialize( data ); QCOMPARE( msg, a->message() ); } { SentBehaviourAttribute::SentBehaviour beh = SentBehaviourAttribute::MoveToCollection; Collection::Id id = 123456789012345ll; SentBehaviourAttribute *a = new SentBehaviourAttribute( beh, id ); QByteArray data = a->serialized(); delete a; a = new SentBehaviourAttribute; a->deserialize( data ); QCOMPARE( beh, a->sentBehaviour() ); QCOMPARE( id, a->moveToCollection() ); } { int id = 3219; TransportAttribute *a = new TransportAttribute( id ); QByteArray data = a->serialized(); delete a; a = new TransportAttribute; a->deserialize( data ); QCOMPARE( id, a->transportId() ); } } QTEST_AKONADIMAIN( AttributeTest, NoGUI ) #include "attributetest.moc" diff --git a/outboxinterface/tests/messagequeuejobtest.cpp b/outboxinterface/tests/messagequeuejobtest.cpp index e49c06180..46608df07 100644 --- a/outboxinterface/tests/messagequeuejobtest.cpp +++ b/outboxinterface/tests/messagequeuejobtest.cpp @@ -1,193 +1,193 @@ /* Copyright 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 "messagequeuejobtest.h" #include #include #include #include #include #include #include #include #include #include #include #include +#include #include #include #include #include -#include #include #include #include #include #include #define SPAM_ADDRESS ( QStringList() << "idanoka@gmail.com" ) using namespace Akonadi; using namespace KMime; using namespace MailTransport; using namespace OutboxInterface; void MessageQueueJobTest::initTestCase() { Control::start(); // HACK: Otherwise the MDA is not switched offline soon enough apparently... QTest::qWait( 1000 ); // Switch MDA offline to avoid spam. AgentInstance mda = AgentManager::self()->instance( "akonadi_maildispatcher_agent" ); QVERIFY( mda.isValid() ); mda.setIsOnline( false ); // check that outbox is empty LocalFolders::self()->fetch(); QTest::kWaitForSignal( LocalFolders::self(), SIGNAL( foldersReady() ) ); verifyOutboxContents( 0 ); } void MessageQueueJobTest::testValidMessages() { // check transport int tid = TransportManager::self()->defaultTransportId(); QVERIFY2( tid >= 0, "I need a default transport, but there is none." ); // send a valid message using the default transport MessageQueueJob *qjob = new MessageQueueJob; qjob->setTransportId( tid ); Message::Ptr msg = Message::Ptr( new Message ); msg->setContent( "\nThis is message #1 from the MessageQueueJobTest unit test.\n" ); qjob->setMessage( msg ); qjob->setTo( SPAM_ADDRESS ); verifyOutboxContents( 0 ); AKVERIFYEXEC( qjob ); // fetch the message and verify it QTest::qWait( 1000 ); verifyOutboxContents( 1 ); ItemFetchJob *fjob = new ItemFetchJob( LocalFolders::self()->outbox() ); fjob->fetchScope().fetchFullPayload(); fjob->fetchScope().fetchAllAttributes(); AKVERIFYEXEC( fjob ); QCOMPARE( fjob->items().count(), 1 ); Item item = fjob->items().first(); QVERIFY( !item.remoteId().isEmpty() ); // stored by the resource QVERIFY( item.hasPayload() ); AddressAttribute *addrA = item.attribute(); QVERIFY( addrA ); QVERIFY( addrA->from().isEmpty() ); QCOMPARE( addrA->to().count(), 1 ); QCOMPARE( addrA->to(), SPAM_ADDRESS ); QCOMPARE( addrA->cc().count(), 0 ); QCOMPARE( addrA->bcc().count(), 0 ); DispatchModeAttribute *dA = item.attribute(); QVERIFY( dA ); QCOMPARE( dA->dispatchMode(), DispatchModeAttribute::Immediately ); // default mode SentBehaviourAttribute *sA = item.attribute(); QVERIFY( sA ); QCOMPARE( sA->sentBehaviour(), SentBehaviourAttribute::MoveToDefaultSentCollection ); // default sent collection TransportAttribute *tA = item.attribute(); QVERIFY( tA ); QCOMPARE( tA->transportId(), tid ); ErrorAttribute *eA = item.attribute(); QVERIFY( !eA ); // no error QCOMPARE( item.flags().count(), 1 ); QVERIFY( item.flags().contains( "queued" ) ); // delete message, for further tests ItemDeleteJob *djob = new ItemDeleteJob( item ); AKVERIFYEXEC( djob ); verifyOutboxContents( 0 ); // TODO test with no To: but only BCC: // TODO test due-date sending // TODO test sending with custom sent-mail collections } void MessageQueueJobTest::testInvalidMessages() { MessageQueueJob *job = 0; Message::Ptr msg; // without message job = new MessageQueueJob; job->setTransportId( TransportManager::self()->defaultTransportId() ); job->setTo( SPAM_ADDRESS ); QVERIFY( !job->exec() ); // without recipients job = new MessageQueueJob; msg = Message::Ptr( new Message ); msg->setContent( "\nThis is a message sent from the MessageQueueJobTest unittest. This shouldn't have been sent.\n" ); job->setMessage( msg ); job->setTransportId( TransportManager::self()->defaultTransportId() ); QVERIFY( !job->exec() ); // without transport job = new MessageQueueJob; msg = Message::Ptr( new Message ); msg->setContent( "\nThis is a message sent from the MessageQueueJobTest unittest. This shouldn't have been sent.\n" ); job->setMessage( msg ); job->setTo( SPAM_ADDRESS ); QVERIFY( !job->exec() ); // with AfterDueDate and no due date job = new MessageQueueJob; msg = Message::Ptr( new Message ); msg->setContent( "\nThis is a message sent from the MessageQueueJobTest unittest. This shouldn't have been sent.\n" ); job->setMessage( msg ); job->setTo( SPAM_ADDRESS ); job->setDispatchMode( DispatchModeAttribute::AfterDueDate ); QVERIFY( !job->exec() ); // with MoveToCollection and no sent-mail folder job = new MessageQueueJob; msg = Message::Ptr( new Message ); msg->setContent( "\nThis is a message sent from the MessageQueueJobTest unittest. This shouldn't have been sent.\n" ); job->setMessage( msg ); job->setTo( SPAM_ADDRESS ); job->setSentBehaviour( SentBehaviourAttribute::MoveToCollection ); QVERIFY( !job->exec() ); } void MessageQueueJobTest::verifyOutboxContents( qlonglong count ) { QVERIFY( LocalFolders::self()->isReady() ); Collection outbox = LocalFolders::self()->outbox(); QVERIFY( outbox.isValid() ); CollectionStatisticsJob *job = new CollectionStatisticsJob( outbox ); AKVERIFYEXEC( job ); QCOMPARE( job->statistics().count(), count ); } QTEST_AKONADIMAIN( MessageQueueJobTest, NoGUI ) #include "messagequeuejobtest.moc"