• Skip to content
  • Skip to link menu
KDE 4.5 API Reference
  • KDE API Reference
  • KDE-PIM Libraries
  • Sitemap
  • Contact Us
 

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   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 ); // defaults to Automatic
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 ); // defaults to Automatic
00152   cp.setFlag( "queued" );
00153   return new ItemModifyJob( cp, parent );
00154 }

mailtransport

Skip menu "mailtransport"
  • Main Page
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

KDE-PIM Libraries

Skip menu "KDE-PIM Libraries"
  • akonadi
  •   contact
  •   kmime
  • kabc
  • kblog
  • kcal
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  •   richtextbuilders
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Generated for KDE-PIM Libraries by doxygen 1.7.1
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal