• Skip to content
  • Skip to link menu
KDE 4.1 API Reference
  • KDE API Reference
  • KDE-PIM Libraries
  • Sitemap
  • Contact Us
 

KMIME Library

kmime_content.h

Go to the documentation of this file.
00001 /*
00002     kmime_content.h
00003 
00004     KMime, the KDE internet mail/usenet news message library.
00005     Copyright (c) 2001 the KMime authors.
00006     See file AUTHORS for details
00007     Copyright (c) 2006 Volker Krause <vkrause@kde.org>
00008 
00009     This library is free software; you can redistribute it and/or
00010     modify it under the terms of the GNU Library General Public
00011     License as published by the Free Software Foundation; either
00012     version 2 of the License, or (at your option) any later version.
00013 
00014     This library is distributed in the hope that it will be useful,
00015     but WITHOUT ANY WARRANTY; without even the implied warranty of
00016     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017     Library General Public License for more details.
00018 
00019     You should have received a copy of the GNU Library General Public License
00020     along with this library; see the file COPYING.LIB.  If not, write to
00021     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00022     Boston, MA 02110-1301, USA.
00023 */
00045 #ifndef __KMIME_CONTENT_H__
00046 #define __KMIME_CONTENT_H__
00047 
00048 #include <QtCore/QTextStream>
00049 #include <QtCore/QByteArray>
00050 #include <QtCore/QList>
00051 
00052 #include "kmime_export.h"
00053 #include "kmime_contentindex.h"
00054 #include "kmime_util.h"
00055 #include "kmime_headers.h"
00056 
00057 namespace KMime {
00058 
00059 class ContentPrivate;
00060 
00068 class KMIME_EXPORT Content
00069 {
00070   public:
00071 
00072     typedef QList<KMime::Content*> List;
00073 
00077     Content();
00078 
00085     Content( const QByteArray &head, const QByteArray &body );
00086 
00090     virtual ~Content();
00091 
00095     bool hasContent() const;
00096 
00103     void setContent( const QList<QByteArray> &l );
00104 
00111     void setContent( const QByteArray &s );
00112 
00116     virtual void parse();
00117 
00121     virtual void assemble();
00122 
00126     virtual void clear();
00127 
00133     QByteArray head() const;
00134 
00142     void setHead( const QByteArray &head );
00143 
00150     Headers::Generic *getNextHeader( QByteArray &head );
00151 
00152     virtual Headers::Base *getHeaderByType( const char *type );
00153 
00154     virtual void setHeader( Headers::Base *h );
00155 
00156     virtual bool removeHeader( const char *type );
00157 
00158     bool hasHeader( const char *type );
00159 
00165     Headers::ContentType *contentType( bool create=true );
00166 
00172     Headers::ContentTransferEncoding *contentTransferEncoding( bool create=true );
00173 
00179     Headers::ContentDisposition *contentDisposition( bool create=true );
00180 
00186     Headers::ContentDescription *contentDescription( bool create=true );
00187 
00191     int size();
00192 
00196     int storageSize() const;
00197 
00201     int lineCount() const;
00202 
00208     QByteArray body() const;
00209 
00217     void setBody( const QByteArray &body );
00218 
00225     QByteArray encodedContent( bool useCrLf = false );
00226 
00230     QByteArray decodedContent();
00231 
00245     QString decodedText( bool trimText = false,
00246                          bool removeTrailingNewlines = false );
00247 
00253     void fromUnicodeString( const QString &s );
00254 
00258     Content *textContent();
00259 
00265     List attachments( bool incAlternatives = false );
00266 
00270     List contents() const;
00271 
00282     void addContent( Content *c, bool prepend = false );
00283 
00293     void removeContent( Content *c, bool del = false );
00294 
00295     void changeEncoding( Headers::contentEncoding e );
00296 
00304     void toStream( QTextStream &ts, bool scrambleFromLines = false );
00305 
00312     QByteArray defaultCharset() const;
00313 
00321     void setDefaultCharset( const QByteArray &cs );
00322 
00329     bool forceDefaultCharset() const;
00330 
00340     virtual void setForceDefaultCharset( bool b );
00341 
00349     Content *content( const ContentIndex &index ) const;
00350 
00356     ContentIndex indexForContent( Content *content ) const;
00357 
00362     virtual bool isTopLevel() const;
00363 
00364   protected:
00370     virtual QByteArray assembleHeaders();
00371 
00372     QByteArray rawHeader( const char *name ) const;
00373     bool decodeText();
00374     template <class T> T *getHeaderInstance( T *ptr, bool create );
00375 
00376     Headers::Base::List h_eaders;
00377 
00378     //@cond PRIVATE
00379     ContentPrivate *d_ptr;
00380     explicit Content( ContentPrivate *d );
00381     //@endcond
00382 
00383   private:
00384     Q_DECLARE_PRIVATE( Content )
00385     Q_DISABLE_COPY( Content )
00386 };
00387 
00388 // some compilers (for instance Compaq C++) need template inline functions
00389 // here rather than in the *.cpp file
00390 
00391 template <class T> T *Content::getHeaderInstance( T *ptr, bool create )
00392 {
00393   T dummy; //needed to access virtual member T::type()
00394 
00395   ptr=static_cast <T*> ( getHeaderByType( dummy.type() ) );
00396   if ( !ptr && create ) { //no such header found, but we need one => create it
00397     ptr = new T( this );
00398     h_eaders.append( ptr );
00399   }
00400 
00401   return ptr;
00402 }
00403 
00404 } // namespace KMime
00405 
00406 #endif // __KMIME_CONTENT_H__

KMIME Library

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

KDE-PIM Libraries

Skip menu "KDE-PIM Libraries"
  • akonadi
  • kabc
  • kblog
  • kcal
  • kimap
  • kioslave
  •   imap4
  •   mbox
  • kldap
  • kmime
  • kpimidentities
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Generated for KDE-PIM Libraries by doxygen 1.5.6
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