1 /* 2 Copyright (C) 2013 David Edmundson <davidedmundson@kde.org> 3 4 This library is free software; you can redistribute it and/or 5 modify it under the terms of the GNU Lesser General Public 6 License as published by the Free Software Foundation; either 7 version 2.1 of the License, or (at your option) any later version. 8 9 This library is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 Lesser General Public License for more details. 13 14 You should have received a copy of the GNU Lesser General Public 15 License along with this library; if not, write to the Free Software 16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 */ 18 19 #ifndef KTP_PERSISTENTCONTACT_H 20 #define KTP_PERSISTENTCONTACT_H 21 22 #include <QObject> 23 24 #include "KTp/contact.h" 25 26 #include <KTp/ktpcommoninternals_export.h> 27 28 namespace KTp { 29 30 /** Object monitors a specific account/contact identifier and will populate it with the most up-to-date contact as connections get destroyed/created 31 * 32 */ 33 class KTPCOMMONINTERNALS_EXPORT PersistentContact : public QObject, public Tp::RefCounted 34 { 35 Q_OBJECT 36 public: 37 static Tp::SharedPtr<KTp::PersistentContact> create(const QString &accountId, const QString &contactId); 38 ~PersistentContact() override; 39 40 QString contactId() const; 41 QString accountId() const; 42 43 /** 44 * This does nothing. Do not use 45 */ 46 void KTPCOMMONINTERNALS_DEPRECATED setAccountManager(const Tp::AccountManagerPtr &accountManager); 47 48 /** The contact object for these ID 49 @warning This may be null whilst loading or if you are offline 50 */ 51 KTp::ContactPtr contact() const; 52 53 /** 54 * @warning This may be null whilst loading or if the account has been deleted 55 */ 56 Tp::AccountPtr account() const; 57 58 Q_SIGNALS: 59 /** Signals that the contact object has been replaced*/ 60 void contactChanged(KTp::ContactPtr); 61 62 private Q_SLOTS: 63 void onAccountReady(Tp::PendingOperation *op); 64 void onAccountConnectionChanged(const Tp::ConnectionPtr &connection); 65 void onPendingContactsFinished(Tp::PendingOperation*); 66 void onContactInvalid(); 67 68 private: 69 PersistentContact(const QString &accountId, const QString &contactId); 70 71 class Private; 72 Private *d; 73 }; 74 75 typedef Tp::SharedPtr<KTp::PersistentContact> PersistentContactPtr; 76 77 } 78 #endif // PERSISTENTCONTACT_H 79