• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepimlibs API Reference
  • KDE Home
  • Contact Us
 

mailtransport

  • sources
  • kde-4.14
  • kdepimlibs
  • mailtransport
outboxactions.cpp
1 /*
2  Copyright (c) 2009 Constantin Berzan <exit3219@gmail.com>
3 
4  This library is free software; you can redistribute it and/or modify it
5  under the terms of the GNU Library General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or (at your
7  option) any later version.
8 
9  This library is distributed in the hope that it will be useful, but WITHOUT
10  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
12  License for more details.
13 
14  You should have received a copy of the GNU Library General Public License
15  along with this library; see the file COPYING.LIB. If not, write to the
16  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17  02110-1301, USA.
18 */
19 
20 #include "outboxactions_p.h"
21 
22 #include "dispatchmodeattribute.h"
23 #include "errorattribute.h"
24 
25 #include <akonadi/itemmodifyjob.h>
26 #include <akonadi/kmime/messageflags.h>
27 
28 using namespace Akonadi;
29 using namespace MailTransport;
30 
31 class MailTransport::SendQueuedAction::Private
32 {
33 };
34 
35 SendQueuedAction::SendQueuedAction()
36  : d( new Private )
37 {
38 }
39 
40 SendQueuedAction::~SendQueuedAction()
41 {
42  delete d;
43 }
44 
45 ItemFetchScope SendQueuedAction::fetchScope() const
46 {
47  ItemFetchScope scope;
48  scope.fetchFullPayload( false );
49  scope.fetchAttribute<DispatchModeAttribute>();
50  scope.fetchAttribute<ErrorAttribute>();
51  scope.setCacheOnly( true );
52  return scope;
53 }
54 
55 bool SendQueuedAction::itemAccepted( const Item &item ) const
56 {
57  if ( !item.hasAttribute<DispatchModeAttribute>() ) {
58  kWarning() << "Item doesn't have DispatchModeAttribute.";
59  return false;
60  }
61 
62  return item.attribute<DispatchModeAttribute>()->dispatchMode() == DispatchModeAttribute::Manual;
63 }
64 
65 Job *SendQueuedAction::itemAction( const Item &item, FilterActionJob *parent ) const
66 {
67  Item cp = item;
68  cp.addAttribute( new DispatchModeAttribute ); // defaults to Automatic
69  if ( cp.hasAttribute<ErrorAttribute>() ) {
70  cp.removeAttribute<ErrorAttribute>();
71  cp.clearFlag( Akonadi::MessageFlags::HasError );
72  }
73  return new ItemModifyJob( cp, parent );
74 }
75 
76 class MailTransport::ClearErrorAction::Private
77 {
78 };
79 
80 ClearErrorAction::ClearErrorAction()
81  : d( new Private )
82 {
83 }
84 
85 ClearErrorAction::~ClearErrorAction()
86 {
87  delete d;
88 }
89 
90 ItemFetchScope ClearErrorAction::fetchScope() const
91 {
92  ItemFetchScope scope;
93  scope.fetchFullPayload( false );
94  scope.fetchAttribute<ErrorAttribute>();
95  scope.setCacheOnly( true );
96  return scope;
97 }
98 
99 bool ClearErrorAction::itemAccepted( const Item &item ) const
100 {
101  return item.hasAttribute<ErrorAttribute>();
102 }
103 
104 Job *ClearErrorAction::itemAction( const Item &item, FilterActionJob *parent ) const
105 {
106  Item cp = item;
107  cp.removeAttribute<ErrorAttribute>();
108  cp.clearFlag( Akonadi::MessageFlags::HasError );
109  cp.setFlag( Akonadi::MessageFlags::Queued );
110  return new ItemModifyJob( cp, parent );
111 }
112 
113 class MailTransport::DispatchManualTransportAction::Private
114 {
115 };
116 
117 DispatchManualTransportAction::DispatchManualTransportAction( int transportId )
118  : d( new Private ), mTransportId( transportId )
119 {
120 }
121 
122 DispatchManualTransportAction::~DispatchManualTransportAction()
123 {
124  delete d;
125 }
126 
127 ItemFetchScope DispatchManualTransportAction::fetchScope() const
128 {
129  ItemFetchScope scope;
130  scope.fetchFullPayload( false );
131  scope.fetchAttribute<TransportAttribute>();
132  scope.fetchAttribute<DispatchModeAttribute>();
133  scope.setCacheOnly( true );
134  return scope;
135 }
136 
137 bool DispatchManualTransportAction::itemAccepted( const Item &item ) const
138 {
139  if ( !item.hasAttribute<DispatchModeAttribute>() ) {
140  kWarning() << "Item doesn't have DispatchModeAttribute.";
141  return false;
142  }
143 
144  if ( !item.hasAttribute<TransportAttribute>() ) {
145  kWarning() << "Item doesn't have TransportAttribute.";
146  return false;
147  }
148 
149  return item.attribute<DispatchModeAttribute>()->dispatchMode() == DispatchModeAttribute::Manual;
150 }
151 
152 Job *DispatchManualTransportAction::itemAction( const Item &item, FilterActionJob *parent ) const
153 {
154  Item cp = item;
155  cp.attribute<TransportAttribute>()->setTransportId( mTransportId );
156  cp.removeAttribute<DispatchModeAttribute>();
157  cp.addAttribute( new DispatchModeAttribute ); // defaults to Automatic
158  cp.setFlag( Akonadi::MessageFlags::Queued );
159  return new ItemModifyJob( cp, parent );
160 }
MailTransport::ErrorAttribute
An Attribute to mark messages that failed to be sent.
Definition: errorattribute.h:39
MailTransport::SendQueuedAction::fetchScope
virtual Akonadi::ItemFetchScope fetchScope() const
Returns an ItemFetchScope to use if the FilterActionJob needs to fetch the items from a collection...
Definition: outboxactions.cpp:45
Akonadi::FilterActionJob
Job to filter and apply an action on a set of items.
Definition: filteractionjob_p.h:131
MailTransport::DispatchModeAttribute
Attribute determining how and when a message from the outbox should be dispatched.
Definition: dispatchmodeattribute.h:39
MailTransport::ClearErrorAction::fetchScope
virtual Akonadi::ItemFetchScope fetchScope() const
Returns an ItemFetchScope to use if the FilterActionJob needs to fetch the items from a collection...
Definition: outboxactions.cpp:90
MailTransport::SendQueuedAction::itemAction
virtual Akonadi::Job * itemAction(const Akonadi::Item &item, Akonadi::FilterActionJob *parent) const
Returns a job to act on the item.
Definition: outboxactions.cpp:65
MailTransport::ClearErrorAction::~ClearErrorAction
virtual ~ClearErrorAction()
Destroys this object.
Definition: outboxactions.cpp:85
MailTransport::SendQueuedAction::itemAccepted
virtual bool itemAccepted(const Akonadi::Item &item) const
Returns true if the item is accepted by the filter and should be acted upon by the FilterActionJob...
Definition: outboxactions.cpp:55
MailTransport::ClearErrorAction::ClearErrorAction
ClearErrorAction()
Creates a ClearErrorAction.
Definition: outboxactions.cpp:80
MailTransport::DispatchManualTransportAction::fetchScope
virtual Akonadi::ItemFetchScope fetchScope() const
Returns an ItemFetchScope to use if the FilterActionJob needs to fetch the items from a collection...
Definition: outboxactions.cpp:127
MailTransport::ClearErrorAction::itemAccepted
virtual bool itemAccepted(const Akonadi::Item &item) const
Returns true if the item is accepted by the filter and should be acted upon by the FilterActionJob...
Definition: outboxactions.cpp:99
MailTransport::DispatchManualTransportAction::itemAccepted
virtual bool itemAccepted(const Akonadi::Item &item) const
Returns true if the item is accepted by the filter and should be acted upon by the FilterActionJob...
Definition: outboxactions.cpp:137
MailTransport::SendQueuedAction::~SendQueuedAction
virtual ~SendQueuedAction()
Destroys this object.
Definition: outboxactions.cpp:40
MailTransport::ClearErrorAction::itemAction
virtual Akonadi::Job * itemAction(const Akonadi::Item &item, Akonadi::FilterActionJob *parent) const
Returns a job to act on the item.
Definition: outboxactions.cpp:104
MailTransport::DispatchManualTransportAction::itemAction
virtual Akonadi::Job * itemAction(const Akonadi::Item &item, Akonadi::FilterActionJob *parent) const
Returns a job to act on the item.
Definition: outboxactions.cpp:152
MailTransport::DispatchModeAttribute::Manual
Send message only when the user requests so.
Definition: dispatchmodeattribute.h:48
MailTransport::TransportAttribute
Attribute determining which transport to use for sending a message.
Definition: transportattribute.h:40
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:37:48 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

mailtransport

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

kdepimlibs API Reference

Skip menu "kdepimlibs API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal