kmail

messageproperty.h

Go to the documentation of this file.
00001 /*  Message Property
00002 
00003     This file is part of KMail, the KDE mail client.
00004     Copyright (c) Don Sanders <sanders@kde.org>
00005 
00006     KMail is free software; you can redistribute it and/or modify it
00007     under the terms of the GNU General Public License, version 2, as
00008     published by the Free Software Foundation.
00009 
00010     KMail is distributed in the hope that it will be useful, but
00011     WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013     General Public License for more details.
00014 
00015     You should have received a copy of the GNU General Public License
00016     along with this program; if not, write to the Free Software
00017     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00018 
00019     In addition, as a special exception, the copyright holders give
00020     permission to link the code of this program with any edition of
00021     the Qt library by Trolltech AS, Norway (or with modified versions
00022     of Qt that use the same license as Qt), and distribute linked
00023     combinations including the two.  You must obey the GNU General
00024     Public License in all respects for all of the code used other than
00025     Qt.  If you modify this file, you may extend this exception to
00026     your version of the file, but you are not obligated to do so.  If
00027     you do not wish to do so, delete this exception statement from
00028     your version.
00029 */
00030 #ifndef messageproperty_h
00031 #define messageproperty_h
00032 
00033 #include "kmfilteraction.h" // for KMFilterAction::ReturnCode
00034 #include "kmfolder.h"
00035 
00036 #include <qptrlist.h>
00037 #include <qguardedptr.h>
00038 #include <qobject.h>
00039 
00040 class KMFilter;
00041 class KMFilterDlg;
00042 
00043 namespace KMail {
00044 
00045 class ActionScheduler;
00046 
00047 /* A place to store properties that some but not necessarily all messages
00048    have.
00049 
00050    These properties do not need to be stored persistantly on disk but
00051    rather only are required while KMail is running.
00052 
00053    Furthermore some properties, namely complete, transferInProgress, and
00054    serialCache should only exist during the lifetime of a particular
00055    KMMsgBase based instance.
00056  */
00057 class MessageProperty : public QObject
00058 {
00059   Q_OBJECT
00060 
00061 public:
00063   static bool filtering( Q_UINT32 );
00064   static void setFiltering( Q_UINT32, bool filtering );
00065   static bool filtering( const KMMsgBase* );
00066   static void setFiltering( const KMMsgBase*, bool filtering );
00070   static KMFolder* filterFolder( Q_UINT32 );
00071   static void setFilterFolder( Q_UINT32, KMFolder* folder );
00072   static KMFolder* filterFolder( const KMMsgBase* );
00073   static void setFilterFolder( const KMMsgBase*, KMFolder* folder );
00074   /* Set the filterHandler for a message */
00075   static ActionScheduler* filterHandler( Q_UINT32 );
00076   static void setFilterHandler( Q_UINT32, ActionScheduler* filterHandler );
00077   static ActionScheduler* filterHandler( const KMMsgBase* );
00078   static void setFilterHandler( const KMMsgBase*, ActionScheduler* filterHandler );
00079 
00080   /* Caches the serial number for a message, or more correctly for a
00081      KMMsgBase based instance representing a message.
00082      This property becomes invalid when the message is destructed or
00083      assigned a new value */
00084   static void setSerialCache( const KMMsgBase*, Q_UINT32 );
00085   static Q_UINT32 serialCache( const KMMsgBase* );
00086 
00087   /* Set the transferInProgress for a message
00088      This property becomes invalid when the message is destructed or
00089      assigned a new value */
00090   static void setTransferInProgress( const KMMsgBase*, bool, bool = false );
00091   static bool transferInProgress( const KMMsgBase* );
00092   static void setTransferInProgress( Q_UINT32, bool, bool = false );
00093   static bool transferInProgress( Q_UINT32 );
00097   static void forget( const KMMsgBase* );
00098 
00099 private:
00100   // The folder a message is to be moved into once filtering is finished if any
00101   static QMap<Q_UINT32, QGuardedPtr<KMFolder> > sFolders;
00102   // The action scheduler currently processing a message if any
00103   static QMap<Q_UINT32, QGuardedPtr<ActionScheduler> > sHandlers;
00104   // The transferInProgres state of a message if any.
00105   static QMap<Q_UINT32, int > sTransfers;
00106   // The cached serial number of a message if any.
00107   static QMap<const KMMsgBase*, long > sSerialCache;
00108 };
00109 
00110 }
00111 
00112 #endif /*messageproperty_h*/