• 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

KMime::Content Class Reference

A class that encapsulates MIME encoded Content. More...

#include <kmime_content.h>

Inheritance diagram for KMime::Content:

Inheritance graph
[legend]

List of all members.


Public Types

typedef QList< KMime::Content * > List

Public Member Functions

void addContent (Content *c, bool prepend=false)
virtual void assemble ()
List attachments (bool incAlternatives=false)
QByteArray body () const
void changeEncoding (Headers::contentEncoding e)
virtual void clear ()
Content * content (const ContentIndex &index) const
 Content (const QByteArray &head, const QByteArray &body, Content *parent)
 Content (const QByteArray &head, const QByteArray &body)
 Content (Content *parent)
 Content ()
Headers::ContentDescription * contentDescription (bool create=true)
Headers::ContentDisposition * contentDisposition (bool create=true)
Headers::ContentLocation * contentLocation (bool create=true)
List contents () const
Headers::ContentTransferEncoding * contentTransferEncoding (bool create=true)
Headers::ContentType * contentType (bool create=true)
QByteArray decodedContent ()
QString decodedText (bool trimText=false, bool removeTrailingNewlines=false)
QByteArray defaultCharset () const
QByteArray encodedContent (bool useCrLf=false)
bool forceDefaultCharset () const
void fromUnicodeString (const QString &s)
virtual Headers::Base * getHeaderByType (const char *type)
Headers::Generic * getNextHeader (QByteArray &head)
bool hasContent () const
bool hasHeader (const char *type)
QByteArray head () const
virtual Headers::Base * headerByType (const char *type)
virtual QList< Headers::Base * > headersByType (const char *type)
ContentIndex index () const
ContentIndex indexForContent (Content *content) const
virtual bool isTopLevel () const
int lineCount () const
Headers::Generic * nextHeader (QByteArray &head)
Content * parent () const
virtual void parse ()
void removeContent (Content *c, bool del=false)
virtual bool removeHeader (const char *type)
void setBody (const QByteArray &body)
void setContent (const QByteArray &s)
void setContent (const QList< QByteArray > &l)
void setDefaultCharset (const QByteArray &cs)
virtual void setForceDefaultCharset (bool b)
void setHead (const QByteArray &head)
virtual void setHeader (Headers::Base *h)
void setParent (Content *parent)
int size ()
int storageSize () const
Content * textContent ()
Content * topLevel () const
void toStream (QTextStream &ts, bool scrambleFromLines=false)
virtual ~Content ()

Protected Member Functions

virtual QByteArray assembleHeaders ()
bool decodeText ()
template<class T >
T * headerInstance (T *ptr, bool create)
QByteArray rawHeader (const char *name) const
QList< QByteArray > rawHeaders (const char *name) const

Protected Attributes

Headers::Base::List h_eaders

Detailed Description

A class that encapsulates MIME encoded Content.

It parses the given data and creates a tree-like structure that represents the structure of the message.

Definition at line 68 of file kmime_content.h.


Constructor & Destructor Documentation

KMime::Content::Content (  ) 

Creates an empty Content object.

Definition at line 55 of file kmime_content.cpp.

KMime::Content::Content ( Content *  parent  )  [explicit]

Creates an empty Content object with a specified parent.

Parameters:
parent the parent Content object
Since:
4.3

Definition at line 60 of file kmime_content.cpp.

KMime::Content::Content ( const QByteArray &  head,
const QByteArray &  body 
)

Creates a Content object containing the given raw data.

Parameters:
head is a QByteArray containing the header data.
body is a QByteArray containing the body data.

Definition at line 66 of file kmime_content.cpp.

KMime::Content::Content ( const QByteArray &  head,
const QByteArray &  body,
Content *  parent 
)

Creates a Content object containing the given raw data.

Parameters:
head is a QByteArray containing the header data.
body is a QByteArray containing the body data.
parent the parent Content object
Since:
4.3

Definition at line 73 of file kmime_content.cpp.

KMime::Content::~Content (  )  [virtual]

Destroys this Content object.

Definition at line 86 of file kmime_content.cpp.


Member Function Documentation

void KMime::Content::addContent ( Content *  c,
bool  prepend = false 
)

Adds a new sub-Content, the current Content object is converted into a multipart/mixed Content node if it has been a single-part Content.

If the sub-Content is already in another Content object, it is removed from there and its parent is updated.

Parameters:
c The new sub-Content.
prepend if true, prepend to the Content list; else append to the Content list.
See also:
removeContent().

Definition at line 628 of file kmime_content.cpp.

void KMime::Content::assemble (  )  [virtual]

Call to generate the MIME structure of the message.

Definition at line 331 of file kmime_content.cpp.

QByteArray KMime::Content::assembleHeaders (  )  [protected, virtual]

Reimplement this method if you need to assemble additional headers in a derived class.

Don't forget to call the implementation of the base class.

Returns:
The raw, assembled headers.

Reimplemented in KMime::Message.

Definition at line 349 of file kmime_content.cpp.

Content::List KMime::Content::attachments ( bool  incAlternatives = false  ) 

Returns a list of attachments.

Parameters:
incAlternatives if true, include multipart/alternative parts.

Definition at line 598 of file kmime_content.cpp.

QByteArray KMime::Content::body (  )  const

Returns the Content body raw data.

See also:
setBody().

Definition at line 160 of file kmime_content.cpp.

void KMime::Content::clear (  )  [virtual]

Clears the complete message and deletes all sub-Contents.

Reimplemented in KMime::Message.

Definition at line 385 of file kmime_content.cpp.

Content * KMime::Content::content ( const ContentIndex &  index  )  const

Returns the Content specified by the given index.

If the index doesn't point to a Content, 0 is returned, if the index is invalid (empty), this Content is returned.

Parameters:
index the Content index

Definition at line 1083 of file kmime_content.cpp.

Headers::ContentDescription * KMime::Content::contentDescription ( bool  create = true  ) 

Returns the Content description.

Parameters:
create if true, create the header if it doesn't exist yet.

Definition at line 946 of file kmime_content.cpp.

Headers::ContentDisposition * KMime::Content::contentDisposition ( bool  create = true  ) 

Returns the Content disposition.

Parameters:
create if true, create the header if it doesn't exist yet.

Definition at line 940 of file kmime_content.cpp.

Headers::ContentLocation * KMime::Content::contentLocation ( bool  create = true  ) 

Returns the Content location.

Parameters:
create if true, create the header if it doesn't exist yet.
Since:
4.2

Definition at line 952 of file kmime_content.cpp.

Content::List KMime::Content::contents (  )  const

Returns a list of sub-Contents.

Definition at line 623 of file kmime_content.cpp.

Headers::ContentTransferEncoding * KMime::Content::contentTransferEncoding ( bool  create = true  ) 

Returns the Content transfer encoding.

Parameters:
create if true, create the header if it doesn't exist yet.

Definition at line 934 of file kmime_content.cpp.

Headers::ContentType * KMime::Content::contentType ( bool  create = true  ) 

Returns the Content type header.

Parameters:
create if true, create the header if it doesn't exist yet.

Definition at line 928 of file kmime_content.cpp.

QByteArray KMime::Content::decodedContent (  ) 

Returns the decoded Content body.

Definition at line 489 of file kmime_content.cpp.

QString KMime::Content::decodedText ( bool  trimText = false,
bool  removeTrailingNewlines = false 
)

Returns the decoded text.

Additional to decodedContent(), this also applies charset decoding. If this is not a text Content, decodedText() returns an empty QString.

Parameters:
trimText if true, then the decoded text will have all trailing whitespace removed.
removeTrailingNewlines if true, then the decoded text will have all consecutive trailing newlines removed.
The last trailing new line of the decoded text is always removed.

Definition at line 536 of file kmime_content.cpp.

QByteArray KMime::Content::defaultCharset (  )  const

Returns the charset that is used for all headers and the body if the charset is not declared explictly.

See also:
setDefaultCharset()

Definition at line 1047 of file kmime_content.cpp.

QByteArray KMime::Content::encodedContent ( bool  useCrLf = false  ) 

Returns a QByteArray containing the encoded Content, including the Content header and all sub-Contents.

Parameters:
useCrLf if true, use CRLF instead of LF for linefeeds.

Definition at line 396 of file kmime_content.cpp.

bool KMime::Content::forceDefaultCharset (  )  const

Use the default charset even if a different charset is declared in the article.

See also:
setForceDefaultCharset().

Definition at line 1065 of file kmime_content.cpp.

void KMime::Content::fromUnicodeString ( const QString &  s  ) 

Sets the Content body to the given string using the current charset.

Parameters:
s Unicode-encoded string.

Definition at line 565 of file kmime_content.cpp.

Headers::Base * KMime::Content::getHeaderByType ( const char *  type  )  [virtual]

Tries to find a type header in the message and returns it.

Deprecated:
Use headerByType( const char * )

Reimplemented in KMime::Message.

Definition at line 814 of file kmime_content.cpp.

Headers::Generic * KMime::Content::getNextHeader ( QByteArray &  head  ) 

Extracts and removes the next header from head.

The caller is responsible for deleting the returned header.

Deprecated:
Use nextHeader( QByteArray )
Parameters:
head is a QByteArray containing the header data.

Definition at line 766 of file kmime_content.cpp.

bool KMime::Content::hasContent (  )  const

Returns true if this Content object is not empty.

Definition at line 93 of file kmime_content.cpp.

QByteArray KMime::Content::head (  )  const

Returns the Content header raw data.

See also:
setHead().

Definition at line 148 of file kmime_content.cpp.

Headers::Base * KMime::Content::headerByType ( const char *  type  )  [virtual]

Tries to find a type header in the message and returns it.

Since:
4.2

Reimplemented in KMime::Message.

Definition at line 819 of file kmime_content.cpp.

QList< Headers::Base * > KMime::Content::headersByType ( const char *  type  )  [virtual]

Tries to find all the type headers in the message and returns it.

Take care that this result is not cached, so could be slow.

Since:
4.2

Definition at line 887 of file kmime_content.cpp.

ContentIndex KMime::Content::index (  )  const

Returns the index of this Content based on the topLevel() object.

Since:
4.3

Definition at line 1153 of file kmime_content.cpp.

ContentIndex KMime::Content::indexForContent ( Content *  content  )  const

Returns the ContentIndex for the given Content, an invalid index if the Content is not found withing the hierarchy.

Parameters:
content the Content object to search.

Definition at line 1097 of file kmime_content.cpp.

bool KMime::Content::isTopLevel (  )  const [virtual]

Returns true if this is the top-level node in the MIME tree, ie.

if this is actually a message or news article.

Reimplemented in KMime::Message.

Definition at line 1117 of file kmime_content.cpp.

int KMime::Content::lineCount (  )  const

Line count of this Content and all sub-Contents.

Definition at line 985 of file kmime_content.cpp.

Headers::Generic * KMime::Content::nextHeader ( QByteArray &  head  ) 

Extracts and removes the next header from head.

The caller is responsible for deleting the returned header.

Since:
4.2
Parameters:
head is a QByteArray containing the header data.

Definition at line 771 of file kmime_content.cpp.

Content * KMime::Content::parent (  )  const

Returns the parent content object, or NULL if the content doesn't have a parent.

Since:
4.3

Definition at line 1136 of file kmime_content.cpp.

void KMime::Content::parse (  )  [virtual]

Parses the Contents, splitting into multiple sub-Contents.

Reimplemented in KMime::Message.

Definition at line 171 of file kmime_content.cpp.

void KMime::Content::removeContent ( Content *  c,
bool  del = false 
)

Removes the given sub-Content, the current Content object is converted into a single-port Content if only one sub-Content is left.

Parameters:
c The Content to remove.
del if true, delete the removed Content object. Otherwise its parent is set to NULL.
See also:
addContent().

Definition at line 681 of file kmime_content.cpp.

void KMime::Content::setBody ( const QByteArray &  body  ) 

Sets the Content body raw data.

Parameters:
body is a QByteArray containing the body data.
See also:
body().

Definition at line 165 of file kmime_content.cpp.

void KMime::Content::setContent ( const QByteArray &  s  ) 

Sets the Content to the given raw data, containing the Content head and body separated by two linefeeds.

Parameters:
s is a QByteArray containing the raw Content data.

Definition at line 127 of file kmime_content.cpp.

void KMime::Content::setContent ( const QList< QByteArray > &  l  ) 

Sets the Content to the given raw data, containing the Content head and body separated by two linefeeds.

Parameters:
l is a line-splitted list of the raw Content data.

Definition at line 98 of file kmime_content.cpp.

void KMime::Content::setDefaultCharset ( const QByteArray &  cs  ) 

Sets the default charset.

Parameters:
cs is a QByteArray containing the new default charset.
See also:
defaultCharset().

Definition at line 1052 of file kmime_content.cpp.

void KMime::Content::setForceDefaultCharset ( bool  b  )  [virtual]

Enables/disables the force mode, housekeeping.

works correctly only when the article is completely empty or completely loaded.

Parameters:
b if true, force the default charset to be used.
See also:
forceDefaultCharset().

Definition at line 1070 of file kmime_content.cpp.

void KMime::Content::setHead ( const QByteArray &  head  ) 

Sets the Content header raw data.

Parameters:
head is a QByteArray containing the header data.
See also:
head().

Definition at line 153 of file kmime_content.cpp.

void KMime::Content::setParent ( Content *  parent  ) 

Sets a new parent to the Content and add to its contents list.

If it already had a parent, it is removed from the old parents contents list.

Parameters:
parent the new parent
Since:
4.3

Definition at line 1122 of file kmime_content.cpp.

int KMime::Content::size (  ) 

Returns the size of the Content body after encoding.

Definition at line 958 of file kmime_content.cpp.

int KMime::Content::storageSize (  )  const

Returns the size of this Content and all sub-Contents.

Definition at line 969 of file kmime_content.cpp.

Content * KMime::Content::textContent (  ) 

Returns the first Content with mimetype text/.

Definition at line 581 of file kmime_content.cpp.

Content * KMime::Content::topLevel (  )  const

Returns the toplevel content object, NULL if there is no such object.

Since:
4.3

Definition at line 1141 of file kmime_content.cpp.

void KMime::Content::toStream ( QTextStream &  ts,
bool  scrambleFromLines = false 
)

Saves the encoded Content to the given textstream.

Parameters:
ts is the stream where the Content should be written to.
scrambleFromLines,: if true, replace "\nFrom " with "\n>From " in the stream. This is needed to avoid problem with mbox-files

Definition at line 753 of file kmime_content.cpp.


The documentation for this class was generated from the following files:
  • kmime_content.h
  • kmime_content.cpp

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.5.9
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