• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • kdepim
  • Sitemap
  • Contact Us
 

kmail

kmmsgbase.h

Go to the documentation of this file.
00001 /*
00002  * kmail: KDE mail client
00003  * Copyright (c) 1996-1998 Stefan Taferner <taferner@kde.org>
00004  *
00005  * This program is free software; you can redistribute it and/or modify
00006  * it under the terms of the GNU General Public License as published by
00007  * the Free Software Foundation; either version 2 of the License, or
00008  * (at your option) any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU 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  */
00020 #ifndef kmmsgbase_h
00021 #define kmmsgbase_h
00022 
00023 #include "messagestatus.h"
00024 using KPIM::MessageStatus;
00025 
00026 // for large file support flags
00027 #include <sys/types.h>
00028 #include <QString>
00029 #include <time.h>
00030 
00031 #ifdef KMAIL_SQLITE_INDEX
00032 #include <sqlite3.h>
00033 #endif
00034 
00035 class QByteArray;
00036 class QStringList;
00037 class QTextCodec;
00038 class KMFolder;
00039 class KMFolderIndex;
00040 class KMMessageTagList;
00041 
00043 typedef enum
00044 {
00045     KMMsgEncryptionStateUnknown=' ',
00046     KMMsgNotEncrypted='N',
00047     KMMsgPartiallyEncrypted='P',
00048     KMMsgFullyEncrypted='F',
00049     KMMsgEncryptionProblematic='X'
00050 } KMMsgEncryptionState;
00051 
00053 typedef enum
00054 {
00055     KMMsgSignatureStateUnknown=' ',
00056     KMMsgNotSigned='N',
00057     KMMsgPartiallySigned='P',
00058     KMMsgFullySigned='F',
00059     KMMsgSignatureProblematic='X'
00060 } KMMsgSignatureState;
00061 
00063 typedef enum
00064 {
00065     KMMsgMDNStateUnknown = ' ',
00066     KMMsgMDNNone = 'N',
00067     KMMsgMDNIgnore = 'I',
00068     KMMsgMDNDisplayed = 'R',
00069     KMMsgMDNDeleted = 'D',
00070     KMMsgMDNDispatched = 'F',
00071     KMMsgMDNProcessed = 'P',
00072     KMMsgMDNDenied = 'X',
00073     KMMsgMDNFailed = 'E'
00074 } KMMsgMDNSentState;
00075 
00077 typedef enum
00078 {
00079     KMMsgDnDActionMOVE=0,
00080     KMMsgDnDActionCOPY=1,
00081     KMMsgDnDActionASK=2
00082 } KMMsgDnDAction;
00083 
00085 typedef enum
00086 {
00087   KMMsgHasAttachment,
00088   KMMsgHasNoAttachment,
00089   KMMsgAttachmentUnknown
00090 } KMMsgAttachmentState;
00091 
00092 
00093 class KMMsgBase
00094 {
00095 public:
00096   KMMsgBase(KMFolder* p=0);
00097 
00098 #ifdef KMAIL_SQLITE_INDEX
00099   KMMsgBase(KMFolder* aParentFolder, char* data, short len, sqlite_int64 id);
00100 #else
00101   KMMsgBase(KMFolder* aParentFolder, off_t off, short len);
00102 #endif
00103 
00104   virtual ~KMMsgBase();
00105 
00107   KMFolderIndex* storage() const;
00108 
00110   KMFolder* parent() const { return mParent; }
00111 
00113   void setParent(KMFolder* p) { mParent = p; }
00114 
00116   virtual bool isMessage(void) const;
00117 
00119   virtual MessageStatus& status() const;
00120 
00122   const MessageStatus& messageStatus() const;
00123 
00125   virtual QString tagString( void ) const = 0;
00127   virtual KMMessageTagList *tagList( void ) const = 0;
00130   virtual void setTagList( const QString &aString );
00132   virtual void setTagList( const KMMessageTagList &aTagList );
00133 
00136   virtual void setStatus(const MessageStatus& status, int idx = -1);
00137   virtual void toggleStatus(const MessageStatus& status, int idx = -1);
00138   virtual void setStatus(const char* statusField, const char* xstatusField=0);
00139 
00141   virtual KMMsgEncryptionState encryptionState() const = 0;
00142 
00144   virtual KMMsgSignatureState signatureState() const = 0;
00145 
00147   virtual KMMsgMDNSentState mdnSentState() const = 0;
00148 
00150   virtual void setMDNSentState( KMMsgMDNSentState status, int idx=-1 );
00151 
00155   virtual void setEncryptionState(const KMMsgEncryptionState, int idx = -1);
00156 
00160   virtual void setSignatureState(const KMMsgSignatureState, int idx = -1);
00161 
00165   virtual void setEncryptionStateChar( QChar status, int idx = -1 );
00166 
00170   virtual void setSignatureStateChar( QChar status, int idx = -1 );
00171 
00173   virtual QString subject(void) const = 0;
00174   virtual QString fromStrip(void) const = 0;
00175   virtual QString toStrip(void) const = 0;
00176   virtual QString replyToIdMD5(void) const = 0;
00177   virtual QString msgIdMD5(void) const = 0;
00178   virtual QString replyToAuxIdMD5() const = 0;
00179   virtual QString strippedSubjectMD5() const = 0;
00180   virtual bool subjectIsPrefixed() const = 0;
00181   virtual time_t date(void) const = 0;
00182   virtual QString dateStr(void) const;
00183   virtual QString xmark(void) const = 0;
00184 
00186   virtual void setDate(const QByteArray &aStrDate);
00187   virtual void setDate(time_t aUnixTime) = 0;
00188 
00190   virtual bool dirty(void) const { return mDirty; }
00191 
00193   void setDirty(bool b) { mDirty = b; }
00194 
00196   virtual void setSubject(const QString&) = 0;
00197   virtual void setXMark(const QString&) = 0;
00198 
00200   virtual void initStrippedSubjectMD5() = 0;
00201 
00203   const uchar *asIndexString(int &len) const;
00204 
00206   virtual off_t folderOffset(void) const = 0;
00207   virtual void setFolderOffset(off_t offs) = 0;
00208 
00210   virtual QString fileName(void) const = 0;
00211   virtual void setFileName(const QString& filename) = 0;
00212 
00214   virtual size_t msgSize(void) const = 0;
00215   virtual void setMsgSize(size_t sz) = 0;
00216 
00218   virtual size_t msgSizeServer(void) const = 0;
00219   virtual void setMsgSizeServer(size_t sz) = 0;
00220 
00222   virtual ulong UID(void) const = 0;
00223   virtual void setUID(ulong uid) = 0;
00224 
00225 
00226 #ifdef KMAIL_SQLITE_INDEX
00227 
00228   virtual void setData(char* data) { mData = data; }
00229   virtual const char* data() const { return mData; }
00231   virtual void setDbId(sqlite_int64 dbId) { mDbId = dbId; }
00232   virtual sqlite_int64 dbId() const { return mDbId; }
00233 #else
00234 
00235   virtual void setIndexOffset(off_t off) { mIndexOffset = off; }
00236   virtual off_t indexOffset() const { return mIndexOffset; }
00237 #endif
00238 
00240   virtual void setIndexLength(short len) { mIndexLength = len; }
00241   virtual short indexLength() const { return mIndexLength; }
00242 
00247   static QString skipKeyword(const QString& str, QChar sepChar=':',
00248                  bool* keywordFound=0);
00249 
00252   static const QTextCodec* codecForName(const QByteArray& _str);
00253 
00257   static QByteArray toUsAscii(const QString& _str, bool *ok=0);
00258 
00260   static QStringList supportedEncodings(bool usAscii);
00261 
00268   static QString encodingForName( const QString &descriptiveName );
00269 
00271   void assign(const KMMsgBase* other);
00272 
00274   KMMsgBase& operator=(const KMMsgBase& other);
00275 
00277   KMMsgBase( const KMMsgBase &other );
00278 
00280   static QByteArray encodeRFC2047Quoted( const QByteArray &aStr, bool base64 );
00281 
00284   static QString decodeRFC2047String( const QByteArray &aStr,
00285                                       const QByteArray &prefCharset = "" );
00286 
00289   static QByteArray encodeRFC2047String( const QString &aStr,
00290                                          const QByteArray &charset );
00291 
00294   static QByteArray encodeRFC2231String( const QString &aStr,
00295                                          const QByteArray &charset );
00296 
00298   static QString decodeRFC2231String( const QByteArray &aStr );
00299 
00306   static QByteArray extractRFC2231HeaderField( const QByteArray &aStr,
00307                                                const QByteArray &field );
00308 
00309 
00313   static QString base64EncodedMD5( const QString & aStr, bool utf8=false );
00314   static QString base64EncodedMD5( const QByteArray & aStr );
00315   static QString base64EncodedMD5( const char * aStr, int len=-1 );
00316 
00322   static QByteArray autoDetectCharset(const QByteArray &encoding, const QStringList &encodingList, const QString &text);
00323 
00325   virtual unsigned long getMsgSerNum() const;
00326 
00328   virtual bool enableUndo() { return mEnableUndo; }
00329   virtual void setEnableUndo( bool enable ) { mEnableUndo = enable; }
00330 
00332   virtual KMMsgAttachmentState attachmentState() const;
00333 
00340   static QString replacePrefixes( const QString& str,
00341                                   const QStringList& prefixRegExps,
00342                                   bool replace,
00343                                   const QString& newPrefix );
00344 
00347   static QString stripOffPrefixes( const QString& str );
00348 
00355   QString cleanSubject( const QStringList& prefixRegExps, bool replace,
00356                         const QString& newPrefix ) const;
00357 
00360   QString cleanSubject() const;
00361 
00363   QString forwardSubject() const;
00364 
00366   QString replySubject() const;
00367 
00370   static void readConfig();
00371 
00372 protected:
00373   KMFolder* mParent;
00374 #ifdef KMAIL_SQLITE_INDEX
00375   char* mData;
00376   sqlite_int64 mDbId; 
00377 #else
00378   off_t mIndexOffset;
00379 #endif
00380   short mIndexLength;
00381   bool mDirty;
00382   bool mEnableUndo;
00383   mutable MessageStatus mStatus;
00384   mutable KMMessageTagList *mTagList;
00385 
00386 public:
00387   enum MsgPartType
00388   {
00389     MsgNoPart = 0,
00390     //unicode strings
00391     MsgFromPart = 1,
00392     MsgSubjectPart = 2,
00393     MsgToPart = 3,
00394     MsgReplyToIdMD5Part = 4,
00395     MsgIdMD5Part = 5,
00396     MsgXMarkPart = 6,
00397     //unsigned long
00398     MsgOffsetPart = 7,
00399     MsgLegacyStatusPart = 8,
00400     MsgSizePart = 9,
00401     MsgDatePart = 10,
00402     MsgFilePart = 11,
00403     MsgCryptoStatePart = 12,
00404     MsgMDNSentPart = 13,
00405     //another two unicode strings
00406     MsgReplyToAuxIdMD5Part = 14,
00407     MsgStrippedSubjectMD5Part = 15,
00408     // and another unsigned long
00409     MsgStatusPart = 16,
00410     MsgSizeServerPart = 17,
00411     MsgUIDPart = 18,
00412     // unicode string
00413     MsgTagPart = 19
00414   };
00416   off_t getLongPart(MsgPartType) const;
00418   QString getStringPart(MsgPartType) const;
00419 #ifndef KMAIL_SQLITE_INDEX
00420 
00421   bool syncIndexString() const;
00422 #endif
00423 };
00424 
00425 #endif /*kmmsgbase_h*/

kmail

Skip menu "kmail"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdepim

Skip menu "kdepim"
  • akonadi
  •   clients
  •   kabc
  •   kcal
  •   kcm
  • akregator
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt
  • kdgantt1
  • kjots
  • kleopatra
  • kmail
  • kmobiletools
  • knode
  • knotes
  • kontact
  • kontactinterfaces
  • korganizer
  •   korgac
  • kpilot
  • ktimetracker
  • libkdepim
  • libkholidays
  • libkleo
  • libkpgp
  • maildir
Generated for kdepim by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal