| 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 | |
| 18 | class ImppTest; |
| 19 | |
| 20 | namespace KContacts |
| 21 | { |
| 22 | class ParameterMap; |
| 23 | |
| 24 | /*! |
| 25 | * \qmlvaluetype impp |
| 26 | * \inqmlmodule org.kde.contacts |
| 27 | * \nativetype KContacts::Impp |
| 28 | * |
| 29 | * \brief Class that holds a IMPP for a contact. |
| 30 | * |
| 31 | * IMPP stands for "Instant Messaging and Presence Protocol". This field is defined |
| 32 | * in the vCard 3.0 extension RFC 4770 and is part of vCard 4.0 (RFC 6350). |
| 33 | */ |
| 34 | |
| 35 | /*! |
| 36 | * \class KContacts::Impp |
| 37 | * \inheaderfile KContacts/Impp |
| 38 | * \inmodule KContacts |
| 39 | * |
| 40 | * \brief Class that holds a IMPP for a contact. |
| 41 | * |
| 42 | * IMPP stands for "Instant Messaging and Presence Protocol". This field is defined |
| 43 | * in the vCard 3.0 extension RFC 4770 and is part of vCard 4.0 (RFC 6350). |
| 44 | * |
| 45 | * \since 4.14.5 |
| 46 | */ |
| 47 | class KCONTACTS_EXPORT Impp |
| 48 | { |
| 49 | Q_GADGET |
| 50 | |
| 51 | /*! |
| 52 | * \qmlproperty bool impp::isValid |
| 53 | */ |
| 54 | |
| 55 | /*! |
| 56 | * \property KContacts::Impp::isValid |
| 57 | */ |
| 58 | Q_PROPERTY(bool isValid READ isValid) |
| 59 | |
| 60 | /*! |
| 61 | * \qmlproperty url impp::address |
| 62 | */ |
| 63 | |
| 64 | /*! |
| 65 | * \property KContacts::Impp::address |
| 66 | */ |
| 67 | Q_PROPERTY(QUrl address READ address WRITE setAddress) |
| 68 | |
| 69 | /*! |
| 70 | * \qmlproperty bool impp::isPreferred |
| 71 | */ |
| 72 | |
| 73 | /*! |
| 74 | * \property KContacts::Impp::isPreferred |
| 75 | */ |
| 76 | Q_PROPERTY(bool isPreferred READ isPreferred WRITE setPreferred) |
| 77 | |
| 78 | /*! |
| 79 | * \qmlproperty string impp::serviceType |
| 80 | */ |
| 81 | |
| 82 | /*! |
| 83 | * \property KContacts::Impp::serviceType |
| 84 | */ |
| 85 | Q_PROPERTY(QString serviceType READ serviceType) |
| 86 | |
| 87 | /*! |
| 88 | * \qmlproperty string impp::serviceLabel |
| 89 | */ |
| 90 | |
| 91 | /*! |
| 92 | * \property KContacts::Impp::serviceLabel |
| 93 | */ |
| 94 | Q_PROPERTY(QString serviceLabel READ serviceLabel) |
| 95 | |
| 96 | /*! |
| 97 | * \qmlproperty bool impp::serviceIcon |
| 98 | */ |
| 99 | |
| 100 | /*! |
| 101 | * \property KContacts::Impp::serviceIcon |
| 102 | */ |
| 103 | Q_PROPERTY(QString serviceIcon READ serviceIcon) |
| 104 | |
| 105 | friend KCONTACTS_EXPORT QDataStream &operator<<(QDataStream &, const Impp &); |
| 106 | friend KCONTACTS_EXPORT QDataStream &operator>>(QDataStream &, Impp &); |
| 107 | friend class VCardTool; |
| 108 | friend class ::ImppTest; |
| 109 | |
| 110 | public: |
| 111 | /*! |
| 112 | */ |
| 113 | Impp(); |
| 114 | |
| 115 | Impp(const Impp &other); |
| 116 | |
| 117 | /*! |
| 118 | */ |
| 119 | Impp(const QUrl &address); |
| 120 | |
| 121 | ~Impp(); |
| 122 | |
| 123 | /*! |
| 124 | */ |
| 125 | typedef QList<Impp> List; |
| 126 | |
| 127 | /*! |
| 128 | */ |
| 129 | Q_REQUIRED_RESULT bool isValid() const; |
| 130 | |
| 131 | /*! |
| 132 | */ |
| 133 | void setAddress(const QUrl &address); |
| 134 | |
| 135 | /*! |
| 136 | */ |
| 137 | Q_REQUIRED_RESULT QUrl address() const; |
| 138 | |
| 139 | /*! |
| 140 | * Returns the messaging service this address is for. |
| 141 | * This is equivalent to address().scheme(). |
| 142 | * \since 5.12 |
| 143 | */ |
| 144 | QString serviceType() const; |
| 145 | /*! |
| 146 | * Returns a translated label for the service type. |
| 147 | * \since 5.12 |
| 148 | */ |
| 149 | QString serviceLabel() const; |
| 150 | /*! |
| 151 | * Returns the name of an icon representing the service type. |
| 152 | * \since 5.12 |
| 153 | */ |
| 154 | QString serviceIcon() const; |
| 155 | |
| 156 | /*! |
| 157 | * Returns whether this is the preferred messaging address. |
| 158 | * \since 5.12 |
| 159 | */ |
| 160 | bool isPreferred() const; |
| 161 | /*! |
| 162 | * Sets that this is the preferred messaging address. |
| 163 | * \since 5.12 |
| 164 | */ |
| 165 | void setPreferred(bool preferred); |
| 166 | |
| 167 | /*! |
| 168 | */ |
| 169 | Q_REQUIRED_RESULT bool operator==(const Impp &other) const; |
| 170 | |
| 171 | /*! |
| 172 | */ |
| 173 | Q_REQUIRED_RESULT bool operator!=(const Impp &other) const; |
| 174 | |
| 175 | Impp &operator=(const Impp &other); |
| 176 | |
| 177 | /*! |
| 178 | */ |
| 179 | Q_REQUIRED_RESULT QString toString() const; |
| 180 | |
| 181 | /*! |
| 182 | * Returns a translated name of the given IM service. |
| 183 | * \since 5.12 |
| 184 | */ |
| 185 | static QString serviceLabel(const QString &serviceType); |
| 186 | /*! |
| 187 | * Returns an icon name representing the given IM service. |
| 188 | * \since 5.12 |
| 189 | */ |
| 190 | static QString serviceIcon(const QString &serviceType); |
| 191 | /*! |
| 192 | * List all known service types. |
| 193 | * |
| 194 | * Don't use these strings directly for display, instead use serviceLabel and serviceIcon. |
| 195 | * \since 5.12 |
| 196 | */ |
| 197 | static QList<QString> serviceTypes(); |
| 198 | |
| 199 | private: |
| 200 | // exported for ImppTest |
| 201 | void setParams(const ParameterMap ¶ms); |
| 202 | Q_REQUIRED_RESULT ParameterMap params() const; |
| 203 | |
| 204 | class Private; |
| 205 | QSharedDataPointer<Private> d; |
| 206 | }; |
| 207 | |
| 208 | /*! |
| 209 | * \relates KContacts::Impp |
| 210 | */ |
| 211 | KCONTACTS_EXPORT QDataStream &operator<<(QDataStream &stream, const Impp &object); |
| 212 | |
| 213 | /*! |
| 214 | * \relates KContacts::Impp |
| 215 | */ |
| 216 | KCONTACTS_EXPORT QDataStream &operator>>(QDataStream &stream, Impp &object); |
| 217 | } |
| 218 | |
| 219 | Q_DECLARE_TYPEINFO(KContacts::Impp, Q_RELOCATABLE_TYPE); |
| 220 | |
| 221 | #endif // IMPP_H |
| 222 | |