File indexing completed on 2023-12-03 08:28:33
0001 /* 0002 * Copyright (C) 2013 Daniel Vrátil <dvratil@redhat.com> 0003 * 0004 * This library is free software; you can redistribute it and/or 0005 * modify it under the terms of the GNU Lesser General Public 0006 * License as published by the Free Software Foundation; either 0007 * version 2.1 of the License, or (at your option) any later version. 0008 * 0009 * This library is distributed in the hope that it will be useful, 0010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0012 * Lesser General Public License for more details. 0013 * 0014 * You should have received a copy of the GNU Lesser General Public 0015 * License along with this library; if not, write to the Free Software 0016 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 0017 * 0018 */ 0019 0020 #ifndef KTP_LOGENTITY_H 0021 #define KTP_LOGENTITY_H 0022 0023 #include <QSharedDataPointer> 0024 #include <QString> 0025 #include <QMetaType> 0026 0027 #include <KTp/ktpcommoninternals_export.h> 0028 0029 #include <TelepathyQt/Constants> 0030 0031 namespace KTp { 0032 0033 /** 0034 * @brief LogEntity represents a single contact or chat room 0035 * 0036 * @since 0.7 0037 * @author Daniel Vrátil <dvratil@redhat.com> 0038 */ 0039 class KTPCOMMONINTERNALS_EXPORT LogEntity 0040 { 0041 public: 0042 /** 0043 * Constructs an invalid LogEntity. 0044 */ 0045 explicit LogEntity(); 0046 0047 /** 0048 * Constructs a valid entity. 0049 * 0050 * @param entityType Whether the entity represents a contact or a chat room 0051 * @param id ID of the contact or chat room 0052 * @param alias Optional alias (username) of the contact or chat room 0053 */ 0054 LogEntity(Tp::HandleType entityType, const QString &id, 0055 const QString &alias = QString()); 0056 0057 /** 0058 * Copy constructor. 0059 */ 0060 LogEntity(const KTp::LogEntity &other); 0061 0062 /** 0063 * Destructor. 0064 */ 0065 ~LogEntity(); 0066 0067 /** 0068 * Assignment operator. 0069 */ 0070 KTp::LogEntity& operator=(const KTp::LogEntity &other); 0071 0072 /** 0073 * Compare operator. 0074 */ 0075 bool operator==(const KTp::LogEntity &other); 0076 0077 /** 0078 * Compare operator. 0079 */ 0080 bool operator!=(const KTp::LogEntity &other); 0081 0082 /** 0083 * Returns whether this entity is valid (i.e. whether entity type is valid and 0084 * whether id is not empty). 0085 */ 0086 bool isValid() const; 0087 0088 /** 0089 * Returns ID of contact or chat room that this entity represents. 0090 */ 0091 QString id() const; 0092 0093 /** 0094 * Returns username of the contact or name of the chat room this entity represents 0095 * or an empty string if none was set. 0096 */ 0097 QString alias() const; 0098 0099 /** 0100 * Returns whether this entity represents a contact or a chat room. 0101 */ 0102 Tp::HandleType entityType() const; 0103 0104 private: 0105 class Private; 0106 QSharedDataPointer<Private> d; 0107 }; 0108 0109 } 0110 0111 Q_DECLARE_METATYPE(KTp::LogEntity) 0112 0113 #endif // KTP_LOGENTITY_H