mailtransport
dispatcherinterface.cpp
00001 /* 00002 Copyright (c) 2009 Constantin Berzan <exit3219@gmail.com> 00003 00004 This library is free software; you can redistribute it and/or modify it 00005 under the terms of the GNU Library General Public License as published by 00006 the Free Software Foundation; either version 2 of the License, or (at your 00007 option) any later version. 00008 00009 This library is distributed in the hope that it will be useful, but WITHOUT 00010 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00011 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public 00012 License for more details. 00013 00014 You should have received a copy of the GNU Library General Public License 00015 along with this library; see the file COPYING.LIB. If not, write to the 00016 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 00017 02110-1301, USA. 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 <akonadi/kmime/specialmailcollections.h> 00032 #include "transportattribute.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 // Nothing to do here, really. If the job fails, the user can retry it. 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 = 00066 SpecialMailCollections::self()->defaultCollection( SpecialMailCollections::Outbox ); 00067 if( !outbox.isValid() ) { 00068 kError() << "Could not access Outbox."; 00069 return; 00070 } 00071 00072 FilterActionJob *mjob = new FilterActionJob( outbox, new SendQueuedAction, sInstance ); 00073 QObject::connect( mjob, SIGNAL(result(KJob*)), sInstance, SLOT(massModifyResult(KJob*)) ); 00074 } 00075 00076 void DispatcherInterface::retryDispatching() 00077 { 00078 Collection outbox = 00079 SpecialMailCollections::self()->defaultCollection( SpecialMailCollections::Outbox ); 00080 if( !outbox.isValid() ) { 00081 kError() << "Could not access Outbox."; 00082 return; 00083 } 00084 00085 FilterActionJob *mjob = new FilterActionJob( outbox, new ClearErrorAction, sInstance ); 00086 QObject::connect( mjob, SIGNAL(result(KJob*)), sInstance, SLOT(massModifyResult(KJob*)) ); 00087 } 00088 00089 void DispatcherInterface::dispatchManualTransport( int transportId ) 00090 { 00091 Collection outbox = 00092 SpecialMailCollections::self()->defaultCollection( SpecialMailCollections::Outbox ); 00093 if( !outbox.isValid() ) { 00094 kError() << "Could not access Outbox."; 00095 return; 00096 } 00097 00098 FilterActionJob *mjob = 00099 new FilterActionJob( outbox, new DispatchManualTransportAction( transportId ), sInstance ); 00100 QObject::connect( mjob, SIGNAL(result(KJob*)), sInstance, SLOT(massModifyResult(KJob*)) ); 00101 } 00102 00103 #include "dispatcherinterface_p.moc"
This file is part of the KDE documentation.
Documentation copyright © 1996-2012 The KDE developers.
Generated on Mon Aug 27 2012 22:09:03 by doxygen 1.7.5 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2012 The KDE developers.
Generated on Mon Aug 27 2012 22:09:03 by doxygen 1.7.5 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.