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

kmail

partNode.h

Go to the documentation of this file.
00001 /* -*- c++ -*-
00002     partNode.h A node in a MIME tree.
00003 
00004     This file is part of KMail, the KDE mail client.
00005     Copyright (c) 2002,2004 Klarälvdalens Datakonsult AB
00006 
00007     KMail is free software; you can redistribute it and/or modify it
00008     under the terms of the GNU General Public License, version 2, as
00009     published by the Free Software Foundation.
00010 
00011     KMail is distributed in the hope that it will be useful, but
00012     WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014     General Public License for more details.
00015 
00016     You should have received a copy of the GNU General Public License
00017     along with this program; if not, write to the Free Software
00018     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00019 
00020     In addition, as a special exception, the copyright holders give
00021     permission to link the code of this program with any edition of
00022     the Qt library by Trolltech AS, Norway (or with modified versions
00023     of Qt that use the same license as Qt), and distribute linked
00024     combinations including the two.  You must obey the GNU General
00025     Public License in all respects for all of the code used other than
00026     Qt.  If you modify this file, you may extend this exception to
00027     your version of the file, but you are not obligated to do so.  If
00028     you do not wish to do so, delete this exception statement from
00029     your version.
00030 */
00031 
00032 #ifndef PARTNODE_H
00033 #define PARTNODE_H
00034 
00035 #include "kmmsgpart.h"
00036 #include "kmmsgbase.h"
00037 #include "kmmessage.h"
00038 
00039 #include "interfaces/bodypart.h"
00040 
00041 #include <mimelib/mimepp.h>
00042 #include <mimelib/body.h>
00043 #include <mimelib/utility.h>
00044 
00045 #include <kio/global.h>
00046 #include <kdebug.h>
00047 #include <QByteArray>
00048 
00049 class KMMimePartTreeItem;
00050 class KMMimePartTree;
00051 
00052 /*
00053  ===========================================================================
00054 
00055 
00056        S T A R T    O F     T E M P O R A R Y     M I M E     C O D E
00057 
00058 
00059  ===========================================================================
00060   N O T E :   The partNode structure will most likely be replaced by KMime.
00061               It's purpose: Speed optimization for KDE 3.   (khz, 28.11.01)
00062  ===========================================================================
00063 */
00064 class partNode
00065 {
00066     partNode();
00067 
00068     int calcNodeIdOrFindNode( int& curId, const partNode* calcNode,
00069                               int findId, partNode** findNode );
00070 
00071 public:
00072     static partNode * fromMessage( const KMMessage * msg );
00073 
00074     explicit partNode( DwBodyPart* dwPart,
00075                int explicitType    = DwMime::kTypeUnknown,
00076                int explicitSubType = DwMime::kSubtypeUnknown,
00077                bool deleteDwBodyPart = false );
00078 
00079     partNode( bool deleteDwBodyPart,
00080               DwBodyPart* dwPart );
00081 
00082     ~partNode();
00083 
00084     void dump( int chars=0 ) const;
00085 
00086     void buildObjectTree( bool processSiblings=true );
00087 
00088     DwBodyPart* dwPart() const {
00089         return mDwPart;
00090     }
00091 
00092     void setDwPart( DwBodyPart* part ) {
00093         mDwPart = part;
00094         mMsgPartOk = false;
00095     }
00096 
00097     KMMessagePart& msgPart() const {
00098         if( !mMsgPartOk ) {
00099             KMMessage::bodyPart(mDwPart, &mMsgPart);
00100             mMsgPartOk = true;
00101         }
00102         return mMsgPart;
00103     }
00104 
00105     const QByteArray & encodedBody();
00106 
00107     void setType( int type ) {
00108         mType = type;
00109     }
00110 
00111     void setSubType( int subType ) {
00112         mSubType = subType;
00113     }
00114 
00115     int type() const {
00116         return mType;
00117     }
00118 
00119     QByteArray typeString() const;
00120 
00121     int subType() const {
00122         return mSubType;
00123     }
00124 
00125     QByteArray subTypeString() const;
00126 
00127     bool hasType( int type ) {
00128       return mType == type;
00129     }
00130 
00131     bool hasSubType( int subType ) {
00132       return mSubType == subType;
00133     }
00134 
00135     void setEncryptionState( KMMsgEncryptionState state ) {
00136         mEncryptionState = state;
00137     }
00138     KMMsgEncryptionState encryptionState() const {
00139         return mEncryptionState;
00140     }
00141 
00142     // look at the encryption states of all children and return result
00143     KMMsgEncryptionState overallEncryptionState() const ;
00144 
00145     // look at the signature states of all children and return result
00146     KMMsgSignatureState  overallSignatureState() const ;
00147 
00148     void setSignatureState( KMMsgSignatureState state ) {
00149         mSignatureState = state;
00150     }
00151     KMMsgSignatureState signatureState() const {
00152         return mSignatureState;
00153     }
00154 
00155     int nodeId() const;  // node ids start at 1 (this is the top level root node)
00156 
00157     partNode* findId( int id );  // returns the node which has the given id (or 0, resp.)
00158 
00159     partNode* findType( int type, int subType, bool deep=true, bool wide=true );
00160 
00161     partNode* findTypeNot( int type, int subType, bool deep=true,
00162                            bool wide=true );
00163 
00164     partNode* findNodeForDwPart( DwBodyPart* part );
00165 
00166     void fillMimePartTree( KMMimePartTreeItem* parentItem,
00167                            KMMimePartTree*     mimePartTree,
00168                            const QString &labelDescr    = QString(),
00169                            const QString &labelCntType  = QString(),
00170                            const QString &labelEncoding = QString(),
00171                            KIO::filesize_t size=0,
00172                            bool revertOrder = false );
00173 
00174     void adjustDefaultType( partNode* node );
00175 
00176     void setNext( partNode* next ) {
00177         mNext = next;
00178         if( mNext ){
00179             mNext->mRoot = mRoot;
00180             adjustDefaultType( mNext );
00181         }
00182     }
00183 
00184     void setFirstChild( partNode* child ) {
00185         mChild = child;
00186         if( mChild ) {
00187             mChild->mRoot = this;
00188             adjustDefaultType( mChild );
00189         }
00190     }
00191 
00192     void setProcessed( bool processed, bool recurse ) {
00193         mWasProcessed = processed;
00194     if ( recurse ) {
00195       if( mChild )
00196             mChild->setProcessed( processed, true );
00197       if( mNext )
00198             mNext->setProcessed( processed, true );
00199     }
00200     }
00201 
00202     void setMimePartTreeItem( KMMimePartTreeItem* item ) {
00203         mMimePartTreeItem = item;
00204     }
00205 
00206     KMMimePartTreeItem* mimePartTreeItem() {
00207         return mMimePartTreeItem;
00208     }
00209 
00210     void setFromAddress( const QString& address ) {
00211         mFromAddress = address;
00212     }
00213 
00214     bool isAttachment() const;
00215     bool isHeuristicalAttachment() const;
00219     bool isFirstTextPart() const;
00220 
00221     bool hasContentDispositionInline() const;
00222 
00223     QString contentTypeParameter( const char * name ) const;
00224 
00225     const QString& trueFromAddress() const;
00226 
00227     partNode * parentNode() const { return mRoot; }
00228     partNode * nextSibling() const { return mNext; }
00229     partNode * firstChild() const { return mChild; }
00230     partNode * next( bool allowChildren=true ) const;
00231     int childCount() const;
00232     bool processed() const { return mWasProcessed; }
00233 
00234     KMail::Interface::BodyPartMemento * bodyPartMemento() const { return mBodyPartMemento; }
00235     void setBodyPartMemento( KMail::Interface::BodyPartMemento * memento ) {
00236         mBodyPartMemento = memento;
00237     }
00238 
00239 private:
00240     partNode*     mRoot;
00241     partNode*     mNext;
00242     partNode*     mChild;
00243     bool          mWasProcessed; // to be used by parseObjectTree()
00244 private:
00245     DwBodyPart*   mDwPart;   // may be zero
00246     mutable KMMessagePart mMsgPart;  // is valid - even if mDwPart is zero
00247     QByteArray    mEncodedBody;
00248     QString       mFromAddress;
00249     int           mType;
00250     int           mSubType;
00251     KMMsgEncryptionState mEncryptionState;
00252     KMMsgSignatureState  mSignatureState;
00253     mutable bool  mMsgPartOk;
00254     bool          mEncodedOk;
00255     bool          mDeleteDwBodyPart;
00256     KMMimePartTreeItem* mMimePartTreeItem;
00257     KMail::Interface::BodyPartMemento * mBodyPartMemento;
00258 };
00259 
00260 #endif

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