kmail

messageproperty.h

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 TQt library by Trolltech AS, Norway (or with modified versions
00022     of TQt that use the same license as TQt), 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     TQt.  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 <tqptrlist.h>
00037 #include <tqguardedptr.h>
00038 #include <tqobject.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 TQObject
00058 {
00059   Q_OBJECT
00060   
00061 
00062 public:
00064   static bool filtering( TQ_UINT32 );
00065   static void setFiltering( TQ_UINT32, bool filtering );
00066   static bool filtering( const KMMsgBase* );
00067   static void setFiltering( const KMMsgBase*, bool filtering );
00071   static KMFolder* filterFolder( TQ_UINT32 );
00072   static void setFilterFolder( TQ_UINT32, KMFolder* folder );
00073   static KMFolder* filterFolder( const KMMsgBase* );
00074   static void setFilterFolder( const KMMsgBase*, KMFolder* folder );
00075   /* Set the filterHandler for a message */
00076   static ActionScheduler* filterHandler( TQ_UINT32 );
00077   static void setFilterHandler( TQ_UINT32, ActionScheduler* filterHandler );
00078   static ActionScheduler* filterHandler( const KMMsgBase* );
00079   static void setFilterHandler( const KMMsgBase*, ActionScheduler* filterHandler );
00080 
00081   /* Caches the serial number for a message, or more correctly for a
00082      KMMsgBase based instance representing a message.
00083      This property becomes invalid when the message is destructed or
00084      assigned a new value */
00085   static void setSerialCache( const KMMsgBase*, TQ_UINT32 );
00086   static TQ_UINT32 serialCache( const KMMsgBase* );
00087 
00088   /* Set the transferInProgress for a message
00089      This property becomes invalid when the message is destructed or
00090      assigned a new value */
00091   static void setTransferInProgress( const KMMsgBase*, bool, bool = false );
00092   static bool transferInProgress( const KMMsgBase* );
00093   static void setTransferInProgress( TQ_UINT32, bool, bool = false );
00094   static bool transferInProgress( TQ_UINT32 );
00095 
00099   static void forget( const KMMsgBase* );
00100 
00101 private:
00102   // The folder a message is to be moved into once filtering is finished if any
00103   static TQMap<TQ_UINT32, TQGuardedPtr<KMFolder> > sFolders;
00104 
00105   // The action scheduler currently processing a message if any
00106   static TQMap<TQ_UINT32, TQGuardedPtr<ActionScheduler> > sHandlers;
00107 
00108   // The transferInProgres state of a message if any.
00109   static TQMap<TQ_UINT32, int > sTransfers;
00110 
00111   // The cached serial number of a message if any.
00112   static TQMap<const KMMsgBase*, long > sSerialCache;
00113 };
00114 
00115 }
00116 
00117 #endif /*messageproperty_h*/