24
24
#include "mailcommon_export.h"
26
26
#include <akonadi/collection.h>
27
#include <akonadi/item.h>
27
28
#include <kmime/kmime_mdn.h>
28
29
#include <kmime/kmime_message.h>
32
33
#include <QtCore/QMultiHash>
33
34
#include <QtCore/QStringList>
39
36
class KTemporaryFile;
42
39
namespace MailCommon {
42
* @short A helper class for the filtering process
44
* The item context is used to pass the item together with meta data
45
* through the filter chain.
46
* This allows to 'record' all actions that shall be taken and execute them
47
* at the end of the filter chain.
49
class MAILCOMMON_EXPORT ItemContext
53
* Creates an item context for the given @p item.
55
ItemContext( const Akonadi::Item &item );
58
* Returns the item of the context.
60
Akonadi::Item& item();
63
* Sets the target collection the item should be moved to.
65
void setMoveTargetCollection( const Akonadi::Collection &collection );
68
* Returns the target collection the item should be moved to, or an invalid
69
* collection if the item should not be moved at all.
71
Akonadi::Collection moveTargetCollection() const;
74
* Marks that the item's payload has been changed and needs to be written back.
76
void setNeedsPayloadStore();
79
* Returns whether the item's payload needs to be written back.
81
bool needsPayloadStore() const;
84
* Marks that the item's flags has been changed and needs to be written back.
86
void setNeedsFlagStore();
89
* Returns whether the item's flags needs to be written back.
91
bool needsFlagStore() const;
95
Akonadi::Collection mMoveTargetCollection;
96
bool mNeedsPayloadStore;
44
100
//=========================================================
46
102
// class FilterAction
101
157
QString name() const;
104
* Execute action on given message. Returns @p CriticalError if a
160
* Execute action on given message (inside the item context).
161
* Returns @p CriticalError if a
105
162
* critical error has occurred (eg. disk full), @p ErrorButGoOn if
106
163
* there was a non-critical error (e.g. invalid address in
107
164
* 'forward' action), @p ErrorNeedComplete if a complete message
108
165
* is required, @p GoOn if the message shall be processed by
109
166
* further filters and @p Ok otherwise.
111
virtual ReturnCode process( const Akonadi::Item &item ) const = 0;
168
virtual ReturnCode process( ItemContext &context ) const = 0;
114
171
* Determines if the action depends on the body of the message
154
211
virtual void argsFromString( const QString &argsStr ) = 0;
214
* Read extra arguments from given string.
216
virtual void argsFromStringInteractive( const QString &argsStr, const QString &filterName );
218
virtual QString argsAsStringReal() const;
157
220
* Return extra arguments as string. Must not contain newlines.
159
222
virtual QString argsAsString() const = 0;
469
532
virtual QString argsAsString() const;
534
virtual void argsFromStringInteractive( const QString &argsStr, const QString& filterName );
536
virtual QString argsAsStringReal() const;
472
539
* @copydoc FilterAction::displayString
648
714
virtual QString substituteCommandLineArgsFor( const KMime::Message::Ptr &aMsg, QList<KTemporaryFile*> &aTempFileList ) const;
650
virtual ReturnCode genericProcess( const Akonadi::Item &item, bool filtering ) const;
716
virtual ReturnCode genericProcess( ItemContext &context, bool filtering ) const;