KContacts

impp.h
1/*
2 This file is part of libkabc.
3 SPDX-FileCopyrightText: 2015-2019 Laurent Montel <montel@kde.org>
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
18class ImppTest;
19
20namespace KContacts
21{
22class 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 */
31class 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
46public:
47 Impp();
48 Impp(const Impp &other);
49 Impp(const QUrl &address);
50
51 ~Impp();
52
53 typedef QList<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 Q_REQUIRED_RESULT bool operator==(const Impp &other) const;
88 Q_REQUIRED_RESULT bool operator!=(const Impp &other) const;
89
90 Impp &operator=(const Impp &other);
91
92 Q_REQUIRED_RESULT QString toString() const;
93
94 /**
95 * Returns a translated name of the given IM service.
96 * @since 5.12
97 */
98 static QString serviceLabel(const QString &serviceType);
99 /**
100 * Returns an icon name representing the given IM service.
101 * @since 5.12
102 */
103 static QString serviceIcon(const QString &serviceType);
104 /**
105 * List all known service types.
106 * Don't use these strings directly for display, instead use serviceLabel and serviceIcon.
107 * @since 5.12
108 */
109 static QList<QString> serviceTypes();
110
111private:
112 // exported for ImppTest
113 void setParams(const ParameterMap &params);
114 Q_REQUIRED_RESULT ParameterMap params() const;
115
116 class Private;
118};
119
120KCONTACTS_EXPORT QDataStream &operator<<(QDataStream &stream, const Impp &object);
121
122KCONTACTS_EXPORT QDataStream &operator>>(QDataStream &stream, Impp &object);
123}
124
125Q_DECLARE_TYPEINFO(KContacts::Impp, Q_RELOCATABLE_TYPE);
126
127#endif // IMPP_H
Class that holds a IMPP for a contact.
Definition impp.h:32
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Oct 4 2024 12:03:16 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.