1 /* 2 * Common enums and types in KTp 3 * 4 * Copyright (C) 2013 David Edmundson <kde@davidedmundson.co.uk> 5 * 6 * This library is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU Lesser General Public 8 * License as published by the Free Software Foundation; either 9 * version 2.1 of the License, or (at your option) any later version. 10 * 11 * This library is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * Lesser General Public License for more details. 15 * 16 * You should have received a copy of the GNU Lesser General Public 17 * License along with this library; if not, write to the Free Software 18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 */ 20 21 #ifndef KTP_TYPES_H 22 #define KTP_TYPES_H 23 24 #include "contact.h" 25 26 #include "core.h" 27 28 #include <TelepathyQt/TextChannel> 29 #include <TelepathyQt/Account> 30 #include <TelepathyQt/AccountSet> 31 #include <TelepathyQt/AccountManager> 32 33 #include <QVariant> 34 35 //this is deliberately the wrong namespace for backwards compatability, we will change it when the roles are sorted. 36 namespace KTp 37 { 38 enum RowType { 39 ContactRowType, 40 PersonRowType, 41 AccountRowType, 42 GroupRowType, 43 RoomRowType, 44 MergeRowType, 45 UserRowType = 1000 46 }; 47 48 enum ContactsModelRole { 49 // general roles 50 RowTypeRole = Qt::UserRole, //returns one of KTp::ContactRowType, KTp::PersonRowType, KTp::GroupRowType, KTp::AccountRowType 51 IdRole, //returns Contact ID, Account UID, or group ID (group name or "_ungrouped") 52 PersonIdRole, ///< id of the corresponding contact/person resource in kpeople 53 54 //telepathy roles 55 ContactRole = Qt::UserRole + 1000, ///<return Tp::ContactPtr 56 AccountRole, ///< return Tp::AccountPtr 57 ChannelRole, ///< return Tp::ChannelPtr 58 59 //contact/person roles 60 ContactClientTypesRole = Qt::UserRole + 2000, ///< stringlist. See Tp::Contact::ClientTypes 61 ContactAvatarPathRole, ///<string. path to avatar file 62 ContactAvatarPixmapRole, ///< QPixmap the pixmap that shall be use as avatar image 63 ContactGroupsRole, ///< stringlist. of all groups contact is in 64 65 ContactPresenceNameRole, 66 ContactPresenceMessageRole, 67 ContactPresenceTypeRole, 68 ContactPresenceIconRole, 69 70 ContactSubscriptionStateRole, ///< enum of type Tp::Contact::PresenceState 71 ContactPublishStateRole, ///< enum of type Tp::Contact::PresenceState 72 ContactIsBlockedRole, ///< bool, true if contact is blocked 73 74 ContactHasTextChannelRole, ///< bool, returns true if a text channel is active for this contact 75 ContactUnreadMessageCountRole, ///< int. the number of unread messages in active channels with this contact 76 ContactLastMessageRole, ///string, the last message to/from this contact in an active chat 77 ContactLastMessageDirectionRole, //enum KTp::Message::MessageDirection direction of last message 78 79 ContactCanTextChatRole, ///< bool. You and contact can both text chat 80 ContactCanFileTransferRole, ///< bool. You and contact can both file transfer 81 ContactCanAudioCallRole, ///< bool. You and contact can both audio call 82 ContactCanVideoCallRole, ///< bool. You and contact can both video call 83 ContactTubesRole, ///< stringlist. common supported dbus + stream services between you and contact 84 85 ContactUriRole, 86 ContactVCardRole, ///< VCard of the contact in KContacts::Addresse format; KPeople only at the moment 87 88 //heading roles 89 HeaderTotalUsersRole = Qt::UserRole + 3000, 90 HeaderOnlineUsersRole, 91 92 CustomRole = Qt::UserRole + 4000 // a placemark for custom roles in inherited models 93 }; 94 } 95 96 static const QString S_KPEOPLE_PROPERTY_ACCOUNT_PATH = QStringLiteral("telepathy-accountPath"); 97 static const QString S_KPEOPLE_PROPERTY_ACCOUNT_DISPLAY_NAME = QStringLiteral("telepathy-accountDisplayName"); 98 static const QString S_KPEOPLE_PROPERTY_CONTACT_ID = QStringLiteral("telepathy-contactId"); 99 static const QString S_KPEOPLE_PROPERTY_CONTACT_URI = QStringLiteral("telepathy-contactUri"); 100 static const QString S_KPEOPLE_PROPERTY_PRESENCE = QStringLiteral("telepathy-presence"); 101 static const QString S_KPEOPLE_PROPERTY_IS_BLOCKED = QStringLiteral("telepathy-isBlocked"); 102 103 const QHash<Tp::ConnectionPresenceType, QString> s_presenceStrings = { 104 { Tp::ConnectionPresenceTypeUnset, QString() }, 105 { Tp::ConnectionPresenceTypeOffline, QStringLiteral("offline") }, 106 { Tp::ConnectionPresenceTypeAvailable, QStringLiteral("available") }, 107 { Tp::ConnectionPresenceTypeAway, QStringLiteral("away") }, 108 { Tp::ConnectionPresenceTypeExtendedAway, QStringLiteral("xa") }, 109 { Tp::ConnectionPresenceTypeHidden, QStringLiteral("hidden") }, //or 'offline' ? 110 { Tp::ConnectionPresenceTypeBusy, QStringLiteral("busy") }, 111 { Tp::ConnectionPresenceTypeUnknown, QStringLiteral("unknown") }, 112 { Tp::ConnectionPresenceTypeError, QStringLiteral("error") } 113 }; 114 115 Q_DECLARE_METATYPE(Tp::AccountSetPtr); 116 Q_DECLARE_METATYPE(Tp::AccountPtr) 117 Q_DECLARE_METATYPE(KTp::ContactPtr) 118 Q_DECLARE_METATYPE(Tp::AccountManagerPtr); 119 Q_DECLARE_METATYPE(Tp::ConnectionPtr); 120 Q_DECLARE_METATYPE(Tp::TextChannelPtr); 121 Q_DECLARE_METATYPE(Tp::ChannelPtr); 122 123 124 #endif // KTP_TYPES_H 125