TelepathyQt4: connection-manager.h Source File

| 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     Q_PROPERTY(QString name READ name)
    00118     Q_PROPERTY(QStringList supportedProtocols READ supportedProtocols)
    00119     Q_PROPERTY(ProtocolInfoList protocols READ protocols)
    00120
    00121 public:
    00122     static const Feature FeatureCore;
    00123
    00124     static ConnectionManagerPtr create(const QString &name);
    00125     static ConnectionManagerPtr create(const QDBusConnection &bus,
    00126             const QString &name);
    00127
    00128     virtual ~ConnectionManager();
    00129
    00130     QString name() const;
    00131
    00132     QStringList supportedProtocols() const;
    00133     const ProtocolInfoList &protocols() const;
    00134
    00135     PendingConnection *requestConnection(const QString &protocol,
    00136             const QVariantMap &parameters);
    00137
    00138     static PendingStringList *listNames(
    00139             const QDBusConnection &bus = QDBusConnection::sessionBus());
    00140
    00141     inline Client::DBus::PropertiesInterface *propertiesInterface() const
    00142     {
    00143         return OptionalInterfaceFactory<ConnectionManager>::interface<Client::DBus::PropertiesInterface>();
    00144     }
    00145
    00146 protected:
    00147     ConnectionManager(const QString &name);
    00148     ConnectionManager(const QDBusConnection &bus, const QString &name);
    00149
    00150     Client::ConnectionManagerInterface *baseInterface() const;
    00151
    00152 private Q_SLOTS:
    00153     void gotMainProperties(QDBusPendingCallWatcher *);
    00154     void gotProtocols(QDBusPendingCallWatcher *);
    00155     void gotParameters(QDBusPendingCallWatcher *);
    00156
    00157 private:
    00158     friend class PendingConnection;
    00159
    00160     struct Private;
    00161     friend struct Private;
    00162     Private *mPriv;
    00163 };
    00164
    00165 } // Tp
    00166
    00167 #endif