KContacts

impp.h
1 /*
2  This file is part of libkabc.
3  SPDX-FileCopyrightText: 2015-2019 Laurent Montel <[email protected]>
4 
5  SPDX-License-Identifier: LGPL-2.0-or-later
6 */
7 
8 #ifndef IMPP_H
9 #define IMPP_H
10 
11 #include "kcontacts_export.h"
12 
13 #include <QMap>
14 #include <QMetaType>
15 #include <QSharedDataPointer>
16 #include <QString>
17 
18 namespace KContacts
19 {
20 /** @short Class that holds a IMPP for a contact.
21  *
22  * IMPP stands for "Instant Messaging and Presence Protocol". This field is defined
23  * in the vCard 3.0 extension RFC 4770 and is part of vCard 4.0 (RFC 6350).
24  *
25  * @since 4.14.5
26  */
27 class KCONTACTS_EXPORT Impp
28 {
29  Q_GADGET
30  Q_PROPERTY(bool isValid READ isValid)
31  Q_PROPERTY(QUrl address READ address WRITE setAddress)
32  Q_PROPERTY(bool isPreferred READ isPreferred WRITE setPreferred)
33  Q_PROPERTY(QString serviceType READ serviceType)
34  Q_PROPERTY(QString serviceLabel READ serviceLabel)
35  Q_PROPERTY(QString serviceIcon READ serviceIcon)
36 
37  friend KCONTACTS_EXPORT QDataStream &operator<<(QDataStream &, const Impp &);
38  friend KCONTACTS_EXPORT QDataStream &operator>>(QDataStream &, Impp &);
39 
40 public:
41  Impp();
42  Impp(const Impp &other);
43  Impp(const QUrl &address);
44 
45  ~Impp();
46 
47  typedef QVector<Impp> List;
48  Q_REQUIRED_RESULT bool isValid() const;
49 
50  void setAddress(const QUrl &address);
51  Q_REQUIRED_RESULT QUrl address() const;
52 
53  /**
54  * Returns the messaging service this address is for.
55  * This is equivalent to address().scheme().
56  * @since 5.12
57  */
58  QString serviceType() const;
59  /**
60  * Returns a translated label for the service type.
61  * @since 5.12
62  */
63  QString serviceLabel() const;
64  /**
65  * Returns the name of an icon representing the service type.
66  * @since 5.12
67  */
68  QString serviceIcon() const;
69 
70  /**
71  * Returns whether this is the preferred messaging address.
72  * @since 5.12
73  */
74  bool isPreferred() const;
75  /**
76  * Sets that this is the preferred messaging address.
77  * @since 5.12
78  */
79  void setPreferred(bool preferred);
80 
81  void setParameters(const QMap<QString, QStringList> &params);
82  Q_REQUIRED_RESULT QMap<QString, QStringList> parameters() const;
83 
84  Q_REQUIRED_RESULT bool operator==(const Impp &other) const;
85  Q_REQUIRED_RESULT bool operator!=(const Impp &other) const;
86 
87  Impp &operator=(const Impp &other);
88 
89  Q_REQUIRED_RESULT QString toString() const;
90 
91  /**
92  * Returns a translated name of the given IM service.
93  * @since 5.12
94  */
95  static QString serviceLabel(const QString &serviceType);
96  /**
97  * Returns an icon name representing the given IM service.
98  * @since 5.12
99  */
100  static QString serviceIcon(const QString &serviceType);
101  /**
102  * List all known service types.
103  * Don't use these strings directly for display, instead use serviceLabel and serviceIcon.
104  * @since 5.12
105  */
106  static QVector<QString> serviceTypes();
107 
108 private:
109  class Private;
111 };
112 
113 KCONTACTS_EXPORT QDataStream &operator<<(QDataStream &stream, const Impp &object);
114 
115 KCONTACTS_EXPORT QDataStream &operator>>(QDataStream &stream, Impp &object);
116 }
117 
118 Q_DECLARE_METATYPE(KContacts::Impp)
119 Q_DECLARE_TYPEINFO(KContacts::Impp, Q_MOVABLE_TYPE);
120 #endif // IMPP_H
QDataStream & operator>>(QDataStream &in, KDateTime::Spec &spec)
Class that holds a IMPP for a contact.
Definition: impp.h:27
QDataStream & operator<<(QDataStream &out, const KDateTime::Spec &spec)
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Mon Sep 20 2021 22:56:07 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.