• Skip to content
  • Skip to link menu
KDE 4.5 API Reference
  • KDE API Reference
  • KDE-PIM Libraries
  • Sitemap
  • Contact Us
 

KMIME Library

Classes | Functions | Variables

KMime Namespace Reference

Contains all the KMIME library global classes, objects, and functions. More...

Classes

class  Base64Codec
 A class representing the codec for Base64 as specified in RFC2045. More...
class  BinaryCodec
 A class representing the codec for eight-bit-binary. More...
class  BoolFlags
 Provides a class for storing boolean values in single bytes. More...
class  CharFreq
 A class for performing basic data typing using frequency count heuristics. More...
class  Codec
 An abstract base class of codecs for common mail transfer encodings. More...
class  Content
 A class that encapsulates MIME encoded Content. More...
class  ContentIndex
 A class to uniquely identify message parts (Content) in a hierarchy. More...
class  DateFormatter
 A class for abstracting date formatting. More...
class  Decoder
 Stateful CTE decoder class. More...
class  EightBitCodec
 A class representing the codec for eight-bit-text. More...
class  Encoder
 Stateful encoder class. More...
class  HeaderFactory
 docu TODO More...
class  IdentityCodec
 A class representing the Identify codec. More...
class  KAutoDeleteHash
 The KAutoDeleteHash class is a convenience QHash subclass that provides automatic deletion of the values in the destructor. More...
class  Message
 Represents a (email) message. More...
class  QuotedPrintableCodec
 A class representing the codec for QuotedPrintable as specified in RFC2045 (section 6.7). More...
class  Rfc2047BEncodingCodec
 A class representing the codec for the B encoding as specified in RFC2047B. More...
class  Rfc2047QEncodingCodec
 A class representing the codec for the Q encoding as specified in RFC2047Q. More...
class  Rfc2231EncodingCodec
 A class representing the codec for RFC2231. More...
class  SevenBitCodec
 A class representing the codec for seven-bit-text. More...
class  UUCodec
 A class representing the UUEncode codec. More...

Functions

void addQuotes (QByteArray &str, bool forceQuotes)
void addQuotes (QString &str, bool forceQuotes)
template<class StringType >
void addQuotes_impl (StringType &str, bool forceQuotes, char(*convertFunction)(const StringType &, int))
QString balanceBidiState (const QString &input)
static char binToHex (uchar value)
QByteArray cachedCharset (const QByteArray &name)
QByteArray cachedLanguage (const QByteArray &name)
QByteArray CRLFtoLF (const QByteArray &s)
QByteArray CRLFtoLF (const char *s)
QString decodeRFC2047String (const QByteArray &src)
QString decodeRFC2047String (const QByteArray &src, QByteArray &usedCS, const QByteArray &defaultCS=QByteArray(), bool forceCS=false)
QString decodeRFC2231String (const QByteArray &src, QByteArray &usedCS, const QByteArray &defaultCS=QByteArray(), bool forceCS=false)
QString decodeRFC2231String (const QByteArray &src)
QByteArray encodeRFC2047String (const QString &src, const QByteArray &charset, bool addressHeader=false, bool allow8bitHeaders=false)
QByteArray encodeRFC2231String (const QString &src, const QByteArray &charset)
QList< Headers::contentEncoding > encodingsForData (const QByteArray &data)
QByteArray extractHeader (const QByteArray &src, const QByteArray &name)
QList< QByteArray > extractHeaders (const QByteArray &src, const QByteArray &name)
QString fallbackCharEncoding ()
int findHeaderLineEnd (const QByteArray &src, int &dataBegin, bool *folded)
static char getCharFromQByteArray (const QByteArray &array, int index)
static char getCharFromQString (const QString &string, int index)
static uchar highNibble (uchar ch)
int indexOfHeader (const QByteArray &src, const QByteArray &name, int &end, int &dataBegin, bool *folded)
bool isUsAscii (const QString &s)
static bool keep (uchar ch)
QByteArray LFtoCRLF (const QByteArray &s)
QByteArray LFtoCRLF (const char *s)
static uchar lowNibble (uchar ch)
QByteArray multiPartBoundary ()
QString nameForEncoding (KMime::Headers::contentEncoding enc)
static int QuotedPrintableDecoder_maxDecodedSizeFor (int insize, bool withCRLF)
QString removeBidiControlChars (const QString &input)
void removeHeader (QByteArray &header, const QByteArray &name)
void removeQuots (QString &str)
void removeQuots (QByteArray &str)
void setFallbackCharEncoding (const QString &fallbackCharEnc)
void setUseOutlookAttachmentEncoding (bool violateStandard)
QByteArray unfoldHeader (const QByteArray &header)
QByteArray uniqueString ()
bool useOutlookAttachmentEncoding ()
static uchar uuDecode (uchar c)

Variables

const uchar aTextMap [16]
QList< QByteArray > c_harsetCache
const uchar eTextMap [16]
QString f_allbackCharEnc
QList< QByteArray > l_anguageCache
const uchar specialsMap [16]
const uchar tSpecialsMap [16]
const uchar tTextMap [16]
bool u_seOutlookEncoding = false

Detailed Description

Contains all the KMIME library global classes, objects, and functions.


Function Documentation

void KMime::addQuotes ( QByteArray &  str,
bool  forceQuotes 
)

Converts the given string into a quoted-string if the string contains any special characters (ie.

one of ()<>@,.;:[]=").

Parameters:
str us-ascii string to work on.
forceQuotes if true, always add quote characters.
void KMime::addQuotes ( QString &  str,
bool  forceQuotes 
)

Overloaded method, behaves same as the above.

Since:
4.5
QString KMime::balanceBidiState ( const QString &  input  ) 

Makes sure that the bidirectional state at the end of the string is the same as at the beginning of the string.

This is useful so that Unicode control characters that can change the text direction can not spill over to following strings.

As an example, consider a mailbox in the form "display name" <local@domain.com>. If the display name here contains unbalanced control characters that change the text direction, it would also have an effect on the addrspec, which could lead to spoofing.

By passing the display name to this function, one can make sure that no change of the bidi state can spill over to the next strings, in this case the addrspec.

Example: The string "Hello <RLO>World" is unbalanced, as it contains a right-to-left override character, which is never followed by a <PDF>, the "pop directional formatting" character. This function adds the missing <PDF> at the end, and the output of this function would be "Hello <RLO>World<PDF>".

Example of spoofing: Consider "Firstname Lastname<RLO>" <moc.mitciv@attacker.com>. Because of the RLO, it is displayed as "Firstname Lastname <moc.rekcatta@victim.com>", which spoofs the domain name. By passing "Firstname Lastname<RLO>" to this function, one can balance the <RLO>, leading to "Firstname Lastname<RLO><PDF>", so the whole mailbox is displayed correctly as "Firstname Lastname" <moc.mitciv@attacker.com> again.

See http://unicode.org/reports/tr9 for more information on bidi control chars.

Parameters:
input the display name of a mailbox, which is checked for unbalanced Unicode direction control characters
Returns:
the display name which now contains a balanced state of direction control characters

Note that this function does not do any parsing related to mailboxes, it only works on plain strings. Therefore, passing the complete mailbox will not lead to any results, only the display name should be passed.

Since:
4.5
static char KMime::binToHex ( uchar  value  )  [inline, static]

Converts a 4-bit value into its hexadecimal characater representation.

So input of value [0,15] returns ['0','1',... 'F']. Input values greater than 15 will produce undesired results.

Parameters:
value is an unsigned character containing the 4-bit input value.

Definition at line 54 of file kmime_codec_qp.cpp.

QByteArray KMime::cachedCharset ( const QByteArray &  name  ) 

Consult the charset cache.

Only used for reducing mem usage by keeping strings in a common repository.

Parameters:
name 
QByteArray KMime::cachedLanguage ( const QByteArray &  name  ) 

Consult the language cache.

Only used for reducing mem usage by keeping strings in a common repository.

Parameters:
name 
QByteArray KMime::CRLFtoLF ( const QByteArray &  s  ) 

Converts all occurrences of "\r\n" (CRLF) in s to "\n" (LF).

This function is expensive and should be used only if the mail will be stored locally. All decode functions can cope with both line endings.

Parameters:
s source string containing CRLF's
Returns:
the string with CRLF's substitued for LF's
See also:
CRLFtoLF(const char*) LFtoCRLF
QByteArray KMime::CRLFtoLF ( const char *  s  ) 

Converts all occurrences of "\r\n" (CRLF) in s to "\n" (LF).

This function is expensive and should be used only if the mail will be stored locally. All decode functions can cope with both line endings.

Parameters:
s source string containing CRLF's
Returns:
the string with CRLF's substitued for LF's
See also:
CRLFtoLF(const QCString&) LFtoCRLF
QString KMime::decodeRFC2047String ( const QByteArray &  src  ) 

Decode string src according to RFC2047 (ie.

the =?charset?[qb]?encoded?= construct).

Parameters:
src source string.
Returns:
the decoded string.
QString KMime::decodeRFC2047String ( const QByteArray &  src,
QByteArray &  usedCS,
const QByteArray &  defaultCS = QByteArray(),
bool  forceCS = false 
)

Decodes string src according to RFC2047,i.e., the construct =?charset?[qb]?encoded?=.

Parameters:
src source string.
usedCS the detected charset is returned here
defaultCS the charset to use in case the detected one isn't known to us.
forceCS force the use of the default charset.
Returns:
the decoded string.
QString KMime::decodeRFC2231String ( const QByteArray &  src,
QByteArray &  usedCS,
const QByteArray &  defaultCS = QByteArray(),
bool  forceCS = false 
)

Decodes string src according to RFC2231.

Parameters:
src source string.
usedCs the detected charset is returned here
defaultCS the charset to use in case the detected one isn't known to us.
forceCS force the use of the default charset.
Returns:
the decoded string.
QString KMime::decodeRFC2231String ( const QByteArray &  src  ) 

Decode string src according to RFC2231 (ie.

the charset'lang'encoded construct).

Parameters:
src source string.
Returns:
the decoded string.
QByteArray KMime::encodeRFC2047String ( const QString &  src,
const QByteArray &  charset,
bool  addressHeader = false,
bool  allow8bitHeaders = false 
)

Encodes string src according to RFC2047 using charset charset.

Parameters:
src source string.
charset charset to use.
addressHeader if this flag is true, all special chars like <,>,[,],... will be encoded, too.
allow8bitHeaders if this flag is true, 8Bit headers are allowed.
Returns:
the encoded string.
QByteArray KMime::encodeRFC2231String ( const QString &  src,
const QByteArray &  charset 
)

Encodes string src according to RFC2231 using charset charset.

Parameters:
src source string.
charset charset to use.
Returns:
the encoded string.
QList< KMime::Headers::contentEncoding > KMime::encodingsForData ( const QByteArray &  data  ) 

Returns a list of encodings that can correctly encode the data.

@ since 4.4

QByteArray KMime::extractHeader ( const QByteArray &  src,
const QByteArray &  name 
)

Tries to extract the header with name name from the string src, unfolding it if necessary.

Parameters:
src the source string.
name the name of the header to search for.
Returns:
the first instance of the header name in src or a null QCString if no such header was found.
QList< QByteArray > KMime::extractHeaders ( const QByteArray &  src,
const QByteArray &  name 
)

Tries to extract the headers with name name from the string src, unfolding it if necessary.

Parameters:
src the source string.
name the name of the header to search for.
Returns:
all instances of the header name in src
Since:
4.2
QString KMime::fallbackCharEncoding (  ) 

Retreive the set fallback charset if there is one set.

Returns:
The name of the fallback encoding, if one was set, otherwise an empty QString.
Since:
4.5
static uchar KMime::highNibble ( uchar  ch  )  [inline, static]

Returns the high-order 4 bits of an 8-bit value in another 8-bit value.

Parameters:
ch is an unsigned character containing the 8-bit input value.

Definition at line 67 of file kmime_codec_qp.cpp.

bool KMime::isUsAscii ( const QString &  s  ) 

Checks whether s contains any non-us-ascii characters.

Parameters:
s 
static bool KMime::keep ( uchar  ch  )  [inline, static]

Returns true if the specified value is a not Control character or question mark; else true.

Parameters:
ch is an unsigned character containing the 8-bit input value.

Definition at line 86 of file kmime_codec_qp.cpp.

QByteArray KMime::LFtoCRLF ( const QByteArray &  s  ) 

Converts all occurrences of "\n" (LF) in s to "\r\n" (CRLF).

This function is expensive and should be used only if the mail will be transmitted as an RFC822 message later. All decode functions can cope with and all encode functions can optionally produce both line endings, which is much faster.

Parameters:
s source string containing CRLF's
Returns:
the string with CRLF's substitued for LF's
See also:
CRLFtoLF(const QCString&) LFtoCRLF
static uchar KMime::lowNibble ( uchar  ch  )  [inline, static]

Returns the low-order 4 bits of an 8-bit value in another 8-bit value.

Parameters:
ch is an unsigned character containing the 8-bit input value.

Definition at line 76 of file kmime_codec_qp.cpp.

QByteArray KMime::multiPartBoundary (  ) 

Constructs a random string (sans leading/trailing "--") that can be used as a multipart delimiter (ie.

as boundary parameter to a multipart/... content-type).

Returns:
the randomized string.
See also:
uniqueString
QString KMime::nameForEncoding ( KMime::Headers::contentEncoding  enc  ) 

Returns a user-visible string for a contentEncoding, for example "quoted-printable" for CEquPr.

@ since 4.4 TODO should they be i18n'ed?

QString KMime::removeBidiControlChars ( const QString &  input  ) 

Similar to the above function.

Instead of trying to balance the Bidi chars, it outright removes them from the string.

Reason: KHTML seems to ignore the PDF character, so adding them doesn't fix things :(

void KMime::removeQuots ( QString &  str  ) 

Removes quote (DQUOTE) characters and decodes "quoted-pairs" (ie.

backslash-escaped characters)

Parameters:
str the string to work on.
See also:
addQuotes
void KMime::removeQuots ( QByteArray &  str  ) 

Removes quote (DQUOTE) characters and decodes "quoted-pairs" (ie.

backslash-escaped characters)

Parameters:
str the string to work on.
See also:
addQuotes
void KMime::setFallbackCharEncoding ( const QString &  fallbackCharEnc  ) 

Set the fallback charset to use when decoding RFC2047-encoded headers.

If decoding according to the RFC fails, then the fallback encoding is used instead.

Parameters:
fallbackCharEnc Name of fallback character encoding to use.
Since:
4.5
void KMime::setUseOutlookAttachmentEncoding ( bool  violateStandard  ) 

Set whether or not to use outlook compatible attachment filename encoding.

Outlook fails to properly adhere to the RFC2322 standard for parametrized header fields, and instead is only able to read and write attachment filenames encoded in RFC2047-style. This will create mails that are not standards-compliant!

Parameters:
violateStandard Whether or not to use outlook-compatible attachment filename encodings.
Since:
4.5
QByteArray KMime::unfoldHeader ( const QByteArray &  header  ) 

Unfolds the given header if necessary.

Parameters:
header The header to unfold.
QByteArray KMime::uniqueString (  ) 

Uses current time, pid and random numbers to construct a string that aims to be unique on a per-host basis (ie.

for the local part of a message-id or for multipart boundaries.

Returns:
the unique string.
See also:
multiPartBoundary
bool KMime::useOutlookAttachmentEncoding (  ) 

Retrieve whether or not to use outlook compatible encodings for attachments.


Variable Documentation

const uchar KMime::aTextMap[16]
Initial value:
 {
  0x00, 0x00, 0x00, 0x00,
  0x5F, 0x35, 0xFF, 0xC5,
  0x7F, 0xFF, 0xFF, 0xE3,
  0xFF, 0xFF, 0xFF, 0xFE
}

Definition at line 158 of file kmime_util.cpp.

const uchar KMime::eTextMap[16]
Initial value:
 {
  0x00, 0x00, 0x00, 0x00,
  0x40, 0x35, 0xFF, 0xC0,
  0x7F, 0xFF, 0xFF, 0xE0,
  0x7F, 0xFF, 0xFF, 0xE0
}

Definition at line 174 of file kmime_util.cpp.

const uchar KMime::specialsMap[16]
Initial value:
 {
  0x00, 0x00, 0x00, 0x00, 
  0x20, 0xCA, 0x00, 0x3A, 
  0x80, 0x00, 0x00, 0x1C, 
  0x00, 0x00, 0x00, 0x00  
}

Definition at line 142 of file kmime_util.cpp.

const uchar KMime::tSpecialsMap[16]
Initial value:
 {
  0x00, 0x00, 0x00, 0x00, 
  0x20, 0xC9, 0x00, 0x3F, 
  0x80, 0x00, 0x00, 0x1C, 
  0x00, 0x00, 0x00, 0x00  
}

Definition at line 150 of file kmime_util.cpp.

const uchar KMime::tTextMap[16]
Initial value:
 {
  0x00, 0x00, 0x00, 0x00,
  0x5F, 0x36, 0xFF, 0xC0,
  0x7F, 0xFF, 0xFF, 0xE3,
  0xFF, 0xFF, 0xFF, 0xFE
}

Definition at line 166 of file kmime_util.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
  •   contact
  •   kmime
  • kabc
  • kblog
  • kcal
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  •   richtextbuilders
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Generated for KDE-PIM Libraries by doxygen 1.7.1
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