kmail Library API Documentation

messageproperty.cpp

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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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 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, bool > MessageProperty::sCompletes; 00041 QMap<Q_UINT32, bool > MessageProperty::sReadyToShows; 00042 QMap<Q_UINT32, int > MessageProperty::sTransfers; 00043 QMap<const KMMsgBase*, long > MessageProperty::sSerialCache; 00044 00045 bool MessageProperty::filtering( Q_UINT32 serNum ) 00046 { 00047 return sFolders.contains( serNum ); 00048 } 00049 00050 void MessageProperty::setFiltering( Q_UINT32 serNum, bool filter ) 00051 { 00052 assert(!filtering(serNum) || !filter); 00053 if (filter && !filtering(serNum)) 00054 sFolders.replace(serNum, QGuardedPtr<KMFolder>(0) ); 00055 else if (!filter) 00056 sFolders.remove(serNum); 00057 } 00058 00059 bool MessageProperty::filtering( const KMMsgBase *msgBase ) 00060 { 00061 return filtering( msgBase->getMsgSerNum() ); 00062 } 00063 00064 void MessageProperty::setFiltering( const KMMsgBase *msgBase, bool filter ) 00065 { 00066 setFiltering( msgBase->getMsgSerNum(), filter ); 00067 } 00068 00069 KMFolder* MessageProperty::filterFolder( Q_UINT32 serNum ) 00070 { 00071 if (sFolders.contains(serNum)) 00072 return sFolders[serNum].operator->(); 00073 return 0; 00074 } 00075 00076 void MessageProperty::setFilterFolder( Q_UINT32 serNum, KMFolder* folder ) 00077 { 00078 sFolders.replace(serNum, QGuardedPtr<KMFolder>(folder) ); 00079 } 00080 00081 KMFolder* MessageProperty::filterFolder( const KMMsgBase *msgBase ) 00082 { 00083 return filterFolder( msgBase->getMsgSerNum() ); 00084 } 00085 00086 void MessageProperty::setFilterFolder( const KMMsgBase *msgBase, KMFolder* folder ) 00087 { 00088 setFilterFolder( msgBase->getMsgSerNum(), folder ); 00089 } 00090 00091 ActionScheduler* MessageProperty::filterHandler( Q_UINT32 serNum ) 00092 { 00093 if ( sHandlers.contains( serNum )) 00094 return sHandlers[serNum].operator->(); 00095 return 0; 00096 } 00097 00098 void MessageProperty::setFilterHandler( Q_UINT32 serNum, ActionScheduler* handler ) 00099 { 00100 if (handler) 00101 sHandlers.replace( serNum, QGuardedPtr<ActionScheduler>(handler) ); 00102 else 00103 sHandlers.remove( serNum ); 00104 } 00105 00106 ActionScheduler* MessageProperty::filterHandler( const KMMsgBase *msgBase ) 00107 { 00108 return filterHandler( msgBase->getMsgSerNum() ); 00109 } 00110 00111 void MessageProperty::setFilterHandler( const KMMsgBase *msgBase, ActionScheduler* handler ) 00112 { 00113 setFilterHandler( msgBase->getMsgSerNum(), handler ); 00114 } 00115 00116 bool MessageProperty::complete( Q_UINT32 serNum ) 00117 { 00118 if (sCompletes.contains( serNum )) 00119 return sCompletes[serNum]; 00120 return false; 00121 } 00122 00123 void MessageProperty::setComplete( Q_UINT32 serNum, bool complete ) 00124 { 00125 if (complete) 00126 sCompletes.replace( serNum, complete ); 00127 else 00128 sCompletes.remove( serNum); 00129 } 00130 00131 bool MessageProperty::complete( const KMMsgBase *msgBase ) 00132 { 00133 return complete( msgBase->getMsgSerNum() ); 00134 } 00135 00136 void MessageProperty::setComplete( const KMMsgBase *msgBase, bool complete ) 00137 { 00138 setComplete( msgBase->getMsgSerNum(), complete ); 00139 } 00140 00141 bool MessageProperty::readyToShow( Q_UINT32 serNum ) 00142 { 00143 if (sReadyToShows.contains( serNum )) 00144 return sReadyToShows[serNum]; 00145 return false; 00146 } 00147 00148 void MessageProperty::setReadyToShow( Q_UINT32 serNum, bool show ) 00149 { 00150 if (show) 00151 sReadyToShows.replace( serNum, show ); 00152 else 00153 sReadyToShows.remove( serNum); 00154 } 00155 00156 bool MessageProperty::readyToShow( const KMMsgBase *msgBase ) 00157 { 00158 return readyToShow( msgBase->getMsgSerNum() ); 00159 } 00160 00161 void MessageProperty::setReadyToShow( const KMMsgBase *msgBase, bool show ) 00162 { 00163 setReadyToShow( msgBase->getMsgSerNum(), show ); 00164 } 00165 00166 bool MessageProperty::transferInProgress( Q_UINT32 serNum ) 00167 { 00168 if (sTransfers.contains(serNum)) 00169 return sTransfers[serNum]; 00170 return false; 00171 } 00172 00173 void MessageProperty::setTransferInProgress( Q_UINT32 serNum, bool transfer, bool force ) 00174 { 00175 int transferInProgress = 0; 00176 if (sTransfers.contains(serNum)) 00177 transferInProgress = sTransfers[serNum]; 00178 if ( force && !transfer ) 00179 transferInProgress = 0; 00180 else 00181 transfer ? ++transferInProgress : --transferInProgress; 00182 if ( transferInProgress < 0 ) 00183 transferInProgress = 0; 00184 if (transferInProgress) 00185 sTransfers.replace( serNum, transferInProgress ); 00186 else 00187 sTransfers.remove( serNum ); 00188 } 00189 00190 bool MessageProperty::transferInProgress( const KMMsgBase *msgBase ) 00191 { 00192 return transferInProgress( msgBase->getMsgSerNum() ); 00193 } 00194 00195 void MessageProperty::setTransferInProgress( const KMMsgBase *msgBase, bool transfer, bool force ) 00196 { 00197 setTransferInProgress( msgBase->getMsgSerNum(), transfer, force ); 00198 } 00199 00200 Q_UINT32 MessageProperty::serialCache( const KMMsgBase *msgBase ) 00201 { 00202 if (sSerialCache.contains( msgBase )) 00203 return sSerialCache[msgBase]; 00204 return 0; 00205 } 00206 00207 void MessageProperty::setSerialCache( const KMMsgBase *msgBase, Q_UINT32 serNum ) 00208 { 00209 if (serNum) 00210 sSerialCache.replace( msgBase, serNum ); 00211 else 00212 sSerialCache.remove( msgBase ); 00213 } 00214 00215 void MessageProperty::forget( const KMMsgBase *msgBase ) 00216 { 00217 Q_UINT32 serNum = serialCache( msgBase ); 00218 if (serNum) { 00219 Q_ASSERT( !transferInProgress( serNum ) ); 00220 sCompletes.remove( serNum ); 00221 sTransfers.remove( serNum ); 00222 sReadyToShows.remove( serNum ); 00223 sSerialCache.remove( msgBase ); 00224 } 00225 } 00226 00227 #include "messageproperty.moc"
KDE Logo
This file is part of the documentation for kmail Library Version 3.3.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Fri Aug 27 12:52:51 2004 by doxygen 1.3.8 written by Dimitri van Heesch, © 1997-2003