• 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

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 ()
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 indexForContent (Content *content) const
virtual bool isTopLevel () const
int lineCount () const
Headers::Generic * nextHeader (QByteArray &head)
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)
int size ()
int storageSize () const
Content * textContent ()
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 ( 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 60 of file kmime_content.cpp.

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

Destroys this Content object.

Definition at line 72 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.

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 620 of file kmime_content.cpp.

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

Call to generate the MIME structure of the message.

Definition at line 323 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 341 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 590 of file kmime_content.cpp.

QByteArray KMime::Content::body (  )  const

Returns the Content body raw data.

See also:
setBody().

Definition at line 144 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 377 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 1069 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 932 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 926 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 938 of file kmime_content.cpp.

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

Returns a list of sub-Contents.

Definition at line 615 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 920 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 914 of file kmime_content.cpp.

QByteArray KMime::Content::decodedContent (  ) 

Returns the decoded Content body.

Definition at line 481 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 528 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 1033 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 388 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 1051 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 557 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 800 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 752 of file kmime_content.cpp.

bool KMime::Content::hasContent (  )  const

Returns true if this Content object is not empty.

Definition at line 79 of file kmime_content.cpp.

QByteArray KMime::Content::head (  )  const

Returns the Content header raw data.

See also:
setHead().

Definition at line 134 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 805 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 873 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 1083 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 1103 of file kmime_content.cpp.

int KMime::Content::lineCount (  )  const

Line count of this Content and all sub-Contents.

Definition at line 971 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 757 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 155 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.
See also:
addContent().

Definition at line 669 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 149 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 113 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 84 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 1038 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 1056 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 139 of file kmime_content.cpp.

int KMime::Content::size (  ) 

Returns the size of the Content body after encoding.

Definition at line 944 of file kmime_content.cpp.

int KMime::Content::storageSize (  )  const

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

Definition at line 955 of file kmime_content.cpp.

Content * KMime::Content::textContent (  ) 

Returns the first Content with mimetype text/.

Definition at line 573 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 739 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
  • 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.8
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