File indexing completed on 2023-10-01 08:41:45
0001 /* 0002 * Common enums and types in KTp 0003 * 0004 * Copyright (C) 2013 David Edmundson <kde@davidedmundson.co.uk> 0005 * 0006 * This library is free software; you can redistribute it and/or 0007 * modify it under the terms of the GNU Lesser General Public 0008 * License as published by the Free Software Foundation; either 0009 * version 2.1 of the License, or (at your option) any later version. 0010 * 0011 * This library is distributed in the hope that it will be useful, 0012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0014 * Lesser General Public License for more details. 0015 * 0016 * You should have received a copy of the GNU Lesser General Public 0017 * License along with this library; if not, write to the Free Software 0018 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 0019 */ 0020 0021 #ifndef KTP_TYPES_H 0022 #define KTP_TYPES_H 0023 0024 #include "contact.h" 0025 0026 #include "core.h" 0027 0028 #include <TelepathyQt/TextChannel> 0029 #include <TelepathyQt/Account> 0030 #include <TelepathyQt/AccountSet> 0031 #include <TelepathyQt/AccountManager> 0032 0033 #include <QVariant> 0034 0035 //this is deliberately the wrong namespace for backwards compatability, we will change it when the roles are sorted. 0036 namespace KTp 0037 { 0038 enum RowType { 0039 ContactRowType, 0040 PersonRowType, 0041 AccountRowType, 0042 GroupRowType, 0043 RoomRowType, 0044 MergeRowType, 0045 UserRowType = 1000 0046 }; 0047 0048 enum ContactsModelRole { 0049 // general roles 0050 RowTypeRole = Qt::UserRole, //returns one of KTp::ContactRowType, KTp::PersonRowType, KTp::GroupRowType, KTp::AccountRowType 0051 IdRole, //returns Contact ID, Account UID, or group ID (group name or "_ungrouped") 0052 PersonIdRole, ///< id of the corresponding contact/person resource in kpeople 0053 0054 //telepathy roles 0055 ContactRole = Qt::UserRole + 1000, ///<return Tp::ContactPtr 0056 AccountRole, ///< return Tp::AccountPtr 0057 ChannelRole, ///< return Tp::ChannelPtr 0058 0059 //contact/person roles 0060 ContactClientTypesRole = Qt::UserRole + 2000, ///< stringlist. See Tp::Contact::ClientTypes 0061 ContactAvatarPathRole, ///<string. path to avatar file 0062 ContactAvatarPixmapRole, ///< QPixmap the pixmap that shall be use as avatar image 0063 ContactGroupsRole, ///< stringlist. of all groups contact is in 0064 0065 ContactPresenceNameRole, 0066 ContactPresenceMessageRole, 0067 ContactPresenceTypeRole, 0068 ContactPresenceIconRole, 0069 0070 ContactSubscriptionStateRole, ///< enum of type Tp::Contact::PresenceState 0071 ContactPublishStateRole, ///< enum of type Tp::Contact::PresenceState 0072 ContactIsBlockedRole, ///< bool, true if contact is blocked 0073 0074 ContactHasTextChannelRole, ///< bool, returns true if a text channel is active for this contact 0075 ContactUnreadMessageCountRole, ///< int. the number of unread messages in active channels with this contact 0076 ContactLastMessageRole, ///string, the last message to/from this contact in an active chat 0077 ContactLastMessageDirectionRole, //enum KTp::Message::MessageDirection direction of last message 0078 0079 ContactCanTextChatRole, ///< bool. You and contact can both text chat 0080 ContactCanFileTransferRole, ///< bool. You and contact can both file transfer 0081 ContactCanAudioCallRole, ///< bool. You and contact can both audio call 0082 ContactCanVideoCallRole, ///< bool. You and contact can both video call 0083 ContactTubesRole, ///< stringlist. common supported dbus + stream services between you and contact 0084 0085 ContactUriRole, 0086 ContactVCardRole, ///< VCard of the contact in KContacts::Addresse format; KPeople only at the moment 0087 0088 //heading roles 0089 HeaderTotalUsersRole = Qt::UserRole + 3000, 0090 HeaderOnlineUsersRole, 0091 0092 CustomRole = Qt::UserRole + 4000 // a placemark for custom roles in inherited models 0093 }; 0094 } 0095 0096 static const QString S_KPEOPLE_PROPERTY_ACCOUNT_PATH = QStringLiteral("telepathy-accountPath"); 0097 static const QString S_KPEOPLE_PROPERTY_ACCOUNT_DISPLAY_NAME = QStringLiteral("telepathy-accountDisplayName"); 0098 static const QString S_KPEOPLE_PROPERTY_CONTACT_ID = QStringLiteral("telepathy-contactId"); 0099 static const QString S_KPEOPLE_PROPERTY_CONTACT_URI = QStringLiteral("telepathy-contactUri"); 0100 static const QString S_KPEOPLE_PROPERTY_PRESENCE = QStringLiteral("telepathy-presence"); 0101 static const QString S_KPEOPLE_PROPERTY_IS_BLOCKED = QStringLiteral("telepathy-isBlocked"); 0102 0103 const QHash<Tp::ConnectionPresenceType, QString> s_presenceStrings = { 0104 { Tp::ConnectionPresenceTypeUnset, QString() }, 0105 { Tp::ConnectionPresenceTypeOffline, QStringLiteral("offline") }, 0106 { Tp::ConnectionPresenceTypeAvailable, QStringLiteral("available") }, 0107 { Tp::ConnectionPresenceTypeAway, QStringLiteral("away") }, 0108 { Tp::ConnectionPresenceTypeExtendedAway, QStringLiteral("xa") }, 0109 { Tp::ConnectionPresenceTypeHidden, QStringLiteral("hidden") }, //or 'offline' ? 0110 { Tp::ConnectionPresenceTypeBusy, QStringLiteral("busy") }, 0111 { Tp::ConnectionPresenceTypeUnknown, QStringLiteral("unknown") }, 0112 { Tp::ConnectionPresenceTypeError, QStringLiteral("error") } 0113 }; 0114 0115 Q_DECLARE_METATYPE(Tp::AccountSetPtr); 0116 Q_DECLARE_METATYPE(Tp::AccountPtr) 0117 Q_DECLARE_METATYPE(KTp::ContactPtr) 0118 Q_DECLARE_METATYPE(Tp::AccountManagerPtr); 0119 Q_DECLARE_METATYPE(Tp::ConnectionPtr); 0120 Q_DECLARE_METATYPE(Tp::TextChannelPtr); 0121 Q_DECLARE_METATYPE(Tp::ChannelPtr); 0122 0123 0124 #endif // KTP_TYPES_H