~ubuntu-branches/ubuntu/quantal/kdepim/quantal

« back to all changes in this revision

Viewing changes to mailcommon/filteraction.h

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2011-12-15 14:17:51 UTC
  • mto: This revision was merged to the branch mainline in revision 193.
  • Revision ID: package-import@ubuntu.com-20111215141751-bmhdpiwl23wd9w26
Tags: upstream-4.7.90
ImportĀ upstreamĀ versionĀ 4.7.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
#include "mailcommon_export.h"
25
25
 
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>
29
30
 
32
33
#include <QtCore/QMultiHash>
33
34
#include <QtCore/QStringList>
34
35
 
35
 
namespace Akonadi {
36
 
  class Item;
37
 
}
38
 
 
39
36
class KTemporaryFile;
40
37
class QWidget;
41
38
 
42
39
namespace MailCommon {
43
40
 
 
41
/**
 
42
 * @short A helper class for the filtering process
 
43
 *
 
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.
 
48
 */
 
49
class MAILCOMMON_EXPORT ItemContext
 
50
{
 
51
  public:
 
52
    /**
 
53
     * Creates an item context for the given @p item.
 
54
     */
 
55
    ItemContext( const Akonadi::Item &item );
 
56
 
 
57
    /**
 
58
     * Returns the item of the context.
 
59
     */
 
60
    Akonadi::Item& item();
 
61
 
 
62
    /**
 
63
     * Sets the target collection the item should be moved to.
 
64
     */
 
65
    void setMoveTargetCollection( const Akonadi::Collection &collection );
 
66
 
 
67
    /**
 
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.
 
70
     */
 
71
    Akonadi::Collection moveTargetCollection() const;
 
72
 
 
73
    /**
 
74
     * Marks that the item's payload has been changed and needs to be written back.
 
75
     */
 
76
    void setNeedsPayloadStore();
 
77
 
 
78
    /**
 
79
     * Returns whether the item's payload needs to be written back.
 
80
     */
 
81
    bool needsPayloadStore() const;
 
82
 
 
83
    /**
 
84
     * Marks that the item's flags has been changed and needs to be written back.
 
85
     */
 
86
    void setNeedsFlagStore();
 
87
 
 
88
    /**
 
89
     * Returns whether the item's flags needs to be written back.
 
90
     */
 
91
    bool needsFlagStore() const;
 
92
 
 
93
  private:
 
94
    Akonadi::Item mItem;
 
95
    Akonadi::Collection mMoveTargetCollection;
 
96
    bool mNeedsPayloadStore;
 
97
    bool mNeedsFlagStore;
 
98
};
 
99
 
44
100
//=========================================================
45
101
//
46
102
// class FilterAction
101
157
    QString name() const;
102
158
 
103
159
    /**
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.
110
167
     */
111
 
    virtual ReturnCode process( const Akonadi::Item &item ) const = 0;
 
168
    virtual ReturnCode process( ItemContext &context ) const = 0;
112
169
 
113
170
    /**
114
171
     * Determines if the action depends on the body of the message
154
211
    virtual void argsFromString( const QString &argsStr ) = 0;
155
212
 
156
213
    /**
 
214
     * Read extra arguments from given string.
 
215
     */
 
216
    virtual void argsFromStringInteractive( const QString &argsStr, const QString &filterName );
 
217
 
 
218
    virtual QString argsAsStringReal() const;
 
219
    /**
157
220
     * Return extra arguments as string. Must not contain newlines.
158
221
     */
159
222
    virtual QString argsAsString() const = 0;
468
531
     */
469
532
    virtual QString argsAsString() const;
470
533
 
 
534
    virtual void argsFromStringInteractive( const QString &argsStr, const QString& filterName );
 
535
  
 
536
    virtual QString argsAsStringReal() const;
 
537
 
471
538
    /**
472
539
     * @copydoc FilterAction::displayString
473
540
     */
480
547
 
481
548
  protected:
482
549
    Akonadi::Collection mFolder;
483
 
    QString mFolderName;
484
550
};
485
551
 
486
552
 
647
713
     */
648
714
    virtual QString substituteCommandLineArgsFor( const KMime::Message::Ptr &aMsg, QList<KTemporaryFile*> &aTempFileList  ) const;
649
715
 
650
 
    virtual ReturnCode genericProcess( const Akonadi::Item &item, bool filtering ) const;
 
716
    virtual ReturnCode genericProcess( ItemContext &context, bool filtering ) const;
651
717
};
652
718
 
653
719