• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdepimlibs-4.8.3 API Reference
  • KDE Home
  • Contact Us
 

KMIME Library

Classes | Functions | Variables
KMime Namespace Reference

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 , class CharType , class CharConverterType , class StringConverterType , class ToString >
void addQuotes_impl (StringType &str, bool forceQuotes)
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, QByteArray &usedCS, const QByteArray &defaultCS=QByteArray(), bool forceCS=false)
QString decodeRFC2047String (const QByteArray &src)
QString decodeRFC2231String (const QByteArray &src, QByteArray &usedCS, const QByteArray &defaultCS=QByteArray(), bool forceCS=false)
QString decodeRFC2231String (const QByteArray &src)
QByteArray encodeRFC2047Sentence (const QString &src, const QByteArray &charset)
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)
bool hasAttachment (Content *content)
static uchar highNibble (uchar ch)
int indexOfHeader (const QByteArray &src, const QByteArray &name, int &end, int &dataBegin, bool *folded)
static bool isCryptoPart (Content *content)
bool isEncrypted (Message *message)
bool isInvitation (Content *content)
bool isSigned (Message *message)
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 (QByteArray &str)
void removeQuots (QString &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
static const char * reservedCharacters = "\"()<>@,.;:\\[]="
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:
strus-ascii string to work on.
forceQuotesif true, always add quote characters.

Definition at line 839 of file kmime_util.cpp.

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

Overloaded method, behaves same as the above.

Since:
4.5

Definition at line 844 of file kmime_util.cpp.

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.nosp@m.@dom.nosp@m.ain.c.nosp@m.om. 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.m.nosp@m.itci.nosp@m.v@att.nosp@m.acke.nosp@m.r.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.m.nosp@m.itci.nosp@m.v@att.nosp@m.acke.nosp@m.r.com again.

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

Parameters:
inputthe 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

Definition at line 849 of file kmime_util.cpp.

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:
valueis 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

Definition at line 60 of file kmime_util.cpp.

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

Definition at line 73 of file kmime_util.cpp.

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:
ssource string containing CRLF's
Returns:
the string with CRLF's substitued for LF's
See also:
CRLFtoLF(const char*) LFtoCRLF

Definition at line 764 of file kmime_util.cpp.

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:
ssource string containing CRLF's
Returns:
the string with CRLF's substitued for LF's
See also:
CRLFtoLF(const QCString&) LFtoCRLF

Definition at line 771 of file kmime_util.cpp.

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:
srcsource string.
usedCSthe detected charset is returned here
defaultCSthe charset to use in case the detected one isn't known to us.
forceCSforce the use of the default charset.
Returns:
the decoded string.

Definition at line 204 of file kmime_util.cpp.

QString KMime::decodeRFC2047String ( const QByteArray &  src)

Decode string src according to RFC2047 (ie.

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

Parameters:
srcsource string.
Returns:
the decoded string.

Definition at line 260 of file kmime_util.cpp.

QString KMime::decodeRFC2231String ( const QByteArray &  src,
QByteArray &  usedCS,
const QByteArray &  defaultCS = QByteArray(),
bool  forceCS = false 
)

Decodes string src according to RFC2231.

Parameters:
srcsource string.
usedCsthe detected charset is returned here
defaultCSthe charset to use in case the detected one isn't known to us.
forceCSforce the use of the default charset.
Returns:
the decoded string.

Definition at line 484 of file kmime_util.cpp.

QString KMime::decodeRFC2231String ( const QByteArray &  src)

Decode string src according to RFC2231 (ie.

the charset'lang'encoded construct).

Parameters:
srcsource string.
Returns:
the decoded string.

Definition at line 526 of file kmime_util.cpp.

QByteArray KMime::encodeRFC2047String ( const QString &  src,
const QByteArray &  charset,
bool  addressHeader = false,
bool  allow8bitHeaders = false 
)

Encodes string src according to RFC2047 using charset charset.

This function also makes commas, quotes and other characters part of the encoded name, for example the string "Jöhn Döe" <john@.nosp@m.exam.nosp@m.ple.c.nosp@m.om"> would be encoded as <encoded word for "Jöhn Döe"> john@.nosp@m.exam.nosp@m.ple.c.nosp@m.om, i.e. the opening and closing quote mark would be part of the encoded word. Therefore don't use this function for input strings that contain semantically meaningful characters, like the quoting marks in this example.

Parameters:
srcsource string.
charsetcharset to use. If it can't encode the string, UTF-8 will be used instead.
addressHeaderif this flag is true, all special chars like <,>,[,],... will be encoded, too.
allow8bitHeadersif this flag is true, 8Bit headers are allowed.
Returns:
the encoded string.

Definition at line 268 of file kmime_util.cpp.

QByteArray KMime::encodeRFC2231String ( const QString &  src,
const QByteArray &  charset 
)

Encodes string src according to RFC2231 using charset charset.

Parameters:
srcsource string.
charsetcharset to use.
Returns:
the encoded string.

Definition at line 428 of file kmime_util.cpp.

QList< KMime::Headers::contentEncoding > KMime::encodingsForData ( const QByteArray &  data)

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

@ since 4.4

Definition at line 110 of file kmime_util.cpp.

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:
srcthe source string.
namethe 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.

Definition at line 703 of file kmime_util.cpp.

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:
srcthe source string.
namethe name of the header to search for.
Returns:
all instances of the header name in src
Since:
4.2

Definition at line 726 of file kmime_util.cpp.

QString KMime::fallbackCharEncoding ( )

Retrieve 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

Definition at line 188 of file kmime_util.cpp.

bool KMime::hasAttachment ( Content *  content)

Returns whether or not the given MIME node contains an attachment part.

This function will recursively parse the MIME tree looking for a suitable attachment and return true if one is found.

Definition at line 931 of file kmime_util.cpp.

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:
chis an unsigned character containing the 8-bit input value.

Definition at line 67 of file kmime_codec_qp.cpp.

bool KMime::isEncrypted ( Message *  message)

Returns whether or not the given message is partly or fully encrypted.

Since:
4.6

Definition at line 978 of file kmime_util.cpp.

bool KMime::isInvitation ( Content *  content)

Returns whether or not the given MIME content is an invitation message of the iTIP protocol.

Since:
4.6

Definition at line 996 of file kmime_util.cpp.

bool KMime::isSigned ( Message *  message)

Returns whether or not the given message is partly or fully signed.

Since:
4.6

Definition at line 958 of file kmime_util.cpp.

bool KMime::isUsAscii ( const QString &  s)

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

Parameters:
s

Definition at line 86 of file kmime_util.cpp.

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:
chis 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:
ssource string containing CRLF's
Returns:
the string with CRLF's substitued for LF's
See also:
CRLFtoLF(const QCString&) LFtoCRLF

Definition at line 777 of file kmime_util.cpp.

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:
chis 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

Definition at line 559 of file kmime_util.cpp.

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?

Definition at line 97 of file kmime_util.cpp.

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 :(

Definition at line 896 of file kmime_util.cpp.

void KMime::removeQuots ( QByteArray &  str)

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

backslash-escaped characters)

Parameters:
strthe string to work on.
See also:
addQuotes

Definition at line 808 of file kmime_util.cpp.

void KMime::removeQuots ( QString &  str)

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

backslash-escaped characters)

Parameters:
strthe string to work on.
See also:
addQuotes

Definition at line 813 of file kmime_util.cpp.

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:
fallbackCharEncName of fallback character encoding to use.
Since:
4.5

Definition at line 183 of file kmime_util.cpp.

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:
violateStandardWhether or not to use outlook-compatible attachment filename encodings.
Since:
4.5

Definition at line 193 of file kmime_util.cpp.

QByteArray KMime::unfoldHeader ( const QByteArray &  header)

Unfolds the given header if necessary.

Parameters:
headerThe header to unfold.

Definition at line 564 of file kmime_util.cpp.

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

Definition at line 532 of file kmime_util.cpp.

bool KMime::useOutlookAttachmentEncoding ( )

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

Definition at line 198 of file kmime_util.cpp.


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 160 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 176 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 144 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 152 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 168 of file kmime_util.cpp.

This file is part of the KDE documentation.
Documentation copyright © 1996-2012 The KDE developers.
Generated on Mon Apr 30 2012 21:48:41 by doxygen 1.8.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KMIME Library

Skip menu "KMIME Library"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • Related Pages

kdepimlibs-4.8.3 API Reference

Skip menu "kdepimlibs-4.8.3 API Reference"
  • akonadi
  •   contact
  •   kmime
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  •   richtextbuilders
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal