mailtransport
outboxactions.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 "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 return scope; 00050 } 00051 00052 bool SendQueuedAction::itemAccepted( const Item &item ) const 00053 { 00054 if( !item.hasAttribute<DispatchModeAttribute>() ) { 00055 kWarning() << "Item doesn't have DispatchModeAttribute."; 00056 return false; 00057 } 00058 00059 return item.attribute<DispatchModeAttribute>()->dispatchMode() == DispatchModeAttribute::Manual; 00060 } 00061 00062 Job *SendQueuedAction::itemAction( const Item &item ) const 00063 { 00064 Item cp = item; 00065 cp.addAttribute( new DispatchModeAttribute ); // defaults to Automatic 00066 return new ItemModifyJob( cp ); 00067 } 00068 00069 class MailTransport::ClearErrorAction::Private 00070 { 00071 }; 00072 00073 ClearErrorAction::ClearErrorAction() 00074 : d( new Private ) 00075 { 00076 } 00077 00078 ClearErrorAction::~ClearErrorAction() 00079 { 00080 delete d; 00081 } 00082 00083 ItemFetchScope ClearErrorAction::fetchScope() const 00084 { 00085 ItemFetchScope scope; 00086 scope.fetchFullPayload( false ); 00087 scope.fetchAttribute<ErrorAttribute>(); 00088 return scope; 00089 } 00090 00091 bool ClearErrorAction::itemAccepted( const Item &item ) const 00092 { 00093 return item.hasAttribute<ErrorAttribute>(); 00094 } 00095 00096 Job *ClearErrorAction::itemAction( const Item &item ) const 00097 { 00098 Item cp = item; 00099 cp.removeAttribute<ErrorAttribute>(); 00100 cp.clearFlag( "error" ); 00101 cp.setFlag( "queued" ); 00102 return new ItemModifyJob( cp ); 00103 } 00104