Home · All Classes · All Namespaces · Modules · Functions · Files

connection-manager.h

00001 /*
00002  * This file is part of TelepathyQt4
00003  *
00004  * Copyright (C) 2008 Collabora Ltd. <http://www.collabora.co.uk/>
00005  * Copyright (C) 2008 Nokia Corporation
00006  *
00007  * This library is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Lesser General Public
00009  * License as published by the Free Software Foundation; either
00010  * version 2.1 of the License, or (at your option) any later version.
00011  *
00012  * This library is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  * Lesser General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Lesser General Public
00018  * License along with this library; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00020  */
00021 
00022 #ifndef _TelepathyQt4_connection_manager_h_HEADER_GUARD_
00023 #define _TelepathyQt4_connection_manager_h_HEADER_GUARD_
00024 
00025 #ifndef IN_TELEPATHY_QT4_HEADER
00026 #error IN_TELEPATHY_QT4_HEADER
00027 #endif
00028 
00029 #include <TelepathyQt4/_gen/cli-connection-manager.h>
00030 
00031 #include <TelepathyQt4/DBus>
00032 #include <TelepathyQt4/DBusProxy>
00033 #include <TelepathyQt4/OptionalInterfaceFactory>
00034 #include <TelepathyQt4/ReadinessHelper>
00035 #include <TelepathyQt4/ReadyObject>
00036 #include <TelepathyQt4/Types>
00037 #include <TelepathyQt4/Constants>
00038 #include <TelepathyQt4/SharedPtr>
00039 
00040 #include <QSet>
00041 
00042 namespace Tp
00043 {
00044 
00045 class PendingConnection;
00046 class PendingReady;
00047 class PendingStringList;
00048 class ProtocolParameter;
00049 class ProtocolInfo;
00050 
00051 typedef QList<ProtocolParameter*> ProtocolParameterList;
00052 typedef QList<ProtocolInfo*> ProtocolInfoList;
00053 
00054 class TELEPATHY_QT4_EXPORT ProtocolParameter
00055 {
00056 public:
00057     ProtocolParameter(const QString &name,
00058                       const QDBusSignature &dbusSignature,
00059                       QVariant defaultValue,
00060                       ConnMgrParamFlag flags);
00061     ~ProtocolParameter();
00062 
00063     QString name() const;
00064     QDBusSignature dbusSignature() const;
00065     QVariant::Type type() const;
00066     QVariant defaultValue() const;
00067 
00068     bool isRequired() const;
00069     bool isSecret() const;
00070     bool isRequiredForRegistration() const;
00071 
00072     bool operator==(const ProtocolParameter &other) const;
00073     bool operator==(const QString &name) const;
00074 
00075 private:
00076     Q_DISABLE_COPY(ProtocolParameter);
00077 
00078     struct Private;
00079     friend struct Private;
00080     Private *mPriv;
00081 };
00082 
00083 class TELEPATHY_QT4_EXPORT ProtocolInfo
00084 {
00085 public:
00086     ~ProtocolInfo();
00087 
00088     QString cmName() const;
00089 
00090     QString name() const;
00091 
00092     const ProtocolParameterList &parameters() const;
00093     bool hasParameter(const QString &name) const;
00094 
00095     bool canRegister() const;
00096 
00097 private:
00098     Q_DISABLE_COPY(ProtocolInfo);
00099 
00100     ProtocolInfo(const QString &cmName, const QString &name);
00101 
00102     void addParameter(const ParamSpec &spec);
00103 
00104     struct Private;
00105     friend struct Private;
00106     friend class ConnectionManager;
00107     Private *mPriv;
00108 };
00109 
00110 class TELEPATHY_QT4_EXPORT ConnectionManager : public StatelessDBusProxy,
00111                           public OptionalInterfaceFactory<ConnectionManager>,
00112                           public ReadyObject,
00113                           public RefCounted
00114 {
00115     Q_OBJECT
00116     Q_DISABLE_COPY(ConnectionManager);
00117 
00118 public:
00119     static const Feature FeatureCore;
00120 
00121     static ConnectionManagerPtr create(const QString &name);
00122     static ConnectionManagerPtr create(const QDBusConnection &bus,
00123             const QString &name);
00124 
00125     virtual ~ConnectionManager();
00126 
00127     QString name() const;
00128 
00129     QStringList supportedProtocols() const;
00130     const ProtocolInfoList &protocols() const;
00131 
00132     PendingConnection *requestConnection(const QString &protocol,
00133             const QVariantMap &parameters);
00134 
00135     static PendingStringList *listNames(
00136             const QDBusConnection &bus = QDBusConnection::sessionBus());
00137 
00138     inline Client::DBus::PropertiesInterface *propertiesInterface() const
00139     {
00140         return OptionalInterfaceFactory<ConnectionManager>::interface<Client::DBus::PropertiesInterface>();
00141     }
00142 
00143 protected:
00144     ConnectionManager(const QString &name);
00145     ConnectionManager(const QDBusConnection &bus, const QString &name);
00146 
00147     Client::ConnectionManagerInterface *baseInterface() const;
00148 
00149 private Q_SLOTS:
00150     void gotMainProperties(QDBusPendingCallWatcher *);
00151     void gotProtocols(QDBusPendingCallWatcher *);
00152     void gotParameters(QDBusPendingCallWatcher *);
00153 
00154 private:
00155     friend class PendingConnection;
00156 
00157     struct Private;
00158     friend struct Private;
00159     Private *mPriv;
00160 };
00161 
00162 } // Tp
00163 
00164 #endif


Copyright © 2009 Collabora Ltd. and Nokia Corporation
Telepathy-Qt4 0.2.1