1 /** 2 * This file is part of TelepathyQt 3 * 4 * @copyright Copyright (C) 2009-2010 Collabora Ltd. <http://www.collabora.co.uk/> 5 * @copyright Copyright (C) 2009-2010 Nokia Corporation 6 * @license LGPL 2.1 7 * 8 * This library is free software; you can redistribute it and/or 9 * modify it under the terms of the GNU Lesser General Public 10 * License as published by the Free Software Foundation; either 11 * version 2.1 of the License, or (at your option) any later version. 12 * 13 * This library is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * Lesser General Public License for more details. 17 * 18 * You should have received a copy of the GNU Lesser General Public 19 * License along with this library; if not, write to the Free Software 20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 21 */ 22 23 #ifndef _TelepathyQt_client_registrar_h_HEADER_GUARD_ 24 #define _TelepathyQt_client_registrar_h_HEADER_GUARD_ 25 26 #ifndef IN_TP_QT_HEADER 27 #error IN_TP_QT_HEADER 28 #endif 29 30 #include <TelepathyQt/AccountFactory> 31 #include <TelepathyQt/ChannelFactory> 32 #include <TelepathyQt/ConnectionFactory> 33 #include <TelepathyQt/ContactFactory> 34 #include <TelepathyQt/Object> 35 #include <TelepathyQt/Types> 36 37 #include <QDBusConnection> 38 #include <QString> 39 40 namespace Tp 41 { 42 43 class TP_QT_EXPORT ClientRegistrar : public Object 44 { 45 Q_OBJECT 46 Q_DISABLE_COPY(ClientRegistrar) 47 48 public: 49 static ClientRegistrarPtr create(const QDBusConnection &bus); 50 static ClientRegistrarPtr create( 51 const AccountFactoryConstPtr &accountFactory = 52 AccountFactory::create(QDBusConnection::sessionBus()), 53 const ConnectionFactoryConstPtr &connectionFactory = 54 ConnectionFactory::create(QDBusConnection::sessionBus()), 55 const ChannelFactoryConstPtr &channelFactory = 56 ChannelFactory::create(QDBusConnection::sessionBus()), 57 const ContactFactoryConstPtr &contactFactory = 58 ContactFactory::create()); 59 static ClientRegistrarPtr create(const QDBusConnection &bus, 60 const AccountFactoryConstPtr &accountFactory, 61 const ConnectionFactoryConstPtr &connectionFactory, 62 const ChannelFactoryConstPtr &channelFactory, 63 const ContactFactoryConstPtr &contactFactory); 64 static ClientRegistrarPtr create(const AccountManagerPtr &accountManager); 65 66 ~ClientRegistrar(); 67 68 QDBusConnection dbusConnection() const; 69 70 AccountFactoryConstPtr accountFactory() const; 71 ConnectionFactoryConstPtr connectionFactory() const; 72 ChannelFactoryConstPtr channelFactory() const; 73 ContactFactoryConstPtr contactFactory() const; 74 75 QList<AbstractClientPtr> registeredClients() const; 76 bool registerClient(const AbstractClientPtr &client, 77 const QString &clientName, bool unique = false); 78 bool unregisterClient(const AbstractClientPtr &client); 79 void unregisterClients(); 80 81 private: 82 ClientRegistrar(const QDBusConnection &bus, 83 const AccountFactoryConstPtr &accountFactory, 84 const ConnectionFactoryConstPtr &connectionFactory, 85 const ChannelFactoryConstPtr &channelFactory, 86 const ContactFactoryConstPtr &contactFactory); 87 88 struct Private; 89 friend struct Private; 90 Private *mPriv; 91 92 static QHash<QPair<QString, QString>, ClientRegistrar *> registrarForConnection; 93 }; 94 95 } // Tp 96 97 #endif 98