KMIME Library
KMime::Content Class Reference
#include <kmime_content.h>

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.
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) |
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 |
ContentIndex | indexForContent (Content *content) const |
virtual bool | isTopLevel () const |
int | lineCount () 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) |
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 * | getHeaderInstance (T *ptr, bool create) |
QByteArray | rawHeader (const char *name) const |
Protected Attributes | |
Headers::Base::List | h_eaders |
Constructor & Destructor Documentation
KMime::Content::Content | ( | ) |
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] |
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 |
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 906 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 900 of file kmime_content.cpp.
Content::List KMime::Content::contents | ( | ) | const |
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 894 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 888 of file kmime_content.cpp.
QByteArray KMime::Content::decodedContent | ( | ) |
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.
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 996 of file kmime_content.cpp.
QByteArray KMime::Content::encodedContent | ( | bool | useCrLf = false |
) |
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 1014 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::Generic * KMime::Content::getNextHeader | ( | QByteArray & | head | ) |
Extracts and removes the next header from head
.
The caller is responsible for deleting the returned header.
- Parameters:
-
head is a QByteArray containing the header data.
Definition at line 752 of file kmime_content.cpp.
bool KMime::Content::hasContent | ( | ) | const |
QByteArray KMime::Content::head | ( | ) | const |
Returns the Content header raw data.
- See also:
- setHead().
Definition at line 134 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 1046 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 1066 of file kmime_content.cpp.
int KMime::Content::lineCount | ( | ) | const |
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.
- 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 1001 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 1019 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 912 of file kmime_content.cpp.
int KMime::Content::storageSize | ( | ) | const |
Returns the size of this Content and all sub-Contents.
Definition at line 923 of file kmime_content.cpp.
Content * KMime::Content::textContent | ( | ) |
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: