1 /* 2 * Copyright (C) 2013 David Edmundson <kde@davidedmundson.co.uk> 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 St, Fifth Floor, Boston, MA 02110-1301 USA 17 */ 18 19 #ifndef KTP_ACCOUNT_FACTORY_H 20 #define KTP_ACCOUNT_FACTORY_H 21 22 #include <TelepathyQt/AccountFactory> 23 #include <TelepathyQt/Account> 24 25 #include <TelepathyQt/Types> 26 27 #include <KTp/ktpcommoninternals_export.h> 28 29 /* 30 * This class is part of a hack that fixes the following problem: 31 * Connection has no way to access the account that owns it 32 * This means contacts have no way to know where they are from 33 * For KPeople (and in other cases) we need the account UID from a contact 34 * 35 * 36 * This class subclasses account and sets a property Connection whenever it is 37 * created. 38 */ 39 40 namespace KTp { 41 class AccountFactory : public Tp::AccountFactory 42 { 43 public: 44 static Tp::AccountFactoryPtr create(const QDBusConnection &bus, const Tp::Features &features=Tp::Features()); 45 protected: 46 AccountFactory(const QDBusConnection& bus, const Tp::Features& features); 47 Tp::AccountPtr construct(const QString& busName, 48 const QString& objectPath, 49 const Tp::ConnectionFactoryConstPtr& connFactory, 50 const Tp::ChannelFactoryConstPtr& chanFactory, 51 const Tp::ContactFactoryConstPtr& contactFactory) const override; 52 }; 53 54 class Account: public Tp::Account 55 { 56 Q_OBJECT 57 public: 58 static Tp::AccountPtr create (const QDBusConnection &bus, const QString &busName, const QString &objectPath, const Tp::ConnectionFactoryConstPtr &connectionFactory, const Tp::ChannelFactoryConstPtr &channelFactory, const Tp::ContactFactoryConstPtr &contactFactory=Tp::ContactFactory::create()); 59 protected: 60 Account (const QDBusConnection &bus, 61 const QString &busName, 62 const QString &objectPath, 63 const Tp::ConnectionFactoryConstPtr &connectionFactory, 64 const Tp::ChannelFactoryConstPtr &channelFactory, 65 const Tp::ContactFactoryConstPtr &contactFactory, 66 const Tp::Feature &coreFeature); 67 68 private Q_SLOTS: 69 void onConnectionChanged(const Tp::ConnectionPtr &connection); 70 }; 71 } 72 73 74 #endif // CONTACTFACTORY_H 75