krop's commit fixes my problem in a better way, reverting
[kdepim.git] / kmail / messageproperty.h
blob7e0df37779f30547ca777caa2dfe46fecb5f39e2
1 /* Message Property
3 This file is part of KMail, the KDE mail client.
4 Copyright (c) Don Sanders <sanders@kde.org>
6 KMail is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License, version 2, as
8 published by the Free Software Foundation.
10 KMail is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 In addition, as a special exception, the copyright holders give
20 permission to link the code of this program with any edition of
21 the Qt library by Trolltech AS, Norway (or with modified versions
22 of Qt that use the same license as Qt), and distribute linked
23 combinations including the two. You must obey the GNU General
24 Public License in all respects for all of the code used other than
25 Qt. If you modify this file, you may extend this exception to
26 your version of the file, but you are not obligated to do so. If
27 you do not wish to do so, delete this exception statement from
28 your version.
30 #ifndef messageproperty_h
31 #define messageproperty_h
33 #include "kmfilteraction.h" // for KMFilterAction::ReturnCode
34 #include "kmfolder.h"
36 #include <QPointer>
37 #include <QObject>
39 class KMFilter;
41 namespace KMail {
43 class ActionScheduler;
45 /* A place to store properties that some but not necessarily all messages
46 have.
48 These properties do not need to be stored persistantly on disk but
49 rather only are required while KMail is running.
51 Furthermore some properties, namely complete, transferInProgress, and
52 serialCache should only exist during the lifetime of a particular
53 KMMsgBase based instance.
55 class MessageProperty : public QObject
57 Q_OBJECT
59 public:
60 /** If the message is being filtered */
61 static bool filtering( quint32 );
62 static void setFiltering( quint32, bool filtering );
63 static bool filtering( const KMMsgBase* );
64 static void setFiltering( const KMMsgBase*, bool filtering );
65 /** The folder this message is to be moved into once
66 filtering is finished, or null if the message is not
67 scheduled to be moved */
68 static KMFolder* filterFolder( quint32 );
69 static void setFilterFolder( quint32, KMFolder* folder );
70 static KMFolder* filterFolder( const KMMsgBase* );
71 static void setFilterFolder( const KMMsgBase*, KMFolder* folder );
72 /* Set the filterHandler for a message */
73 static ActionScheduler* filterHandler( quint32 );
74 static void setFilterHandler( quint32, ActionScheduler* filterHandler );
75 static ActionScheduler* filterHandler( const KMMsgBase* );
76 static void setFilterHandler( const KMMsgBase*, ActionScheduler* filterHandler );
78 /* Caches the serial number for a message, or more correctly for a
79 KMMsgBase based instance representing a message.
80 This property becomes invalid when the message is destructed or
81 assigned a new value */
82 static void setSerialCache( const KMMsgBase*, quint32 );
83 static quint32 serialCache( const KMMsgBase* );
85 /**
86 * Set the transferInProgress for a message.
88 * The number of calls to setTransferInProgress() with transfer = true is counted,
89 * e.g. if you call setTransferInProgress() with transfer = true two times, and
90 * then setTransferInProgress() with transfer = false once, transferInProgres()
91 * will return true. transferInProgress() only returns false after an additional
92 * call to setTransferInProgress() with transfer = false.
94 * This property becomes invalid when the message is destructed or
95 * assigned a new value.
97 static void setTransferInProgress( const KMMsgBase*, bool, bool = false );
98 static bool transferInProgress( const KMMsgBase* );
99 static void setTransferInProgress( quint32, bool, bool = false );
100 static bool transferInProgress( quint32 );
103 * Set this property to true if you want to keep the serial number when moving
104 * a message from a local folder to an online IMAP folder.
105 * Setting this to true will cause the ImapJob to save the meta data, like the
106 * serial number, of the message in a map, which is later read when the
107 * message arrives in the new location. Then the serial number is restored.
109 static void setKeepSerialNumber( quint32 serialNumber, bool keepForMoving );
110 static bool keepSerialNumber( quint32 serialNumber );
112 /** Some properties, namely complete, transferInProgress, and
113 serialCache must be forgotten when a message class instance is
114 destructed or assigned a new value */
115 static void forget( const KMMsgBase* );
117 private:
119 // The folder a message is to be moved into once filtering is finished if any
120 static QMap<quint32, QPointer<KMFolder> > sFolders;
122 // Whether the serial number of a message should be kept when moving it from
123 // a local folder to an online IMAP folder. This is currently only used by
124 // the action scheduler (in ActionScheduler::moveMessage()), to make the IMAP
125 // job aware that it should try to preserve the serial number when moving, see
126 // ImapJob::init().
127 static QMap<quint32, bool> sKeepSerialNumber;
129 // The action scheduler currently processing a message if any
130 static QMap<quint32, QPointer<ActionScheduler> > sHandlers;
132 // The transferInProgres state of a message if any.
133 static QMap<quint32, int > sTransfers;
135 // The cached serial number of a message if any.
136 static QMap<const KMMsgBase*, long> sSerialCache;
141 #endif /*messageproperty_h*/