MessageCore::StringUtil

MessageCore::StringUtil Namespace Reference

Enumerations

enum  AddressMode { ExpandableAddresses, FullAddresses }
 
enum  Display { DisplayNameOnly, DisplayFullAddress }
 
enum  Link { ShowLink, HideLink }
 

Functions

bool addressIsInAddressList (const QString &address, const QStringList &addresses)
 
QByteArray asSendableString (const KMime::Message::Ptr &message)
 
QString cleanFileName (const QString &fileName)
 
QString cleanSubject (KMime::Message *msg)
 
QString cleanSubject (KMime::Message *msg, const QStringList &prefixRegExps, bool replace, const QString &newPrefix)
 
MESSAGECORE_EXPORT QString emailAddrAsAnchor (const QVector< KMime::Types::Mailbox > &mailboxList, Display display=DisplayNameOnly, const QString &cssStyle=QString(), Link link=ShowLink, AddressMode expandable=FullAddresses, const QString &fieldName=QString(), int collapseNumber=4)
 
QString emailAddrAsAnchor (const KMime::Types::Mailbox::List &mailboxList, Display display, const QString &cssStyle, Link link, AddressMode expandable, const QString &fieldName, int collapseNumber)
 
QString emailAddrAsAnchor (const KMime::Headers::Generics::MailboxList *mailboxList, Display display=DisplayNameOnly, const QString &cssStyle=QString(), Link link=ShowLink, AddressMode expandable=FullAddresses, const QString &fieldName=QString(), int collapseNumber=4)
 
QString emailAddrAsAnchor (const KMime::Headers::Generics::AddressList *addressList, Display display=DisplayNameOnly, const QString &cssStyle=QString(), Link link=ShowLink, AddressMode expandable=FullAddresses, const QString &fieldName=QString(), int collapseNumber=4)
 
static bool flushPart (QString &msg, QStringList &textParts, const QString &indent, int maxLength)
 
QString formatQuotePrefix (const QString &wildString, const QString &fromDisplayString)
 
QString forwardSubject (KMime::Message *msg)
 
QString generateMessageId (const QString &address, const QString &suffix)
 
QString guessEmailAddressFromLoginName (const QString &userName)
 
QByteArray headerAsSendableString (const KMime::Message::Ptr &message)
 
QVector< QPair< QString, QString > > parseMailtoUrl (const QUrl &url)
 
QString quoteHtmlChars (const QString &text, bool removeLineBreaks=false)
 
void removePrivateHeaderFields (const KMime::Message::Ptr &message, bool cleanUpHeader=true)
 
static void removeTrailingSpace (QString &line)
 
QString replacePrefixes (const QString &str, const QStringList &prefixRegExps, bool replace, const QString &newPrefix)
 
QString replySubject (KMime::Message *msg)
 
void setEncodingFile (QUrl &url, const QString &encoding)
 
QString smartQuote (const QString &message, int maxLineLength)
 
AddressList splitAddressField (const QByteArray &text)
 
static QString splitLine (QString &line)
 
QString stripOffPrefixes (const QString &subject)
 
QString stripSignature (const QString &message)
 

Detailed Description

This namespace contain helper functions for string manipulation.

Enumeration Type Documentation

Used to determine if the address field should be expandable/collapsable.

Definition at line 103 of file stringutil.h.

Used to determine if the visible part of the anchor contains only the name part and not the given emailAddr or the full address.

Definition at line 87 of file stringutil.h.

Used to determine if the address should be a link or not.

Definition at line 95 of file stringutil.h.

Function Documentation

MESSAGECORE_EXPORT bool MessageCore::StringUtil::addressIsInAddressList ( const QString address,
const QStringList addresses 
)

Returns true if the given address is contained in the given address list.

Definition at line 465 of file stringutil.cpp.

MESSAGECORE_EXPORT QByteArray MessageCore::StringUtil::asSendableString ( const KMime::Message::Ptr originalMessage)

Returns the message contents with the headers that should not be sent stripped off.

Definition at line 374 of file stringutil.cpp.

MESSAGECORE_EXPORT QString MessageCore::StringUtil::cleanFileName ( const QString fileName)

Cleans a filename by replacing characters not allowed or wanted on the filesystem e.g.

':', '/', '\' with '_'

Definition at line 660 of file stringutil.cpp.

MESSAGECORE_EXPORT QString MessageCore::StringUtil::cleanSubject ( KMime::Message msg)

Return this mails subject, with all "forward" and "reply" prefixes removed.

Definition at line 696 of file stringutil.cpp.

MESSAGECORE_EXPORT QString MessageCore::StringUtil::cleanSubject ( KMime::Message msg,
const QStringList prefixRegExps,
bool  replace,
const QString newPrefix 
)

Check for prefixes prefixRegExps in #subject().

If none is found, newPrefix + ' ' is prepended to the subject and the resulting string is returned. If replace is true, any sequence of whitespace-delimited prefixes at the beginning of #subject() is replaced by newPrefix

Definition at line 702 of file stringutil.cpp.

MESSAGECORE_EXPORT QString MessageCore::StringUtil::emailAddrAsAnchor ( const QVector< KMime::Types::Mailbox > &  mailboxList,
Display  display = DisplayNameOnly,
const QString cssStyle = QString(),
Link  link = ShowLink,
AddressMode  expandable = FullAddresses,
const QString fieldName = QString(),
int  collapseNumber = 4 
)

Same as the above, only for Mailbox::List types.

MESSAGECORE_EXPORT QString MessageCore::StringUtil::emailAddrAsAnchor ( const KMime::Headers::Generics::MailboxList mailboxList,
Display  display = DisplayNameOnly,
const QString cssStyle = QString(),
Link  link = ShowLink,
AddressMode  expandable = FullAddresses,
const QString fieldName = QString(),
int  collapseNumber = 4 
)

Converts the email address(es) to (a) nice HTML mailto: anchor(s).

display determines if only the name part or the entire address should be returned. cssStyle a custom css template. link determines if the result should be a html link or not. expandable determines if a long list of addresses should be expandable or shown in full. fieldName the name that the divs should be based on if expandable is set to ExpanableAddesses. The number of addresses to show before collapsing the rest, if expandable is set to ExpandableAddresses.

Definition at line 453 of file stringutil.cpp.

MESSAGECORE_EXPORT QString MessageCore::StringUtil::emailAddrAsAnchor ( const KMime::Headers::Generics::AddressList addressList,
Display  display,
const QString cssStyle,
Link  link,
AddressMode  expandable,
const QString fieldName,
int  collapseNumber 
)

Same as above method, only for AddressList headers.

Definition at line 459 of file stringutil.cpp.

MESSAGECORE_EXPORT QString MessageCore::StringUtil::formatQuotePrefix ( const QString wildString,
const QString fromDisplayString 
)

Convert quote wildcards into the final quote prefix.

Parameters
wildStringthe string to be converted
fromDisplayStringdisplayable string of the from email address

Definition at line 606 of file stringutil.cpp.

MESSAGECORE_EXPORT QString MessageCore::StringUtil::forwardSubject ( KMime::Message msg)

Return this mails subject, formatted for "forward" mails.

Definition at line 708 of file stringutil.cpp.

MESSAGECORE_EXPORT QString MessageCore::StringUtil::generateMessageId ( const QString address,
const QString suffix 
)

Generates the Message-Id.

It uses either the Message-Id suffix defined by the user or the given email address as suffix. The address must be given as addr-spec as defined in RFC 2822.

Definition at line 291 of file stringutil.cpp.

MESSAGECORE_EXPORT QString MessageCore::StringUtil::guessEmailAddressFromLoginName ( const QString loginName)

Uses the hostname as domain part and tries to determine the real name from the entries in the password file.

Definition at line 480 of file stringutil.cpp.

MESSAGECORE_EXPORT QByteArray MessageCore::StringUtil::headerAsSendableString ( const KMime::Message::Ptr originalMessage)

Return the message header with the headers that should not be sent stripped off.

Definition at line 385 of file stringutil.cpp.

MESSAGECORE_EXPORT QVector< QPair< QString, QString > > MessageCore::StringUtil::parseMailtoUrl ( const QUrl url)

Parses a mailto: url and extracts the information in the QMap (field name as key).

Definition at line 159 of file stringutil.cpp.

MESSAGECORE_EXPORT QString MessageCore::StringUtil::quoteHtmlChars ( const QString text,
bool  removeLineBreaks = false 
)

Quotes the following characters which have a special meaning in HTML: '<' '>' '&' '"'. Additionally '\n' is converted to "<br />" if removeLineBreaks is false.

If removeLineBreaks is true, then '\n' is removed. Last but not least '\r' is removed.

Definition at line 308 of file stringutil.cpp.

MESSAGECORE_EXPORT void MessageCore::StringUtil::removePrivateHeaderFields ( const KMime::Message::Ptr message,
bool  cleanUpHeader = true 
)

Removes all private header fields (e.g.

*Status: and X-KMail-*) from the given message. if cleanUpHeader is false don't remove X-KMail-Identity and X-KMail-Dictionary which is useful when we want restore mail.

Definition at line 345 of file stringutil.cpp.

MESSAGECORE_EXPORT QString MessageCore::StringUtil::replacePrefixes ( const QString str,
const QStringList prefixRegExps,
bool  replace,
const QString newPrefix 
)

Check for prefixes prefixRegExps in str.

If none is found, newPrefix + ' ' is prepended to str and the resulting string is returned. If replace is true, any sequence of whitespace-delimited prefixes at the beginning of str is replaced by newPrefix.

Definition at line 720 of file stringutil.cpp.

MESSAGECORE_EXPORT QString MessageCore::StringUtil::replySubject ( KMime::Message msg)

Return this mails subject, formatted for "reply" mails.

Definition at line 714 of file stringutil.cpp.

MESSAGECORE_EXPORT QString MessageCore::StringUtil::smartQuote ( const QString message,
int  maxLineLength 
)

Relayouts the given string so that the individual lines don't exceed the given maximal length.

As the name of the function implies, it is smart, which means it deals with quoting correctly. This means if a line already starts with quote characters and needs to be broken, the same quote characters are prepended to the next line as well.

This does not add new quote characters in front of every line, that is the responsibility of the caller.

Parameters
messageThe string which it to be relayouted
maxLineLengthreformat text to be this amount of columns at maximum. Note that this also includes the trailing
!

Definition at line 500 of file stringutil.cpp.

MESSAGECORE_EXPORT KMime::Types::AddressList MessageCore::StringUtil::splitAddressField ( const QByteArray text)

Splits the given address list text into separate addresses.

Definition at line 274 of file stringutil.cpp.

MESSAGECORE_EXPORT QString MessageCore::StringUtil::stripOffPrefixes ( const QString subject)

Removes the forward and reply markes (e.g.

Re: or Fwd:) from a subject string. Additional markers to act on can be specified in the MessageCore::GlobalSettings object.

Definition at line 753 of file stringutil.cpp.

MESSAGECORE_EXPORT QString MessageCore::StringUtil::stripSignature ( const QString message)

Strips the signature blocks from a message text.

"-- " is considered as a signature block separator.

Parameters
messageThe message to remove the signature block from.

Definition at line 213 of file stringutil.cpp.

This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Nov 30 2020 23:14:54 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.