00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "outboxactions_p.h"
00021
00022 #include "dispatchmodeattribute.h"
00023 #include "errorattribute.h"
00024
00025 #include <akonadi/itemmodifyjob.h>
00026
00027 using namespace Akonadi;
00028 using namespace MailTransport;
00029
00030 class MailTransport::SendQueuedAction::Private
00031 {
00032 };
00033
00034 SendQueuedAction::SendQueuedAction()
00035 : d( new Private )
00036 {
00037 }
00038
00039 SendQueuedAction::~SendQueuedAction()
00040 {
00041 delete d;
00042 }
00043
00044 ItemFetchScope SendQueuedAction::fetchScope() const
00045 {
00046 ItemFetchScope scope;
00047 scope.fetchFullPayload( false );
00048 scope.fetchAttribute<DispatchModeAttribute>();
00049 scope.setCacheOnly( true );
00050 return scope;
00051 }
00052
00053 bool SendQueuedAction::itemAccepted( const Item &item ) const
00054 {
00055 if( !item.hasAttribute<DispatchModeAttribute>() ) {
00056 kWarning() << "Item doesn't have DispatchModeAttribute.";
00057 return false;
00058 }
00059
00060 return item.attribute<DispatchModeAttribute>()->dispatchMode() == DispatchModeAttribute::Manual;
00061 }
00062
00063 Job *SendQueuedAction::itemAction( const Item &item, FilterActionJob *parent ) const
00064 {
00065 Item cp = item;
00066 cp.addAttribute( new DispatchModeAttribute );
00067 return new ItemModifyJob( cp, parent );
00068 }
00069
00070 class MailTransport::ClearErrorAction::Private
00071 {
00072 };
00073
00074 ClearErrorAction::ClearErrorAction()
00075 : d( new Private )
00076 {
00077 }
00078
00079 ClearErrorAction::~ClearErrorAction()
00080 {
00081 delete d;
00082 }
00083
00084 ItemFetchScope ClearErrorAction::fetchScope() const
00085 {
00086 ItemFetchScope scope;
00087 scope.fetchFullPayload( false );
00088 scope.fetchAttribute<ErrorAttribute>();
00089 scope.setCacheOnly( true );
00090 return scope;
00091 }
00092
00093 bool ClearErrorAction::itemAccepted( const Item &item ) const
00094 {
00095 return item.hasAttribute<ErrorAttribute>();
00096 }
00097
00098 Job *ClearErrorAction::itemAction( const Item &item, FilterActionJob *parent ) const
00099 {
00100 Item cp = item;
00101 cp.removeAttribute<ErrorAttribute>();
00102 cp.clearFlag( "error" );
00103 cp.setFlag( "queued" );
00104 return new ItemModifyJob( cp, parent );
00105 }
00106
00107 class MailTransport::DispatchManualTransportAction::Private
00108 {
00109 };
00110
00111 DispatchManualTransportAction::DispatchManualTransportAction( int transportId )
00112 : d( new Private ), mTransportId( transportId )
00113 {
00114 }
00115
00116 DispatchManualTransportAction::~DispatchManualTransportAction()
00117 {
00118 delete d;
00119 }
00120
00121 ItemFetchScope DispatchManualTransportAction::fetchScope() const
00122 {
00123 ItemFetchScope scope;
00124 scope.fetchFullPayload( false );
00125 scope.fetchAttribute<TransportAttribute>();
00126 scope.fetchAttribute<DispatchModeAttribute>();
00127 scope.setCacheOnly( true );
00128 return scope;
00129 }
00130
00131 bool DispatchManualTransportAction::itemAccepted( const Item &item ) const
00132 {
00133 if( !item.hasAttribute<DispatchModeAttribute>() ) {
00134 kWarning() << "Item doesn't have DispatchModeAttribute.";
00135 return false;
00136 }
00137
00138 if( !item.hasAttribute<TransportAttribute>() ) {
00139 kWarning() << "Item doesn't have TransportAttribute.";
00140 return false;
00141 }
00142
00143 return item.attribute<DispatchModeAttribute>()->dispatchMode() == DispatchModeAttribute::Manual;
00144 }
00145
00146 Job *DispatchManualTransportAction::itemAction( const Item &item, FilterActionJob *parent ) const
00147 {
00148 Item cp = item;
00149 cp.attribute<TransportAttribute>()->setTransportId( mTransportId );
00150 cp.removeAttribute<DispatchModeAttribute>();
00151 cp.addAttribute( new DispatchModeAttribute );
00152 cp.setFlag( "queued" );
00153 return new ItemModifyJob( cp, parent );
00154 }