MessageCore::StringUtil
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 93 of file stringutil.h.
Used to determine if the address should be a link or not.
Definition at line 98 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 488 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 376 of file stringutil.cpp.
Cleans a filename by replacing characters not allowed or wanted on the filesystem e.g.
':', '/', '\' with '_'
Definition at line 679 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 715 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 724 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 464 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 476 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
-
wildString the string to be converted fromDisplayString displayable string of the from email address
Definition at line 628 of file stringutil.cpp.
MESSAGECORE_EXPORT QString MessageCore::StringUtil::forwardSubject | ( | KMime::Message * | msg | ) |
Return this mails subject, formatted for "forward" mails.
Definition at line 729 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 293 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 502 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 387 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 162 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 310 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 347 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 745 of file stringutil.cpp.
MESSAGECORE_EXPORT QString MessageCore::StringUtil::replySubject | ( | KMime::Message * | msg | ) |
Return this mails subject, formatted for "reply" mails.
Definition at line 737 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
-
message The string which it to be relayouted maxLineLength reformat text to be this amount of columns at maximum. Note that this also includes the trailing
!
Definition at line 522 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 276 of file stringutil.cpp.
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 776 of file stringutil.cpp.
Strips the signature blocks from a message text.
"-- " is considered as a signature block separator.
- Parameters
-
message The message to remove the signature block from.
Definition at line 216 of file stringutil.cpp.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Thu Mar 4 2021 23:15:13 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.