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

# connection-manager.h

    00001 /*
    00002  * This file is part of TelepathyQt4
    00003  *
    00004  * Copyright (C) 2008-2010 Collabora Ltd. <http://www.collabora.co.uk/>
    00005  * Copyright (C) 2008-2010 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 ConnectionCapabilities;
    00046 class PendingConnection;
    00047 class PendingReady;
    00048 class PendingStringList;
    00049 class ProtocolParameter;
    00050 class ProtocolInfo;
    00051
    00052 typedef QList<ProtocolParameter*> ProtocolParameterList;
    00053 typedef QList<ProtocolInfo*> ProtocolInfoList;
    00054
    00055 class TELEPATHY_QT4_EXPORT ProtocolParameter
    00056 {
    00057 public:
    00058     ProtocolParameter(const QString &name,
    00059                       const QDBusSignature &dbusSignature,
    00060                       QVariant defaultValue,
    00061                       ConnMgrParamFlag flags);
    00062     ~ProtocolParameter();
    00063
    00064     QString name() const;
    00065     QDBusSignature dbusSignature() const;
    00066     QVariant::Type type() const;
    00067     QVariant defaultValue() const;
    00068
    00069     bool isRequired() const;
    00070     bool isSecret() const;
    00071     bool isRequiredForRegistration() const;
    00072
    00073     bool operator==(const ProtocolParameter &other) const;
    00074     bool operator==(const QString &name) const;
    00075
    00076 private:
    00077     Q_DISABLE_COPY(ProtocolParameter);
    00078
    00079     struct Private;
    00080     friend struct Private;
    00081     Private *mPriv;
    00082 };
    00083
    00084 class TELEPATHY_QT4_EXPORT ProtocolInfo
    00085 {
    00086 public:
    00087     ~ProtocolInfo();
    00088
    00089     QString cmName() const;
    00090
    00091     QString name() const;
    00092
    00093     const ProtocolParameterList &parameters() const;
    00094     bool hasParameter(const QString &name) const;
    00095
    00096     bool canRegister() const;
    00097
    00098     ConnectionCapabilities *capabilities() const;
    00099
    00100     QString vcardField() const;
    00101
    00102     QString englishName() const;
    00103
    00104     QString iconName() const;
    00105
    00106 private:
    00107     Q_DISABLE_COPY(ProtocolInfo);
    00108
    00109     ProtocolInfo(const QString &cmName, const QString &name);
    00110
    00111     void addParameter(const ParamSpec &spec);
    00112     void setRequestableChannelClasses(const RequestableChannelClassList &caps);
    00113     void setVCardField(const QString &vcardField);
    00114     void setEnglishName(const QString &englishName);
    00115     void setIconName(const QString &iconName);
    00116
    00117     struct Private;
    00118     friend struct Private;
    00119     friend class ConnectionManager;
    00120     Private *mPriv;
    00121 };
    00122
    00123 class TELEPATHY_QT4_EXPORT ConnectionManager : public StatelessDBusProxy,
    00124                           public OptionalInterfaceFactory<ConnectionManager>,
    00125                           public ReadyObject,
    00126                           public RefCounted
    00127 {
    00128     Q_OBJECT
    00129     Q_DISABLE_COPY(ConnectionManager);
    00130     Q_PROPERTY(QString name READ name)
    00131     Q_PROPERTY(QStringList supportedProtocols READ supportedProtocols)
    00132     Q_PROPERTY(ProtocolInfoList protocols READ protocols)
    00133
    00134 public:
    00135     static const Feature FeatureCore;
    00136
    00137     // TODO (API/ABI break): Should we keep ConnectionManager::requestConnection. If so we
    00138     //                       probably want to pass factories here and use them in requestConnection.
    00139     static ConnectionManagerPtr create(const QString &name);
    00140     static ConnectionManagerPtr create(const QDBusConnection &bus,
    00141             const QString &name);
    00142
    00143     virtual ~ConnectionManager();
    00144
    00145     QString name() const;
    00146
    00147     QStringList supportedProtocols() const;
    00148     const ProtocolInfoList &protocols() const;
    00149     bool hasProtocol(const QString &protocolName) const;
    00150     ProtocolInfo *protocol(const QString &protocolName) const;
    00151
    00152     // TODO (API/ABI break): Do we want to keep requestConnection as public API?
    00153     PendingConnection *requestConnection(const QString &protocolName,
    00154             const QVariantMap &parameters);
    00155
    00156     static PendingStringList *listNames(
    00157             const QDBusConnection &bus = QDBusConnection::sessionBus());
    00158
    00159     TELEPATHY_QT4_DEPRECATED inline Client::DBus::PropertiesInterface *propertiesInterface() const
    00160     {
    00161         return OptionalInterfaceFactory<ConnectionManager>::interface<Client::DBus::PropertiesInterface>();
    00162     }
    00163
    00164 protected:
    00165     ConnectionManager(const QString &name);
    00166     ConnectionManager(const QDBusConnection &bus, const QString &name);
    00167
    00168     Client::ConnectionManagerInterface *baseInterface() const;
    00169
    00170 private Q_SLOTS:
    00171     void gotMainProperties(QDBusPendingCallWatcher *);
    00172     void gotProtocolsLegacy(QDBusPendingCallWatcher *);
    00173     void gotParametersLegacy(QDBusPendingCallWatcher *);
    00174     void onProtocolReady(Tp::PendingOperation *);
    00175
    00176 private:
    00177     friend class PendingConnection;
    00178
    00179     struct Private;
    00180     friend struct Private;
    00181     Private *mPriv;
    00182 };
    00183
    00184 } // Tp
    00185
    00186 #endif