KMIME Library
KMime::Content Class Reference
A class that encapsulates MIME encoded Content. More...
#include <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 *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 | ( | ) |
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] |
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 626 of file kmime_content.cpp.
void KMime::Content::assemble | ( | ) | [virtual] |
Call to generate the MIME structure of the message.
Definition at line 329 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 347 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 596 of file kmime_content.cpp.
QByteArray KMime::Content::body | ( | ) | const |
Returns the Content body raw data.
- See also:
- setBody().
Definition at line 158 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 383 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 944 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 938 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 950 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 932 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 926 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 534 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 1045 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 1063 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 563 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.
Reimplemented in KMime::Message.
Definition at line 812 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 764 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 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 817 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 885 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 1151 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 1095 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 1115 of file kmime_content.cpp.
int KMime::Content::lineCount | ( | ) | const |
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 769 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 1134 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 169 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 679 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 163 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 1050 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 1068 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 1120 of file kmime_content.cpp.
int KMime::Content::size | ( | ) |
Returns the size of the Content body after encoding.
Definition at line 956 of file kmime_content.cpp.
int KMime::Content::storageSize | ( | ) | const |
Returns the size of this Content and all sub-Contents.
Definition at line 967 of file kmime_content.cpp.
Content * KMime::Content::textContent | ( | ) |
Content * KMime::Content::topLevel | ( | ) | const |
Returns the toplevel content object, NULL if there is no such object.
- Since:
- 4.3
Definition at line 1139 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 751 of file kmime_content.cpp.
The documentation for this class was generated from the following files: