File indexing completed on 2023-10-01 08:41:44

0001 /*
0002 * Copyright (C) 2012 David Edmundson <kde@davidedmundson.co.uk>
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 #ifndef KTP_CONTACT_H
0020 #define KTP_CONTACT_H
0021 
0022 #include <QVariant>
0023 #include <TelepathyQt/Contact>
0024 #include <KTp/presence.h>
0025 #include <KTp/ktpcommoninternals_export.h>
0026 
0027 
0028 namespace KTp{
0029 class KTPCOMMONINTERNALS_EXPORT Contact : public Tp::Contact
0030 {
0031     Q_OBJECT
0032 public:
0033     explicit Contact(Tp::ContactManager *manager, const Tp::ReferencedHandles &handle, const Tp::Features &requestedFeatures, const QVariantMap &attributes);
0034 
0035     KTp::Presence presence() const;
0036 
0037 
0038     /** Returns true if text chats can be started with this contact*/
0039     bool textChatCapability() const;
0040     /** Returns true if audio calls can be started with this contact*/
0041     bool audioCallCapability() const;
0042     /** Returns true if video calls can be started with this contact*/
0043     bool videoCallCapability() const;
0044     /** Returns true if file transfers can be started with this contact*/
0045     bool fileTransferCapability() const;
0046     /** Returns true if this contact supports collaborative editing*/
0047     bool collaborativeEditingCapability() const;
0048 
0049     /** Returns list of available dbus tube services*/
0050     QStringList dbusTubeServicesCapability() const;
0051     /** Returns list of available stream tube services*/
0052     QStringList streamTubeServicesCapability() const;
0053 
0054     //Overridden as a workaround for upstream bug https://bugs.freedesktop.org/show_bug.cgi?id=55883
0055     QStringList clientTypes() const;
0056     /** Returns the pixmap of an avatar desaturated to gray if contact is offline*/
0057     QPixmap avatarPixmap();
0058 
0059     QString accountUniqueIdentifier() const;
0060 
0061     /**
0062      * Returns unique identifier for this contact in the form of
0063      * ktp:// + account unique ID + ? + contact ID
0064      */
0065     QString uri() const;
0066 
0067 Q_SIGNALS:
0068     void invalidated();
0069 
0070 private Q_SLOTS:
0071     void invalidateAvatarCache();
0072     void onPresenceChanged(const Tp::Presence &presence);
0073 
0074 private:
0075     static QStringList getCommonElements(const QStringList &list1, const QStringList &list2);
0076     void avatarToGray(QPixmap &avatar);
0077     QString keyCache() const;
0078     QString buildAvatarPath(const QString &avatarToken);
0079 
0080     QString m_accountUniqueIdentifier;
0081 };
0082 
0083 
0084 typedef Tp::SharedPtr<KTp::Contact> ContactPtr;
0085 
0086 }//namespace
0087 
0088 // Q_DECLARE_METATYPE(KTp::ContactPtr)
0089 
0090 #endif // CONTACT_H