mailtransport
dispatcherinterface.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "dispatcherinterface.h"
00021 #include "dispatcherinterface_p.h"
00022
00023 #include "outboxactions_p.h"
00024
00025 #include <KDebug>
00026 #include <KGlobal>
00027 #include <KLocalizedString>
00028
00029 #include <akonadi/agentmanager.h>
00030 #include <akonadi/collection.h>
00031 #include "filteractionjob.h"
00032 #include <akonadi/kmime/specialmailcollections.h>
00033
00034 using namespace Akonadi;
00035 using namespace MailTransport;
00036
00037 K_GLOBAL_STATIC( DispatcherInterfacePrivate, sInstance )
00038
00039 void DispatcherInterfacePrivate::massModifyResult( KJob *job )
00040 {
00041
00042 if( job->error() ) {
00043 kDebug() << "failed" << job->errorString();
00044 } else {
00045 kDebug() << "succeeded.";
00046 }
00047 }
00048
00049 DispatcherInterface::DispatcherInterface()
00050 {
00051 }
00052
00053 AgentInstance DispatcherInterface::dispatcherInstance() const
00054 {
00055 AgentInstance a =
00056 AgentManager::self()->instance( QLatin1String( "akonadi_maildispatcher_agent" ) );
00057 if( !a.isValid() ) {
00058 kWarning() << "Could not get MDA instance.";
00059 }
00060 return a;
00061 }
00062
00063 void DispatcherInterface::dispatchManually()
00064 {
00065 Collection outbox = SpecialMailCollections::self()->defaultCollection( SpecialMailCollections::Outbox );
00066 if( !outbox.isValid() ) {
00067 kError() << "Could not access Outbox.";
00068 return;
00069 }
00070
00071 FilterActionJob *mjob = new FilterActionJob( outbox, new SendQueuedAction, sInstance );
00072 QObject::connect( mjob, SIGNAL(result(KJob*)), sInstance, SLOT(massModifyResult(KJob*)) );
00073 }
00074
00075 void DispatcherInterface::retryDispatching()
00076 {
00077 Collection outbox = SpecialMailCollections::self()->defaultCollection( SpecialMailCollections::Outbox );
00078 if( !outbox.isValid() ) {
00079 kError() << "Could not access Outbox.";
00080 return;
00081 }
00082
00083 FilterActionJob *mjob = new FilterActionJob( outbox, new ClearErrorAction, sInstance );
00084 QObject::connect( mjob, SIGNAL(result(KJob*)), sInstance, SLOT(massModifyResult(KJob*)) );
00085 }
00086
00087 #include "dispatcherinterface_p.moc"