48 #ifndef __KMIME_CONTENT_H__
49 #define __KMIME_CONTENT_H__
51 #include "kmime_export.h"
53 #include "kmime_util.h"
56 #include <QtCore/QTextStream>
57 #include <QtCore/QByteArray>
58 #include <QtCore/QList>
60 #include <boost/shared_ptr.hpp>
119 typedef QList<KMime::Content*>
List;
139 Content(
const QByteArray &head,
const QByteArray &body );
150 Content(
const QByteArray &head,
const QByteArray &body,
Content *parent );
160 bool hasContent()
const;
172 void setContent(
const QList<QByteArray> &l );
187 void setContent(
const QByteArray &s );
207 virtual void parse();
218 bool isFrozen()
const;
226 void setFrozen(
bool frozen =
true );
247 virtual void assemble();
253 virtual void clear();
266 void clearContents(
bool del =
true );
273 QByteArray head()
const;
285 void setHead(
const QByteArray &head );
312 KMIME_DEPRECATED
virtual Headers::Base *getHeaderByType(
const char *type );
334 template <
typename T> T *header(
bool create =
false );
342 virtual QList<Headers::Base*> headersByType(
const char *type );
380 virtual bool removeHeader(
const char *type );
388 bool hasHeader(
const char *type );
443 int storageSize()
const;
448 int lineCount()
const;
458 QByteArray body()
const;
470 void setBody(
const QByteArray &body );
479 QByteArray preamble()
const;
490 void setPreamble(
const QByteArray &preamble );
499 QByteArray epilogue()
const;
509 void setEpilogue(
const QByteArray &epilogue );
525 QByteArray encodedContent(
bool useCrLf =
false );
533 QByteArray encodedBody();
544 QByteArray decodedContent();
561 QString decodedText(
bool trimText =
false,
562 bool removeTrailingNewlines =
false );
580 void fromUnicodeString(
const QString &s );
592 List attachments(
bool incAlternatives =
false );
599 List contents()
const;
618 void addContent(
Content *content,
bool prepend =
false );
637 void removeContent(
Content *content,
bool del =
false );
645 void changeEncoding( Headers::contentEncoding e );
654 void toStream( QTextStream &ts,
bool scrambleFromLines =
false );
668 QByteArray defaultCharset()
const;
677 void setDefaultCharset(
const QByteArray &cs );
685 bool forceDefaultCharset()
const;
696 virtual void setForceDefaultCharset(
bool b );
719 virtual bool isTopLevel()
const;
727 void setParent(
Content *parent );
754 bool bodyIsMessage()
const;
775 boost::shared_ptr<Message> bodyAsMessage()
const;
783 virtual QByteArray assembleHeaders();
790 KMIME_DEPRECATED QByteArray rawHeader(
const char *name )
const;
796 KMIME_DEPRECATED QList<QByteArray> rawHeaders(
const char *name )
const;
808 template <
class T> KMIME_DEPRECATED T *headerInstance( T *ptr,
bool create );
818 ContentPrivate *d_ptr;
819 explicit Content( ContentPrivate *d );
830 template <class T> T *Content::headerInstance( T *,
bool create )
832 return header<T>( create );
840 Q_ASSERT( dynamic_cast<T*>( h ) );
841 }
else if ( create ) {
845 return static_cast<T*
>( h );
850 #endif // __KMIME_CONTENT_H__
QList< KMime::Content * > List
Describes a list of Content objects.
T * header(bool create=false)
Returns the first header of type T, if it exists.
Headers::Base::List h_eaders
The list of headers in this Content.
A class that encapsulates MIME encoded Content.
This file is part of the API for handling MIME data and defines the ContentIndex class.
A class to uniquely identify message parts (Content) in a hierarchy.