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)
 
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)
 
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::Types::Mailbox::List &mailboxList, Display display, const QString &cssStyle, Link link, AddressMode expandable, const QString &fieldName, int collapseNumber)
 
MESSAGECORE_EXPORT QString emailAddrAsAnchor (const QList< KMime::Types::Mailbox > &mailboxList, 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)
 
QList< 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

◆ AddressMode

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

Definition at line 108 of file stringutil.h.

◆ Display

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 92 of file stringutil.h.

◆ Link

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

Definition at line 100 of file stringutil.h.

Function Documentation

◆ addressIsInAddressList()

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

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

Definition at line 494 of file stringutil.cpp.

◆ asSendableString()

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

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

Definition at line 382 of file stringutil.cpp.

◆ cleanFileName()

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

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

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

Definition at line 685 of file stringutil.cpp.

◆ cleanSubject() [1/2]

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

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

Definition at line 721 of file stringutil.cpp.

◆ cleanSubject() [2/2]

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

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 730 of file stringutil.cpp.

◆ emailAddrAsAnchor() [1/4]

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 )
nodiscard

Same as above method, only for AddressList headers.

Definition at line 482 of file stringutil.cpp.

◆ emailAddrAsAnchor() [2/4]

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 )
nodiscard

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 470 of file stringutil.cpp.

◆ emailAddrAsAnchor() [3/4]

QString MessageCore::StringUtil::emailAddrAsAnchor ( const KMime::Types::Mailbox::List & mailboxList,
Display display,
const QString & cssStyle,
Link link,
AddressMode expandable,
const QString & fieldName,
int collapseNumber )

Definition at line 404 of file stringutil.cpp.

◆ emailAddrAsAnchor() [4/4]

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

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

◆ flushPart()

static bool MessageCore::StringUtil::flushPart ( QString & msg,
QStringList & textParts,
const QString & indent,
int maxLength )
static

Definition at line 113 of file stringutil.cpp.

◆ formatQuotePrefix()

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

Convert quote wildcards into the final quote prefix.

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

Definition at line 634 of file stringutil.cpp.

◆ forwardSubject()

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

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

Definition at line 739 of file stringutil.cpp.

◆ generateMessageId()

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

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 299 of file stringutil.cpp.

◆ guessEmailAddressFromLoginName()

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

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

Definition at line 508 of file stringutil.cpp.

◆ headerAsSendableString()

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

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

Definition at line 393 of file stringutil.cpp.

◆ parseMailtoUrl()

MESSAGECORE_EXPORT QList< QPair< QString, QString > > MessageCore::StringUtil::parseMailtoUrl ( const QUrl & url)
nodiscard

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

Definition at line 161 of file stringutil.cpp.

◆ quoteHtmlChars()

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

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 316 of file stringutil.cpp.

◆ removePrivateHeaderFields()

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 353 of file stringutil.cpp.

◆ removeTrailingSpace()

static void MessageCore::StringUtil::removeTrailingSpace ( QString & line)
static

Definition at line 37 of file stringutil.cpp.

◆ replacePrefixes()

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

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 755 of file stringutil.cpp.

◆ replySubject()

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

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

Definition at line 747 of file stringutil.cpp.

◆ setEncodingFile()

MESSAGECORE_EXPORT void MessageCore::StringUtil::setEncodingFile ( QUrl & url,
const QString & encoding )

Definition at line 820 of file stringutil.cpp.

◆ smartQuote()

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

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 528 of file stringutil.cpp.

◆ splitAddressField()

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

Splits the given address list text into separate addresses.

Definition at line 282 of file stringutil.cpp.

◆ splitLine()

static QString MessageCore::StringUtil::splitLine ( QString & line)
static

Definition at line 50 of file stringutil.cpp.

◆ stripOffPrefixes()

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

Removes the forward and reply marks (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 786 of file stringutil.cpp.

◆ stripSignature()

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

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 222 of file stringutil.cpp.

This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Jul 12 2024 11:49:56 by doxygen 1.11.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.