MessageCore::StringUtil

MessageCore::StringUtil Namespace Reference

Enumerations

enum  AddressMode : uint8_t { ExpandableAddresses , FullAddresses }
 
enum  Display : uint8_t { DisplayNameOnly , DisplayFullAddress }
 
enum  Link : uint8_t { 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 493 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 380 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 684 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 720 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 729 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 481 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 469 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 402 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 111 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 633 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 738 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 297 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 507 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 391 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 159 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 314 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 351 of file stringutil.cpp.

◆ removeTrailingSpace()

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

Definition at line 35 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 754 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 746 of file stringutil.cpp.

◆ setEncodingFile()

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

Definition at line 819 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 527 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 280 of file stringutil.cpp.

◆ splitLine()

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

Definition at line 48 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 785 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 220 of file stringutil.cpp.

This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 16:59:13 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.