KMime

kmime_types.h
1 /* -*- c++ -*-
2  kmime_header_types.h
3 
4  KMime, the KDE Internet mail/usenet news message library.
5  SPDX-FileCopyrightText: 2001-2002 Marc Mutz <[email protected]>
6 
7  SPDX-License-Identifier: LGPL-2.0-or-later
8 */
9 
10 #ifndef __KMIME_TYPES_H__
11 #define __KMIME_TYPES_H__
12 
13 #include <QString>
14 #include <QVector>
15 
16 #include "kmime_export.h"
17 
18 namespace KMime
19 {
20 
21 namespace Types
22 {
23 
24 struct KMIME_EXPORT AddrSpec {
25  QString asString() const;
27  QString asPrettyString() const;
28  bool isEmpty() const;
29  QString localPart;
30  QString domain;
31 };
32 typedef QVector<AddrSpec> AddrSpecList;
33 
38 class KMIME_EXPORT Mailbox
39 {
40 public:
41  typedef QVector<Mailbox> List;
42 
47  Q_REQUIRED_RESULT QByteArray address() const;
48 
49  Q_REQUIRED_RESULT AddrSpec addrSpec() const;
50 
54  Q_REQUIRED_RESULT QString name() const;
55 
59  void setAddress(const AddrSpec &addr);
60 
64  void setAddress(const QByteArray &addr);
65 
69  void setName(const QString &name);
70 
74  void setNameFrom7Bit(const QByteArray &name,
75  const QByteArray &defaultCharset = QByteArray());
76 
80  Q_REQUIRED_RESULT bool hasAddress() const;
81 
85  Q_REQUIRED_RESULT bool hasName() const;
86 
91  //AK_REVIEW: remove this enum
92  enum Quoting {
94  QuoteWhenNecessary,
97  QuoteAlways
99  };
100 
106  Q_REQUIRED_RESULT QString prettyAddress(Quoting quoting = QuoteNever) const;
107 
111  void fromUnicodeString(const QString &s);
112 
116  void from7BitString(const QByteArray &s);
117 
123  Q_REQUIRED_RESULT QByteArray as7BitString(const QByteArray &encCharset) const;
124 
130  Q_REQUIRED_RESULT static QVector<Mailbox> listFromUnicodeString(const QString &s);
131 
137  Q_REQUIRED_RESULT static QVector<Mailbox> listFrom7BitString(const QByteArray &s);
138 
144  Q_REQUIRED_RESULT static QString listToUnicodeString(const QVector<Mailbox> &mailboxes);
145 
146 private:
147  QString mDisplayName;
148  AddrSpec mAddrSpec;
149 };
150 
152 
153 struct KMIME_EXPORT Address {
154  QString displayName;
155  MailboxList mailboxList;
156 };
158 
159 } // namespace KMime::Types
160 
161 } // namespace KMime
162 
163 Q_DECLARE_TYPEINFO(KMime::Types::Mailbox, Q_MOVABLE_TYPE);
164 Q_DECLARE_TYPEINFO(KMime::Types::Address, Q_MOVABLE_TYPE);
165 Q_DECLARE_TYPEINFO(KMime::Types::AddrSpec, Q_MOVABLE_TYPE);
166 
167 #endif // __KMIME_HEADER_PARSING_H__
168 
Represents an (email address, display name) pair according RFC 2822, section 3.4. ...
Definition: kmime_types.h:38
Don&#39;t quote display names at all.
Definition: kmime_types.h:93
Quoting
Describes how display names should be quoted.
Definition: kmime_types.h:92
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Sep 21 2020 23:12:58 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.