kmail Library API Documentation

kmmsgbase.h

00001 /* Virtual base class for messages and message infos 00002 * Author: Stefan Taferner <taferner@kde.org> 00003 * This code is under GPL. 00004 */ 00005 #ifndef kmmsgbase_h 00006 #define kmmsgbase_h 00007 00008 // for large file support flags 00009 #include <config.h> 00010 #include <sys/types.h> 00011 #include <qstring.h> 00012 #include <time.h> 00013 00014 class QCString; 00015 class QStringList; 00016 class QTextCodec; 00017 class KMFolder; 00018 class KMFolderIndex; 00019 00021 enum MsgStatus 00022 { 00023 KMMsgStatusUnknown = 0x00000000, 00024 KMMsgStatusNew = 0x00000001, 00025 KMMsgStatusUnread = 0x00000002, 00026 KMMsgStatusRead = 0x00000004, 00027 KMMsgStatusOld = 0x00000008, 00028 KMMsgStatusDeleted = 0x00000010, 00029 KMMsgStatusReplied = 0x00000020, 00030 KMMsgStatusForwarded = 0x00000040, 00031 KMMsgStatusQueued = 0x00000080, 00032 KMMsgStatusSent = 0x00000100, 00033 KMMsgStatusFlag = 0x00000200, // important 00034 KMMsgStatusWatched = 0x00000400, 00035 KMMsgStatusIgnored = 0x00000800, 00036 KMMsgStatusTodo = 0x00001000, 00037 KMMsgStatusSpam = 0x00002000, 00038 KMMsgStatusHam = 0x00004000, 00039 KMMsgStatusHasAttach = 0x00008000, 00040 KMMsgStatusHasNoAttach = 0x00010000 00041 }; 00042 00043 typedef uint KMMsgStatus; 00044 00048 typedef enum 00049 { 00050 KMLegacyMsgStatusUnknown=' ', 00051 KMLegacyMsgStatusNew='N', 00052 KMLegacyMsgStatusUnread='U', 00053 KMLegacyMsgStatusRead='R', 00054 KMLegacyMsgStatusOld='O', 00055 KMLegacyMsgStatusDeleted='D', 00056 KMLegacyMsgStatusReplied='A', 00057 KMLegacyMsgStatusForwarded='F', 00058 KMLegacyMsgStatusQueued='Q', 00059 KMLegacyMsgStatusSent='S', 00060 KMLegacyMsgStatusFlag='G' 00061 } KMLegacyMsgStatus; 00062 00063 00064 00066 typedef enum 00067 { 00068 KMMsgEncryptionStateUnknown=' ', 00069 KMMsgNotEncrypted='N', 00070 KMMsgPartiallyEncrypted='P', 00071 KMMsgFullyEncrypted='F', 00072 KMMsgEncryptionProblematic='X' 00073 } KMMsgEncryptionState; 00074 00076 typedef enum 00077 { 00078 KMMsgSignatureStateUnknown=' ', 00079 KMMsgNotSigned='N', 00080 KMMsgPartiallySigned='P', 00081 KMMsgFullySigned='F', 00082 KMMsgSignatureProblematic='X' 00083 } KMMsgSignatureState; 00084 00086 typedef enum 00087 { 00088 KMMsgMDNStateUnknown = ' ', 00089 KMMsgMDNNone = 'N', 00090 KMMsgMDNIgnore = 'I', 00091 KMMsgMDNDisplayed = 'R', 00092 KMMsgMDNDeleted = 'D', 00093 KMMsgMDNDispatched = 'F', 00094 KMMsgMDNProcessed = 'P', 00095 KMMsgMDNDenied = 'X', 00096 KMMsgMDNFailed = 'E' 00097 } KMMsgMDNSentState; 00098 00100 typedef enum 00101 { 00102 KMMsgDnDActionMOVE=0, 00103 KMMsgDnDActionCOPY=1, 00104 KMMsgDnDActionASK=2 00105 } KMMsgDnDAction; 00106 00108 typedef enum 00109 { 00110 KMMsgHasAttachment, 00111 KMMsgHasNoAttachment, 00112 KMMsgAttachmentUnknown 00113 } KMMsgAttachmentState; 00114 00115 00116 class KMMsgBase 00117 { 00118 public: 00119 KMMsgBase(KMFolder* p=0); 00120 virtual ~KMMsgBase(); 00121 00123 KMFolderIndex* storage() const; 00124 00126 KMFolder* parent() const { return mParent; } 00127 00129 void setParent(KMFolder* p) { mParent = p; } 00130 00132 static QCString statusToStr(const KMMsgStatus status); 00133 00135 QString statusToSortRank(); 00136 00138 virtual bool isMessage(void) const; 00139 00141 virtual bool isUnread(void) const; 00142 00144 virtual bool isNew(void) const; 00145 00147 virtual bool isOfUnknownStatus(void) const; 00148 00150 virtual bool isOld(void) const; 00151 00153 virtual bool isRead(void) const; 00154 00156 virtual bool isDeleted(void) const; 00157 00159 virtual bool isReplied(void) const; 00160 00162 virtual bool isForwarded(void) const; 00163 00165 virtual bool isQueued(void) const; 00166 00168 virtual bool isSent(void) const; 00169 00171 virtual bool isImportant(void) const; 00172 00174 virtual bool isWatched(void) const; 00175 00177 virtual bool isIgnored(void) const; 00178 00180 virtual bool isSpam(void) const; 00181 00183 virtual bool isHam(void) const; 00184 00185 00187 virtual KMMsgStatus status(void) const = 0; 00188 00191 virtual void setStatus(const KMMsgStatus status, int idx = -1); 00192 virtual void toggleStatus(const KMMsgStatus status, int idx = -1); 00193 virtual void setStatus(const char* statusField, const char* xstatusField=0); 00194 00196 virtual KMMsgEncryptionState encryptionState() const = 0; 00197 00199 virtual KMMsgSignatureState signatureState() const = 0; 00200 00202 virtual KMMsgMDNSentState mdnSentState() const = 0; 00203 00205 virtual void setMDNSentState( KMMsgMDNSentState status, int idx=-1 ); 00206 00210 virtual void setEncryptionState(const KMMsgEncryptionState, int idx = -1); 00211 00215 virtual void setSignatureState(const KMMsgSignatureState, int idx = -1); 00216 00220 virtual void setEncryptionStateChar( QChar status, int idx = -1 ); 00221 00225 virtual void setSignatureStateChar( QChar status, int idx = -1 ); 00226 00228 virtual QString subject(void) const = 0; 00229 virtual QString fromStrip(void) const = 0; 00230 virtual QString toStrip(void) const = 0; 00231 virtual QString replyToIdMD5(void) const = 0; 00232 virtual QString msgIdMD5(void) const = 0; 00233 virtual QString replyToAuxIdMD5() const = 0; 00234 virtual QString strippedSubjectMD5() const = 0; 00235 virtual bool subjectIsPrefixed() const = 0; 00236 virtual time_t date(void) const = 0; 00237 virtual QString dateStr(void) const; 00238 virtual QString xmark(void) const = 0; 00239 00241 virtual void setDate(const QCString &aStrDate); 00242 virtual void setDate(time_t aUnixTime) = 0; 00243 00245 virtual bool dirty(void) const { return mDirty; } 00246 00248 void setDirty(bool b) { mDirty = b; } 00249 00251 virtual void setSubject(const QString&) = 0; 00252 virtual void setXMark(const QString&) = 0; 00253 00255 virtual void initStrippedSubjectMD5() = 0; 00256 00258 const uchar *asIndexString(int &len) const; 00259 00261 virtual off_t folderOffset(void) const = 0; 00262 virtual void setFolderOffset(off_t offs) = 0; 00263 00265 virtual QString fileName(void) const = 0; 00266 virtual void setFileName(const QString& filename) = 0; 00267 00269 virtual size_t msgSize(void) const = 0; 00270 virtual void setMsgSize(size_t sz) = 0; 00271 00273 virtual size_t msgSizeServer(void) const = 0; 00274 virtual void setMsgSizeServer(size_t sz) = 0; 00275 00277 virtual ulong UID(void) const = 0; 00278 virtual void setUID(ulong uid) = 0; 00279 00281 virtual void setIndexOffset(off_t off) { mIndexOffset = off; } 00282 virtual off_t indexOffset() const { return mIndexOffset; } 00283 00285 virtual void setIndexLength(short len) { mIndexLength = len; } 00286 virtual short indexLength() const { return mIndexLength; } 00287 00292 static QString skipKeyword(const QString& str, QChar sepChar=':', 00293 bool* keywordFound=0); 00294 00297 static const QTextCodec* codecForName(const QCString& _str); 00298 00302 static QCString toUsAscii(const QString& _str, bool *ok=0); 00303 00305 static QStringList supportedEncodings(bool usAscii); 00306 00308 void assign(const KMMsgBase* other); 00309 00311 KMMsgBase& operator=(const KMMsgBase& other); 00312 00314 KMMsgBase( const KMMsgBase& other ); 00315 00317 static QCString encodeRFC2047Quoted(const QCString& aStr, bool base64); 00318 00321 static QString decodeRFC2047String(const QCString& aStr); 00322 00325 static QCString encodeRFC2047String(const QString& aStr, 00326 const QCString& charset); 00327 00330 static QCString encodeRFC2231String(const QString& aStr, 00331 const QCString& charset); 00332 00334 static QString decodeRFC2231String(const QCString& aStr); 00335 00339 static QString base64EncodedMD5( const QString & aStr, bool utf8=false ); 00340 static QString base64EncodedMD5( const QCString & aStr ); 00341 static QString base64EncodedMD5( const char * aStr, int len=-1 ); 00342 00348 static QCString autoDetectCharset(const QCString &encoding, const QStringList &encodingList, const QString &text); 00349 00351 virtual unsigned long getMsgSerNum() const; 00352 00354 virtual bool enableUndo() { return mEnableUndo; } 00355 virtual void setEnableUndo( bool enable ) { mEnableUndo = enable; } 00356 00359 bool isComplete(); 00361 void setComplete(bool value); 00362 00364 bool readyToShow(); 00366 void setReadyToShow(bool); 00367 00369 bool transferInProgress(); 00371 void setTransferInProgress(bool value, bool force = false); 00372 00374 virtual KMMsgAttachmentState attachmentState() const; 00375 00382 static QString replacePrefixes( const QString& str, 00383 const QStringList& prefixRegExps, 00384 bool replace, 00385 const QString& newPrefix ); 00386 00389 static QString stripOffPrefixes( const QString& str ); 00390 00397 QString cleanSubject(const QStringList& prefixRegExps, bool replace, 00398 const QString& newPrefix) const; 00399 00402 QString cleanSubject() const; 00403 00405 QString forwardSubject() const; 00406 00408 QString replySubject() const; 00409 00412 static void readConfig(); 00413 00414 protected: 00415 KMFolder* mParent; 00416 bool mDirty; 00417 off_t mIndexOffset; 00418 short mIndexLength; 00419 bool mEnableUndo; 00420 mutable KMMsgStatus mStatus; 00421 // This is kept to provide an upgrade path from the the old single status 00422 // to the new multiple status scheme. 00423 mutable KMLegacyMsgStatus mLegacyStatus; 00424 00425 public: 00426 enum MsgPartType 00427 { 00428 MsgNoPart = 0, 00429 //unicode strings 00430 MsgFromPart = 1, 00431 MsgSubjectPart = 2, 00432 MsgToPart = 3, 00433 MsgReplyToIdMD5Part = 4, 00434 MsgIdMD5Part = 5, 00435 MsgXMarkPart = 6, 00436 //unsigned long 00437 MsgOffsetPart = 7, 00438 MsgLegacyStatusPart = 8, 00439 MsgSizePart = 9, 00440 MsgDatePart = 10, 00441 MsgFilePart = 11, 00442 MsgCryptoStatePart = 12, 00443 MsgMDNSentPart = 13, 00444 //another two unicode strings 00445 MsgReplyToAuxIdMD5Part = 14, 00446 MsgStrippedSubjectMD5Part = 15, 00447 // and another unsigned long 00448 MsgStatusPart = 16, 00449 MsgSizeServerPart = 17, 00450 MsgUIDPart = 18 00451 }; 00453 off_t getLongPart(MsgPartType) const; 00455 QString getStringPart(MsgPartType) const; 00457 bool syncIndexString() const; 00458 }; 00459 00460 #endif /*kmmsgbase_h*/
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 Thu Oct 21 19:46:50 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003