Akonadi Mime

outboxactions.cpp
1/*
2 SPDX-FileCopyrightText: 2009 Constantin Berzan <exit3219@gmail.com>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#include "outboxactions_p.h"
8
9#include "akonadi_mime_debug.h"
10#include "dispatchmodeattribute.h"
11#include "errorattribute.h"
12
13#include <Akonadi/ItemModifyJob>
14#include <Akonadi/MessageFlags>
15
16using namespace Akonadi;
17
18SendQueuedAction::SendQueuedAction() = default;
19
20SendQueuedAction::~SendQueuedAction() = default;
21
22ItemFetchScope SendQueuedAction::fetchScope() const
23{
24 ItemFetchScope scope;
25 scope.fetchFullPayload(false);
28 scope.setCacheOnly(true);
29 return scope;
30}
31
32bool SendQueuedAction::itemAccepted(const Item &item) const
33{
34 if (!item.hasAttribute<DispatchModeAttribute>()) {
35 qCWarning(AKONADIMIME_LOG) << "Item doesn't have DispatchModeAttribute.";
36 return false;
37 }
38
39 return item.attribute<DispatchModeAttribute>()->dispatchMode() == DispatchModeAttribute::Manual;
40}
41
42Job *SendQueuedAction::itemAction(const Item &item, FilterActionJob *parent) const
43{
44 Item cp = item;
45 cp.addAttribute(new DispatchModeAttribute); // defaults to Automatic
46 if (cp.hasAttribute<ErrorAttribute>()) {
47 cp.removeAttribute<ErrorAttribute>();
49 }
50 return new ItemModifyJob(cp, parent);
51}
52
53ClearErrorAction::ClearErrorAction() = default;
54
55ClearErrorAction::~ClearErrorAction() = default;
56
57ItemFetchScope ClearErrorAction::fetchScope() const
58{
59 ItemFetchScope scope;
60 scope.fetchFullPayload(false);
62 scope.setCacheOnly(true);
63 return scope;
64}
65
66bool ClearErrorAction::itemAccepted(const Item &item) const
67{
68 return item.hasAttribute<ErrorAttribute>();
69}
70
71Job *ClearErrorAction::itemAction(const Item &item, FilterActionJob *parent) const
72{
73 Item cp = item;
74 cp.removeAttribute<ErrorAttribute>();
77 return new ItemModifyJob(cp, parent);
78}
79
80DispatchManualTransportAction::DispatchManualTransportAction(int transportId)
81 : mTransportId(transportId)
82{
83}
84
85DispatchManualTransportAction::~DispatchManualTransportAction() = default;
86
87ItemFetchScope DispatchManualTransportAction::fetchScope() const
88{
89 ItemFetchScope scope;
90 scope.fetchFullPayload(false);
93 scope.setCacheOnly(true);
94 return scope;
95}
96
97bool DispatchManualTransportAction::itemAccepted(const Item &item) const
98{
99 if (!item.hasAttribute<DispatchModeAttribute>()) {
100 qCWarning(AKONADIMIME_LOG) << "Item doesn't have DispatchModeAttribute.";
101 return false;
102 }
103
104 if (!item.hasAttribute<TransportAttribute>()) {
105 qCWarning(AKONADIMIME_LOG) << "Item doesn't have TransportAttribute.";
106 return false;
107 }
108
109 return item.attribute<DispatchModeAttribute>()->dispatchMode() == DispatchModeAttribute::Manual;
110}
111
112Job *DispatchManualTransportAction::itemAction(const Item &item, FilterActionJob *parent) const
113{
114 Item cp = item;
115 cp.attribute<TransportAttribute>()->setTransportId(mTransportId);
116 cp.removeAttribute<DispatchModeAttribute>();
117 cp.addAttribute(new DispatchModeAttribute); // defaults to Automatic
119 return new ItemModifyJob(cp, parent);
120}
Attribute determining how and when a message from the outbox should be dispatched.
@ Manual
specified by setSendAfter()
An Attribute to mark messages that failed to be sent.
void setCacheOnly(bool cacheOnly)
void fetchAttribute(bool fetch=true)
void fetchFullPayload(bool fetch=true)
Attribute determining which transport to use for sending a message.
AKONADI_MIME_EXPORT const char HasError[]
The flag for a message being marked with an error.
AKONADI_MIME_EXPORT const char Queued[]
The flag for a message being marked as queued.
void setFlag(Flag flag, bool enabled)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:05:31 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.