• Skip to content
  • Skip to link menu
KDE 4.3 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 
00084     explicit Content( Content* parent ); //TODO: Merge with the above
00085 
00092     Content( const QByteArray &head, const QByteArray &body );
00093 
00102     Content( const QByteArray &head, const QByteArray &body, Content *parent ); //TODO: merge with the above
00103 
00107     virtual ~Content();
00108 
00112     bool hasContent() const;
00113 
00120     void setContent( const QList<QByteArray> &l );
00121 
00128     void setContent( const QByteArray &s );
00129 
00133     virtual void parse();
00134 
00138     virtual void assemble();
00139 
00143     virtual void clear();
00144 
00150     QByteArray head() const;
00151 
00159     void setHead( const QByteArray &head );
00160 
00169     KDE_DEPRECATED Headers::Generic *getNextHeader( QByteArray &head );
00170 
00177     Headers::Generic *nextHeader( QByteArray &head );
00178 
00183     KDE_DEPRECATED virtual Headers::Base *getHeaderByType( const char *type );
00184 
00189     virtual Headers::Base *headerByType( const char *type );
00190 
00196     virtual QList<Headers::Base*> headersByType( const char *type );
00197 
00198     virtual void setHeader( Headers::Base *h );
00199 
00200     virtual bool removeHeader( const char *type );
00201 
00202     bool hasHeader( const char *type );
00203 
00209     Headers::ContentType *contentType( bool create=true );
00210 
00216     Headers::ContentTransferEncoding *contentTransferEncoding( bool create=true );
00217 
00223     Headers::ContentDisposition *contentDisposition( bool create=true );
00224 
00230     Headers::ContentDescription *contentDescription( bool create=true );
00231 
00238     Headers::ContentLocation *contentLocation( bool create=true );
00239 
00240 
00244     int size();
00245 
00249     int storageSize() const;
00250 
00254     int lineCount() const;
00255 
00261     QByteArray body() const;
00262 
00270     void setBody( const QByteArray &body );
00271 
00278     QByteArray encodedContent( bool useCrLf = false );
00279 
00283     QByteArray decodedContent();
00284 
00298     QString decodedText( bool trimText = false,
00299                          bool removeTrailingNewlines = false );
00300 
00306     void fromUnicodeString( const QString &s );
00307 
00311     Content *textContent();
00312 
00318     List attachments( bool incAlternatives = false );
00319 
00323     List contents() const;
00324 
00337     void addContent( Content *c, bool prepend = false );
00338 
00348     void removeContent( Content *c, bool del = false );
00349 
00350     void changeEncoding( Headers::contentEncoding e );
00351 
00359     void toStream( QTextStream &ts, bool scrambleFromLines = false );
00360 
00367     QByteArray defaultCharset() const;
00368 
00376     void setDefaultCharset( const QByteArray &cs );
00377 
00384     bool forceDefaultCharset() const;
00385 
00395     virtual void setForceDefaultCharset( bool b );
00396 
00404     Content *content( const ContentIndex &index ) const;
00405 
00411     ContentIndex indexForContent( Content *content ) const;
00412 
00417     virtual bool isTopLevel() const;
00418 
00425     void setParent( Content *parent );
00426 
00431     Content* parent() const;
00432 
00437     Content* topLevel() const;
00438 
00443     ContentIndex index() const;
00444 
00445   protected:
00451     virtual QByteArray assembleHeaders();
00452 
00453     QByteArray rawHeader( const char *name ) const;
00454     QList<QByteArray> rawHeaders( const char *name ) const;
00455     bool decodeText();
00456     template <class T> T *headerInstance( T *ptr, bool create );
00457 
00458     Headers::Base::List h_eaders;
00459 
00460     //@cond PRIVATE
00461     ContentPrivate *d_ptr;
00462     explicit Content( ContentPrivate *d );
00463     //@endcond
00464 
00465   private:
00466     Q_DECLARE_PRIVATE( Content )
00467     Q_DISABLE_COPY( Content )
00468 };
00469 
00470 // some compilers (for instance Compaq C++) need template inline functions
00471 // here rather than in the *.cpp file
00472 
00473 template <class T> T *Content::headerInstance( T *ptr, bool create )
00474 {
00475   T dummy; //needed to access virtual member T::type()
00476 
00477   ptr=static_cast <T*> ( headerByType( dummy.type() ) );
00478   if ( !ptr && create ) { //no such header found, but we need one => create it
00479     ptr = new T( this );
00480     h_eaders.append( ptr );
00481   }
00482 
00483   return ptr;
00484 }
00485 
00486 } // namespace KMime
00487 
00488 #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
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  • kldap
  • kmime
  • kpimidentities
  • kpimtextedit
  •   richtextbuilders
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Generated for KDE-PIM Libraries by doxygen 1.6.1
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