File indexing completed on 2024-12-08 03:38:52
0001 /* 0002 This file is part of libkabc. 0003 SPDX-FileCopyrightText: 2015-2019 Laurent Montel <montel@kde.org> 0004 0005 SPDX-License-Identifier: LGPL-2.0-or-later 0006 */ 0007 0008 #ifndef IMPP_H 0009 #define IMPP_H 0010 0011 #include "kcontacts_export.h" 0012 0013 #include <QMap> 0014 #include <QMetaType> 0015 #include <QSharedDataPointer> 0016 #include <QString> 0017 0018 class ImppTest; 0019 0020 namespace KContacts 0021 { 0022 class ParameterMap; 0023 0024 /** @short Class that holds a IMPP for a contact. 0025 * 0026 * IMPP stands for "Instant Messaging and Presence Protocol". This field is defined 0027 * in the vCard 3.0 extension RFC 4770 and is part of vCard 4.0 (RFC 6350). 0028 * 0029 * @since 4.14.5 0030 */ 0031 class KCONTACTS_EXPORT Impp 0032 { 0033 Q_GADGET 0034 Q_PROPERTY(bool isValid READ isValid) 0035 Q_PROPERTY(QUrl address READ address WRITE setAddress) 0036 Q_PROPERTY(bool isPreferred READ isPreferred WRITE setPreferred) 0037 Q_PROPERTY(QString serviceType READ serviceType) 0038 Q_PROPERTY(QString serviceLabel READ serviceLabel) 0039 Q_PROPERTY(QString serviceIcon READ serviceIcon) 0040 0041 friend KCONTACTS_EXPORT QDataStream &operator<<(QDataStream &, const Impp &); 0042 friend KCONTACTS_EXPORT QDataStream &operator>>(QDataStream &, Impp &); 0043 friend class VCardTool; 0044 friend class ::ImppTest; 0045 0046 public: 0047 Impp(); 0048 Impp(const Impp &other); 0049 Impp(const QUrl &address); 0050 0051 ~Impp(); 0052 0053 typedef QList<Impp> List; 0054 Q_REQUIRED_RESULT bool isValid() const; 0055 0056 void setAddress(const QUrl &address); 0057 Q_REQUIRED_RESULT QUrl address() const; 0058 0059 /** 0060 * Returns the messaging service this address is for. 0061 * This is equivalent to address().scheme(). 0062 * @since 5.12 0063 */ 0064 QString serviceType() const; 0065 /** 0066 * Returns a translated label for the service type. 0067 * @since 5.12 0068 */ 0069 QString serviceLabel() const; 0070 /** 0071 * Returns the name of an icon representing the service type. 0072 * @since 5.12 0073 */ 0074 QString serviceIcon() const; 0075 0076 /** 0077 * Returns whether this is the preferred messaging address. 0078 * @since 5.12 0079 */ 0080 bool isPreferred() const; 0081 /** 0082 * Sets that this is the preferred messaging address. 0083 * @since 5.12 0084 */ 0085 void setPreferred(bool preferred); 0086 0087 Q_REQUIRED_RESULT bool operator==(const Impp &other) const; 0088 Q_REQUIRED_RESULT bool operator!=(const Impp &other) const; 0089 0090 Impp &operator=(const Impp &other); 0091 0092 Q_REQUIRED_RESULT QString toString() const; 0093 0094 /** 0095 * Returns a translated name of the given IM service. 0096 * @since 5.12 0097 */ 0098 static QString serviceLabel(const QString &serviceType); 0099 /** 0100 * Returns an icon name representing the given IM service. 0101 * @since 5.12 0102 */ 0103 static QString serviceIcon(const QString &serviceType); 0104 /** 0105 * List all known service types. 0106 * Don't use these strings directly for display, instead use serviceLabel and serviceIcon. 0107 * @since 5.12 0108 */ 0109 static QList<QString> serviceTypes(); 0110 0111 private: 0112 // exported for ImppTest 0113 void setParams(const ParameterMap ¶ms); 0114 Q_REQUIRED_RESULT ParameterMap params() const; 0115 0116 class Private; 0117 QSharedDataPointer<Private> d; 0118 }; 0119 0120 KCONTACTS_EXPORT QDataStream &operator<<(QDataStream &stream, const Impp &object); 0121 0122 KCONTACTS_EXPORT QDataStream &operator>>(QDataStream &stream, Impp &object); 0123 } 0124 0125 Q_DECLARE_TYPEINFO(KContacts::Impp, Q_RELOCATABLE_TYPE); 0126 0127 #endif // IMPP_H