kmail
messageproperty.cppGo to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #ifdef HAVE_CONFIG_H
00032 #include <config.h>
00033 #endif
00034
00035 #include "messageproperty.h"
00036 using namespace KMail;
00037
00038 QMap<Q_UINT32, QGuardedPtr<KMFolder> > MessageProperty::sFolders;
00039 QMap<Q_UINT32, QGuardedPtr<ActionScheduler> > MessageProperty::sHandlers;
00040 QMap<Q_UINT32, int > MessageProperty::sTransfers;
00041 QMap<const KMMsgBase*, long > MessageProperty::sSerialCache;
00042
00043 bool MessageProperty::filtering( Q_UINT32 serNum )
00044 {
00045 return sFolders.contains( serNum );
00046 }
00047
00048 void MessageProperty::setFiltering( Q_UINT32 serNum, bool filter )
00049 {
00050 assert(!filtering(serNum) || !filter);
00051 if (filter && !filtering(serNum))
00052 sFolders.replace(serNum, QGuardedPtr<KMFolder>(0) );
00053 else if (!filter)
00054 sFolders.remove(serNum);
00055 }
00056
00057 bool MessageProperty::filtering( const KMMsgBase *msgBase )
00058 {
00059 return filtering( msgBase->getMsgSerNum() );
00060 }
00061
00062 void MessageProperty::setFiltering( const KMMsgBase *msgBase, bool filter )
00063 {
00064 setFiltering( msgBase->getMsgSerNum(), filter );
00065 }
00066
00067 KMFolder* MessageProperty::filterFolder( Q_UINT32 serNum )
00068 {
00069 if (sFolders.contains(serNum))
00070 return sFolders[serNum].operator->();
00071 return 0;
00072 }
00073
00074 void MessageProperty::setFilterFolder( Q_UINT32 serNum, KMFolder* folder )
00075 {
00076 sFolders.replace(serNum, QGuardedPtr<KMFolder>(folder) );
00077 }
00078
00079 KMFolder* MessageProperty::filterFolder( const KMMsgBase *msgBase )
00080 {
00081 return filterFolder( msgBase->getMsgSerNum() );
00082 }
00083
00084 void MessageProperty::setFilterFolder( const KMMsgBase *msgBase, KMFolder* folder )
00085 {
00086 setFilterFolder( msgBase->getMsgSerNum(), folder );
00087 }
00088
00089 ActionScheduler* MessageProperty::filterHandler( Q_UINT32 serNum )
00090 {
00091 if ( sHandlers.contains( serNum ))
00092 return sHandlers[serNum].operator->();
00093 return 0;
00094 }
00095
00096 void MessageProperty::setFilterHandler( Q_UINT32 serNum, ActionScheduler* handler )
00097 {
00098 if (handler)
00099 sHandlers.replace( serNum, QGuardedPtr<ActionScheduler>(handler) );
00100 else
00101 sHandlers.remove( serNum );
00102 }
00103
00104 ActionScheduler* MessageProperty::filterHandler( const KMMsgBase *msgBase )
00105 {
00106 return filterHandler( msgBase->getMsgSerNum() );
00107 }
00108
00109 void MessageProperty::setFilterHandler( const KMMsgBase *msgBase, ActionScheduler* handler )
00110 {
00111 setFilterHandler( msgBase->getMsgSerNum(), handler );
00112 }
00113
00114 bool MessageProperty::transferInProgress( Q_UINT32 serNum )
00115 {
00116 if (sTransfers.contains(serNum))
00117 return sTransfers[serNum];
00118 return false;
00119 }
00120
00121 void MessageProperty::setTransferInProgress( Q_UINT32 serNum, bool transfer, bool force )
00122 {
00123 int transferInProgress = 0;
00124 if (sTransfers.contains(serNum))
00125 transferInProgress = sTransfers[serNum];
00126 if ( force && !transfer )
00127 transferInProgress = 0;
00128 else
00129 transfer ? ++transferInProgress : --transferInProgress;
00130 if ( transferInProgress < 0 )
00131 transferInProgress = 0;
00132 if (transferInProgress)
00133 sTransfers.replace( serNum, transferInProgress );
00134 else
00135 sTransfers.remove( serNum );
00136 }
00137
00138 bool MessageProperty::transferInProgress( const KMMsgBase *msgBase )
00139 {
00140 return transferInProgress( msgBase->getMsgSerNum() );
00141 }
00142
00143 void MessageProperty::setTransferInProgress( const KMMsgBase *msgBase, bool transfer, bool force )
00144 {
00145 setTransferInProgress( msgBase->getMsgSerNum(), transfer, force );
00146 }
00147
00148 Q_UINT32 MessageProperty::serialCache( const KMMsgBase *msgBase )
00149 {
00150 if (sSerialCache.contains( msgBase ))
00151 return sSerialCache[msgBase];
00152 return 0;
00153 }
00154
00155 void MessageProperty::setSerialCache( const KMMsgBase *msgBase, Q_UINT32 serNum )
00156 {
00157 if (serNum)
00158 sSerialCache.replace( msgBase, serNum );
00159 else
00160 sSerialCache.remove( msgBase );
00161 }
00162
00163 void MessageProperty::forget( const KMMsgBase *msgBase )
00164 {
00165 Q_UINT32 serNum = serialCache( msgBase );
00166 if (serNum) {
00167 Q_ASSERT( !transferInProgress( serNum ) );
00168 sTransfers.remove( serNum );
00169 sSerialCache.remove( msgBase );
00170 }
00171 }
00172
00173 #include "messageproperty.moc"
|