Warning, file /pim/kmime/src/kmime_types.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* -*- c++ -*- 0002 kmime_header_types.h 0003 0004 KMime, the KDE Internet mail/usenet news message library. 0005 SPDX-FileCopyrightText: 2001-2002 Marc Mutz <mutz@kde.org> 0006 0007 SPDX-License-Identifier: LGPL-2.0-or-later 0008 */ 0009 0010 #pragma once 0011 0012 #include <QString> 0013 #include <QVector> 0014 0015 #include "kmime_export.h" 0016 0017 namespace KMime 0018 { 0019 0020 namespace Types 0021 { 0022 0023 struct KMIME_EXPORT AddrSpec { 0024 QString asString() const; 0025 /*! This is the same as asString(), except it decodes IDNs for display */ 0026 QString asPrettyString() const; 0027 bool isEmpty() const; 0028 QString localPart; 0029 QString domain; 0030 }; 0031 using AddrSpecList = QVector<AddrSpec>; 0032 0033 /** 0034 Represents an (email address, display name) pair according RFC 2822, 0035 section 3.4. 0036 */ 0037 class KMIME_EXPORT Mailbox 0038 { 0039 public: 0040 typedef QVector<Mailbox> List; 0041 0042 /** 0043 Returns a string representation of the email address, without 0044 the angle brackets. 0045 */ 0046 Q_REQUIRED_RESULT QByteArray address() const; 0047 0048 Q_REQUIRED_RESULT AddrSpec addrSpec() const; 0049 0050 /** 0051 Returns the display name. 0052 */ 0053 Q_REQUIRED_RESULT QString name() const; 0054 0055 /** 0056 Sets the email address. 0057 */ 0058 void setAddress(const AddrSpec &addr); 0059 0060 /** 0061 Sets the email address. 0062 */ 0063 void setAddress(const QByteArray &addr); 0064 0065 /** 0066 Sets the name. 0067 */ 0068 void setName(const QString &name); 0069 0070 /** 0071 Sets the name based on a 7bit encoded string. 0072 */ 0073 void setNameFrom7Bit(const QByteArray &name, 0074 const QByteArray &defaultCharset = QByteArray()); 0075 0076 /** 0077 Returns true if this mailbox has an address. 0078 */ 0079 Q_REQUIRED_RESULT bool hasAddress() const; 0080 0081 /** 0082 Returns true if this mailbox has a display name. 0083 */ 0084 Q_REQUIRED_RESULT bool hasName() const; 0085 0086 /** 0087 * Describes how display names should be quoted 0088 * @since 4.5 0089 */ 0090 //AK_REVIEW: remove this enum 0091 enum Quoting { 0092 QuoteNever, ///< Don't quote display names at all. Such an unquoted display name can not 0093 /// be machine-processed anymore in some cases, for example when it contains 0094 /// commas, like in "Lastname, Firstname". 0095 QuoteWhenNecessary, ///< Only quote display names when they contain characters that need to be 0096 /// quoted, like commas or quote signs. 0097 QuoteAlways ///< Always quote the display name 0098 }; 0099 0100 /** 0101 * Overloaded method that gives more control over the quoting of the display name 0102 * @param quoting describes how the display name should be quoted 0103 * @since 4.5 0104 */ 0105 Q_REQUIRED_RESULT QString prettyAddress(Quoting quoting = QuoteNever) const; 0106 0107 /** 0108 Parses the given unicode string. 0109 */ 0110 void fromUnicodeString(const QString &s); 0111 0112 /** 0113 Parses the given 7bit encoded string. 0114 */ 0115 void from7BitString(const QByteArray &s); 0116 0117 /** 0118 Returns a 7bit transport encoded representation of this mailbox. 0119 0120 @param encCharset The charset used for encoding. 0121 */ 0122 Q_REQUIRED_RESULT QByteArray as7BitString(const QByteArray &encCharset) const; 0123 0124 /** 0125 * Returns a list of mailboxes from an unicode string. 0126 * 0127 * @since 5.14 0128 */ 0129 Q_REQUIRED_RESULT static QVector<Mailbox> listFromUnicodeString(const QString &s); 0130 0131 /** 0132 * Returns a list of mailboxes from an encoded 7bit string. 0133 * 0134 * @since 5.14 0135 */ 0136 Q_REQUIRED_RESULT static QVector<Mailbox> listFrom7BitString(const QByteArray &s); 0137 0138 /** 0139 * Returns a unicode string representing the given list of mailboxes. 0140 * 0141 * @since 5.15 0142 */ 0143 Q_REQUIRED_RESULT static QString listToUnicodeString(const QVector<Mailbox> &mailboxes); 0144 0145 private: 0146 QString mDisplayName; 0147 AddrSpec mAddrSpec; 0148 }; 0149 0150 typedef QVector<Mailbox> MailboxList; 0151 0152 struct KMIME_EXPORT Address { 0153 QString displayName; 0154 MailboxList mailboxList; 0155 }; 0156 typedef QVector<Address> AddressList; 0157 0158 } // namespace KMime::Types 0159 0160 } // namespace KMime 0161 0162 Q_DECLARE_TYPEINFO(KMime::Types::Mailbox, Q_MOVABLE_TYPE); 0163 Q_DECLARE_TYPEINFO(KMime::Types::Address, Q_MOVABLE_TYPE); 0164 Q_DECLARE_TYPEINFO(KMime::Types::AddrSpec, Q_MOVABLE_TYPE); 0165 0166