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

0001 /*
0002 * Copyright (C) 2013 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_ACCOUNT_FACTORY_H
0020 #define KTP_ACCOUNT_FACTORY_H
0021 
0022 #include <TelepathyQt/AccountFactory>
0023 #include <TelepathyQt/Account>
0024 
0025 #include <TelepathyQt/Types>
0026 
0027 #include <KTp/ktpcommoninternals_export.h>
0028 
0029 /*
0030  * This class is part of a hack that fixes the following problem:
0031  *  Connection has no way to access the account that owns it
0032  *  This means contacts have no way to know where they are from
0033  *  For KPeople (and in other cases) we need the account UID from a contact
0034  *
0035  *
0036  * This class subclasses account and sets a property Connection whenever it is
0037  * created.
0038  */
0039 
0040 namespace KTp {
0041 class AccountFactory : public Tp::AccountFactory
0042 {
0043 public:
0044     static Tp::AccountFactoryPtr create(const QDBusConnection &bus, const Tp::Features &features=Tp::Features());
0045 protected:
0046     AccountFactory(const QDBusConnection& bus, const Tp::Features& features);
0047     Tp::AccountPtr construct(const QString& busName,
0048                                      const QString& objectPath,
0049                                      const Tp::ConnectionFactoryConstPtr& connFactory,
0050                                      const Tp::ChannelFactoryConstPtr& chanFactory,
0051                                      const Tp::ContactFactoryConstPtr& contactFactory) const override;
0052 };
0053 
0054 class Account: public Tp::Account
0055 {
0056     Q_OBJECT
0057 public:
0058     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());
0059 protected:
0060     Account (const QDBusConnection &bus,
0061              const QString &busName,
0062              const QString &objectPath,
0063              const Tp::ConnectionFactoryConstPtr &connectionFactory,
0064              const Tp::ChannelFactoryConstPtr &channelFactory,
0065              const Tp::ContactFactoryConstPtr &contactFactory,
0066              const Tp::Feature &coreFeature);
0067 
0068 private Q_SLOTS:
0069     void onConnectionChanged(const Tp::ConnectionPtr &connection);
0070 };
0071 }
0072 
0073 
0074 #endif // CONTACTFACTORY_H