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 class ImppTest;
19 
20 namespace KContacts
21 {
22 class ParameterMap;
23 
24 /** @short Class that holds a IMPP for a contact.
25  *
26  * IMPP stands for "Instant Messaging and Presence Protocol". This field is defined
27  * in the vCard 3.0 extension RFC 4770 and is part of vCard 4.0 (RFC 6350).
28  *
29  * @since 4.14.5
30  */
31 class KCONTACTS_EXPORT Impp
32 {
33  Q_GADGET
34  Q_PROPERTY(bool isValid READ isValid)
35  Q_PROPERTY(QUrl address READ address WRITE setAddress)
36  Q_PROPERTY(bool isPreferred READ isPreferred WRITE setPreferred)
37  Q_PROPERTY(QString serviceType READ serviceType)
38  Q_PROPERTY(QString serviceLabel READ serviceLabel)
39  Q_PROPERTY(QString serviceIcon READ serviceIcon)
40 
41  friend KCONTACTS_EXPORT QDataStream &operator<<(QDataStream &, const Impp &);
42  friend KCONTACTS_EXPORT QDataStream &operator>>(QDataStream &, Impp &);
43  friend class VCardTool;
44  friend class ::ImppTest;
45 
46 public:
47  Impp();
48  Impp(const Impp &other);
49  Impp(const QUrl &address);
50 
51  ~Impp();
52 
53  typedef QVector<Impp> List;
54  Q_REQUIRED_RESULT bool isValid() const;
55 
56  void setAddress(const QUrl &address);
57  Q_REQUIRED_RESULT QUrl address() const;
58 
59  /**
60  * Returns the messaging service this address is for.
61  * This is equivalent to address().scheme().
62  * @since 5.12
63  */
64  QString serviceType() const;
65  /**
66  * Returns a translated label for the service type.
67  * @since 5.12
68  */
69  QString serviceLabel() const;
70  /**
71  * Returns the name of an icon representing the service type.
72  * @since 5.12
73  */
74  QString serviceIcon() const;
75 
76  /**
77  * Returns whether this is the preferred messaging address.
78  * @since 5.12
79  */
80  bool isPreferred() const;
81  /**
82  * Sets that this is the preferred messaging address.
83  * @since 5.12
84  */
85  void setPreferred(bool preferred);
86 
87 #if KCONTACTS_ENABLE_DEPRECATED_SINCE(5, 88)
88  /**
89  * @deprecated Since 5.88 for lack of usage
90  */
91  KCONTACTS_DEPRECATED_VERSION(5, 88, "For lack of usage.")
92  void setParameters(const QMap<QString, QStringList> &params);
93 #endif
94 
95 #if KCONTACTS_ENABLE_DEPRECATED_SINCE(5, 88)
96  /**
97  * @deprecated Since 5.88 for lack of usage
98  */
99  Q_REQUIRED_RESULT
100  KCONTACTS_DEPRECATED_VERSION(5, 88, "For lack of usage.")
101  QMap<QString, QStringList> parameters() const;
102 #endif
103 
104  Q_REQUIRED_RESULT bool operator==(const Impp &other) const;
105  Q_REQUIRED_RESULT bool operator!=(const Impp &other) const;
106 
107  Impp &operator=(const Impp &other);
108 
109  Q_REQUIRED_RESULT QString toString() const;
110 
111  /**
112  * Returns a translated name of the given IM service.
113  * @since 5.12
114  */
115  static QString serviceLabel(const QString &serviceType);
116  /**
117  * Returns an icon name representing the given IM service.
118  * @since 5.12
119  */
120  static QString serviceIcon(const QString &serviceType);
121  /**
122  * List all known service types.
123  * Don't use these strings directly for display, instead use serviceLabel and serviceIcon.
124  * @since 5.12
125  */
126  static QVector<QString> serviceTypes();
127 
128 private:
129  // exported for ImppTest
130  void setParams(const ParameterMap &params);
131  Q_REQUIRED_RESULT ParameterMap params() const;
132 
133  class Private;
135 };
136 
137 KCONTACTS_EXPORT QDataStream &operator<<(QDataStream &stream, const Impp &object);
138 
139 KCONTACTS_EXPORT QDataStream &operator>>(QDataStream &stream, Impp &object);
140 }
141 
142 Q_DECLARE_METATYPE(KContacts::Impp)
143 Q_DECLARE_TYPEINFO(KContacts::Impp, Q_MOVABLE_TYPE);
144 #endif // IMPP_H
KCALENDARCORE_EXPORT QDataStream & operator<<(QDataStream &out, const KCalendarCore::Alarm::Ptr &)
KCALENDARCORE_EXPORT QDataStream & operator>>(QDataStream &in, const KCalendarCore::Alarm::Ptr &)
Class that holds a IMPP for a contact.
Definition: impp.h:31
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Sun Dec 10 2023 03:49:09 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.