• Skip to content
  • Skip to link menu
KDE 4.2 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 
00152     KDE_DEPRECATED Headers::Generic *getNextHeader( QByteArray &head );
00153 
00160     Headers::Generic *nextHeader( QByteArray &head );
00161 
00166     KDE_DEPRECATED virtual Headers::Base *getHeaderByType( const char *type );
00167 
00172     virtual Headers::Base *headerByType( const char *type );
00173 
00179     virtual QList<Headers::Base*> headersByType( const char *type );
00180 
00181     virtual void setHeader( Headers::Base *h );
00182 
00183     virtual bool removeHeader( const char *type );
00184 
00185     bool hasHeader( const char *type );
00186 
00192     Headers::ContentType *contentType( bool create=true );
00193 
00199     Headers::ContentTransferEncoding *contentTransferEncoding( bool create=true );
00200 
00206     Headers::ContentDisposition *contentDisposition( bool create=true );
00207 
00213     Headers::ContentDescription *contentDescription( bool create=true );
00214 
00221     Headers::ContentLocation *contentLocation( bool create=true );
00222 
00223 
00227     int size();
00228 
00232     int storageSize() const;
00233 
00237     int lineCount() const;
00238 
00244     QByteArray body() const;
00245 
00253     void setBody( const QByteArray &body );
00254 
00261     QByteArray encodedContent( bool useCrLf = false );
00262 
00266     QByteArray decodedContent();
00267 
00281     QString decodedText( bool trimText = false,
00282                          bool removeTrailingNewlines = false );
00283 
00289     void fromUnicodeString( const QString &s );
00290 
00294     Content *textContent();
00295 
00301     List attachments( bool incAlternatives = false );
00302 
00306     List contents() const;
00307 
00318     void addContent( Content *c, bool prepend = false );
00319 
00329     void removeContent( Content *c, bool del = false );
00330 
00331     void changeEncoding( Headers::contentEncoding e );
00332 
00340     void toStream( QTextStream &ts, bool scrambleFromLines = false );
00341 
00348     QByteArray defaultCharset() const;
00349 
00357     void setDefaultCharset( const QByteArray &cs );
00358 
00365     bool forceDefaultCharset() const;
00366 
00376     virtual void setForceDefaultCharset( bool b );
00377 
00385     Content *content( const ContentIndex &index ) const;
00386 
00392     ContentIndex indexForContent( Content *content ) const;
00393 
00398     virtual bool isTopLevel() const;
00399 
00400   protected:
00406     virtual QByteArray assembleHeaders();
00407 
00408     QByteArray rawHeader( const char *name ) const;
00409     QList<QByteArray> rawHeaders( const char *name ) const;
00410     bool decodeText();
00411     template <class T> T *headerInstance( T *ptr, bool create );
00412 
00413     Headers::Base::List h_eaders;
00414 
00415     //@cond PRIVATE
00416     ContentPrivate *d_ptr;
00417     explicit Content( ContentPrivate *d );
00418     //@endcond
00419 
00420   private:
00421     Q_DECLARE_PRIVATE( Content )
00422     Q_DISABLE_COPY( Content )
00423 };
00424 
00425 // some compilers (for instance Compaq C++) need template inline functions
00426 // here rather than in the *.cpp file
00427 
00428 template <class T> T *Content::headerInstance( T *ptr, bool create )
00429 {
00430   T dummy; //needed to access virtual member T::type()
00431 
00432   ptr=static_cast <T*> ( headerByType( dummy.type() ) );
00433   if ( !ptr && create ) { //no such header found, but we need one => create it
00434     ptr = new T( this );
00435     h_eaders.append( ptr );
00436   }
00437 
00438   return ptr;
00439 }
00440 
00441 } // namespace KMime
00442 
00443 #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
  •   richtextbuilders
  • 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