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

List:       kde-commits
Subject:    branches/work/akonadi-ports/kdepimlibs/mailtransport
From:       Constantin Berzan <exit3219 () gmail ! com>
Date:       2009-08-27 10:22:41
Message-ID: 1251368561.307835.13073.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 1016260 by cberzan:

Adapt to new LocalFolders API.


 M  +8 -8      dispatcherinterface.cpp  
 M  +17 -12    messagequeuejob.cpp  
 M  +1 -1      messagequeuejob.h  
 M  +7 -4      tests/clearerror.cpp  
 M  +7 -5      tests/messagequeuejobtest.cpp  
 M  +7 -4      tests/sendqueued.cpp  


--- branches/work/akonadi-ports/kdepimlibs/mailtransport/dispatcherinterface.cpp #1016259:1016260
@@ -93,25 +93,25 @@
 
 void DispatcherInterface::dispatchManually()
 {
-  if( !LocalFolders::self()->isReady() ) {
-    kWarning() << "LocalFolders not ready.";
+  Collection outbox = LocalFolders::self()->defaultFolder( LocalFolders::Outbox );
+  if( !outbox.isValid() ) {
+    kError() << "Could not access Outbox.";
     return;
   }
 
-  FilterActionJob *mjob =
-    new FilterActionJob( LocalFolders::self()->outbox(), new SendQueuedAction, this );
+  FilterActionJob *mjob = new FilterActionJob( outbox, new SendQueuedAction, this );
   connect( mjob, SIGNAL(result(KJob*)), this, SLOT(massModifyResult(KJob*)) );
 }
 
 void DispatcherInterface::retryDispatching()
 {
-  if( !LocalFolders::self()->isReady() ) {
-    kWarning() << "LocalFolders not ready.";
+  Collection outbox = LocalFolders::self()->defaultFolder( LocalFolders::Outbox );
+  if( !outbox.isValid() ) {
+    kError() << "Could not access Outbox.";
     return;
   }
 
-  FilterActionJob *mjob =
-    new FilterActionJob( LocalFolders::self()->outbox(), new ClearErrorAction, this );
+  FilterActionJob *mjob = new FilterActionJob( outbox, new ClearErrorAction, this );
   connect( mjob, SIGNAL(result(KJob*)), this, SLOT(massModifyResult(KJob*)) );
 }
 
--- branches/work/akonadi-ports/kdepimlibs/mailtransport/messagequeuejob.cpp #1016259:1016260
@@ -31,6 +31,7 @@
 #include <akonadi/itemcreatejob.h>
 #include <akonadi/kmime/addressattribute.h>
 #include <akonadi/kmime/localfolders.h>
+#include <akonadi/kmime/localfoldersrequestjob.h>
 
 using namespace Akonadi;
 using namespace KMime;
@@ -73,7 +74,7 @@
     bool validate();
 
     // slot
-    void doStart();
+    void outboxRequestResult( KJob *job );
 
 };
 
@@ -113,19 +114,22 @@
     q->emitResult();
     return false;
   } else if( sentBehaviour == SentBehaviourAttribute::MoveToDefaultSentCollection ) {
-    Q_ASSERT( LocalFolders::self()->isReady() );
-    Q_ASSERT( LocalFolders::self()->sentMail().isValid() );
+    // TODO require LocalFolders::SentMail here?
   }
 
   return true; // all ok
 }
 
-void MessageQueueJob::Private::doStart()
+void MessageQueueJob::Private::outboxRequestResult( KJob *job )
 {
-  LocalFolders::self()->disconnect( q );
   Q_ASSERT( !started );
   started = true;
 
+  if( job->error() ) {
+    kError() << "Failed to get the Outbox folder:" << job->error();
+    return;
+  }
+
   if( !validate() ) {
     // The error has been set; the result has been emitted.
     return;
@@ -150,10 +154,10 @@
   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 );
+  Collection col = LocalFolders::self()->defaultFolder( LocalFolders::Outbox );
+  Q_ASSERT( col.isValid() );
+  ItemCreateJob *cjob = new ItemCreateJob( item, col ); // job autostarts
+  q->addSubjob( cjob );
 }
 
 MessageQueueJob::MessageQueueJob( QObject *parent )
@@ -269,9 +273,10 @@
 
 void MessageQueueJob::start()
 {
-  LocalFolders *folders = LocalFolders::self();
-  connect( folders, SIGNAL( foldersReady() ), this, SLOT( doStart() ) );
-  folders->fetch(); // will emit foldersReady()
+  LocalFoldersRequestJob *rjob = new LocalFoldersRequestJob( this );
+  rjob->requestDefaultFolder( LocalFolders::Outbox );
+  connect( rjob, SIGNAL(result(KJob*)), this, SLOT(outboxRequestResult(KJob*)) );
+  rjob->start();
 }
 
 void MessageQueueJob::slotResult( KJob *job )
--- branches/work/akonadi-ports/kdepimlibs/mailtransport/messagequeuejob.h #1016259:1016260
@@ -246,7 +246,7 @@
     friend class Private;
     Private *const d;
 
-    Q_PRIVATE_SLOT( d, void doStart() )
+    Q_PRIVATE_SLOT( d, void outboxRequestResult( KJob* ) )
 
 };
 
--- branches/work/akonadi-ports/kdepimlibs/mailtransport/tests/clearerror.cpp #1016259:1016260
@@ -28,6 +28,7 @@
 #include <akonadi/control.h>
 #include <akonadi/filteractionjob.h>
 #include <akonadi/kmime/localfolders.h>
+#include <akonadi/kmime/localfoldersrequestjob.h>
 
 #include <mailtransport/outboxactions.h>
 
@@ -39,17 +40,19 @@
 {
   Control::start();
 
-  connect( LocalFolders::self(), SIGNAL( foldersReady() ),
-      this, SLOT( checkFolders() ) );
-  LocalFolders::self()->fetch();
+  LocalFoldersRequestJob *rjob = new LocalFoldersRequestJob( this );
+  rjob->requestDefaultFolder( LocalFolders::Outbox );
+  connect( rjob, SIGNAL(result(KJob*)), this, SLOT(checkFolders()) );
+  rjob->start();
 }
 
 void Runner::checkFolders()
 {
-  Collection outbox = LocalFolders::self()->outbox();
+  Collection outbox = LocalFolders::self()->defaultFolder( LocalFolders::Outbox );
   kDebug() << "Got outbox" << outbox.id();
 
   if( !outbox.isValid() ) {
+    kError() << "Failed to get outbox folder.";
     KApplication::exit( 1 );
   }
 
--- branches/work/akonadi-ports/kdepimlibs/mailtransport/tests/messagequeuejobtest.cpp #1016259:1016260
@@ -32,6 +32,7 @@
 #include <akonadi/itemdeletejob.h>
 #include <akonadi/qtest_akonadi.h>
 #include <akonadi/kmime/localfolders.h>
+#include <akonadi/kmime/localfoldersrequestjob.h>
 #include <akonadi/kmime/addressattribute.h>
 
 #include <kmime/kmime_message.h>
@@ -64,8 +65,9 @@
   mda.setIsOnline( false );
 
   // check that outbox is empty
-  LocalFolders::self()->fetch();
-  QTest::kWaitForSignal( LocalFolders::self(), SIGNAL( foldersReady() ) );
+  LocalFoldersRequestJob *rjob = new LocalFoldersRequestJob( this );
+  rjob->requestDefaultFolder( LocalFolders::Outbox );
+  QTest::kWaitForSignal( rjob, SIGNAL(result(KJob*)) );
   verifyOutboxContents( 0 );
 }
 
@@ -88,7 +90,7 @@
   // fetch the message and verify it
   QTest::qWait( 1000 );
   verifyOutboxContents( 1 );
-  ItemFetchJob *fjob = new ItemFetchJob( LocalFolders::self()->outbox() );
+  ItemFetchJob *fjob = new ItemFetchJob( LocalFolders::self()->defaultFolder( LocalFolders::Outbox ) );
   fjob->fetchScope().fetchFullPayload();
   fjob->fetchScope().fetchAllAttributes();
   AKVERIFYEXEC( fjob );
@@ -177,8 +179,8 @@
 
 void MessageQueueJobTest::verifyOutboxContents( qlonglong count )
 {
-  QVERIFY( LocalFolders::self()->isReady() );
-  Collection outbox = LocalFolders::self()->outbox();
+  QVERIFY( LocalFolders::self()->hasDefaultFolder( LocalFolders::Outbox ) );
+  Collection outbox = LocalFolders::self()->defaultFolder( LocalFolders::Outbox );
   QVERIFY( outbox.isValid() );
   CollectionStatisticsJob *job = new CollectionStatisticsJob( outbox );
   AKVERIFYEXEC( job );
--- branches/work/akonadi-ports/kdepimlibs/mailtransport/tests/sendqueued.cpp #1016259:1016260
@@ -28,6 +28,7 @@
 #include <akonadi/control.h>
 #include <akonadi/filteractionjob.h>
 #include <akonadi/kmime/localfolders.h>
+#include <akonadi/kmime/localfoldersrequestjob.h>
 
 #include <mailtransport/outboxactions.h>
 
@@ -39,17 +40,19 @@
 {
   Control::start();
 
-  connect( LocalFolders::self(), SIGNAL( foldersReady() ),
-      this, SLOT( checkFolders() ) );
-  LocalFolders::self()->fetch();
+  LocalFoldersRequestJob *rjob = new LocalFoldersRequestJob( this );
+  rjob->requestDefaultFolder( LocalFolders::Outbox );
+  connect( rjob, SIGNAL(result(KJob*)), this, SLOT(checkFolders()) );
+  rjob->start();
 }
 
 void Runner::checkFolders()
 {
-  Collection outbox = LocalFolders::self()->outbox();
+  Collection outbox = LocalFolders::self()->defaultFolder( LocalFolders::Outbox );
   kDebug() << "Got outbox" << outbox.id();
 
   if( !outbox.isValid() ) {
+    kError() << "Failed to get outbox folder.";
     KApplication::exit( 1 );
   }
 
[prev in list] [next in list] [prev in thread] [next in thread] 

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