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

mailtransport

  • 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
28using namespace Akonadi;
29using namespace MailTransport;
30
31class MailTransport::SendQueuedAction::Private
32{
33};
34
35SendQueuedAction::SendQueuedAction()
36 : d( new Private )
37{
38}
39
40SendQueuedAction::~SendQueuedAction()
41{
42 delete d;
43}
44
45ItemFetchScope 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
55bool 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
65Job *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
76class MailTransport::ClearErrorAction::Private
77{
78};
79
80ClearErrorAction::ClearErrorAction()
81 : d( new Private )
82{
83}
84
85ClearErrorAction::~ClearErrorAction()
86{
87 delete d;
88}
89
90ItemFetchScope ClearErrorAction::fetchScope() const
91{
92 ItemFetchScope scope;
93 scope.fetchFullPayload( false );
94 scope.fetchAttribute<ErrorAttribute>();
95 scope.setCacheOnly( true );
96 return scope;
97}
98
99bool ClearErrorAction::itemAccepted( const Item &item ) const
100{
101 return item.hasAttribute<ErrorAttribute>();
102}
103
104Job *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
113class MailTransport::DispatchManualTransportAction::Private
114{
115};
116
117DispatchManualTransportAction::DispatchManualTransportAction( int transportId )
118 : d( new Private ), mTransportId( transportId )
119{
120}
121
122DispatchManualTransportAction::~DispatchManualTransportAction()
123{
124 delete d;
125}
126
127ItemFetchScope 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
137bool 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
152Job *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}
Akonadi::FilterActionJob
Job to filter and apply an action on a set of items.
Definition filteractionjob_p.h:132
MailTransport::ClearErrorAction::~ClearErrorAction
virtual ~ClearErrorAction()
Destroys this object.
Definition outboxactions.cpp:85
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::ClearErrorAction::ClearErrorAction
ClearErrorAction()
Creates a ClearErrorAction.
Definition outboxactions.cpp:80
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::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::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::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::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
Attribute determining how and when a message from the outbox should be dispatched.
Definition dispatchmodeattribute.h:40
MailTransport::DispatchModeAttribute::Manual
@ Manual
Send message only when the user requests so.
Definition dispatchmodeattribute.h:48
MailTransport::ErrorAttribute
An Attribute to mark messages that failed to be sent.
Definition errorattribute.h:40
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::SendQueuedAction::SendQueuedAction
SendQueuedAction()
Creates a SendQueuedAction.
Definition outboxactions.cpp:35
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
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::SendQueuedAction::~SendQueuedAction
virtual ~SendQueuedAction()
Destroys this object.
Definition outboxactions.cpp:40
MailTransport::TransportAttribute
Attribute determining which transport to use for sending a message.
Definition transportattribute.h:41
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Wed Jan 24 2024 00:00:00 by doxygen 1.10.0 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-4.14.10 API Reference

Skip menu "kdepimlibs-4.14.10 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
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