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_cli_connection_manager_h_HEADER_GUARD_
00023 #define _TelepathyQt4_cli_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 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 { return mName; }
00064     QDBusSignature dbusSignature() const { return mDBusSignature; }
00065     QVariant::Type type() const { return mType; }
00066     QVariant defaultValue() const { return mDefaultValue; }
00067 
00068     bool isRequired() const;
00069     bool isSecret() const;
00070     bool requiredForRegistration() 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     QString mName;
00082     QDBusSignature mDBusSignature;
00083     QVariant::Type mType;
00084     QVariant mDefaultValue;
00085     ConnMgrParamFlag mFlags;
00086 };
00087 
00088 
00089 class ProtocolInfo
00090 {
00091 public:
00092     ~ProtocolInfo();
00093 
00094     QString cmName() const { return mCmName; }
00095 
00096     QString name() const { return mName; }
00097 
00098     const ProtocolParameterList &parameters() const;
00099     bool hasParameter(const QString &name) const;
00100 
00101     bool canRegister() const;
00102 
00103 private:
00104     Q_DISABLE_COPY(ProtocolInfo);
00105 
00106     ProtocolInfo(const QString &cmName, const QString &name);
00107 
00108     void addParameter(const ParamSpec &spec);
00109 
00110     class Private;
00111     friend class Private;
00112     friend class ConnectionManager;
00113     Private *mPriv;
00114     QString mCmName;
00115     QString mName;
00116 };
00117 
00118 
00119 class ConnectionManager : public StatelessDBusProxy,
00120                           private OptionalInterfaceFactory<ConnectionManager>,
00121                           public ReadyObject,
00122                           public RefCounted
00123 {
00124     Q_OBJECT
00125 
00126 public:
00127     static const Feature FeatureCore;
00128 
00129     static ConnectionManagerPtr create(const QString &name);
00130     static ConnectionManagerPtr create(const QDBusConnection &bus,
00131             const QString &name);
00132 
00133     virtual ~ConnectionManager();
00134 
00135     QString name() const;
00136 
00137     QStringList interfaces() const;
00138 
00139     QStringList supportedProtocols() const;
00140     const ProtocolInfoList &protocols() const;
00141 
00142     PendingConnection *requestConnection(const QString &protocol,
00143             const QVariantMap &parameters);
00144 
00145     inline Client::DBus::PropertiesInterface *propertiesInterface() const
00146     {
00147         return OptionalInterfaceFactory<ConnectionManager>::interface<Client::DBus::PropertiesInterface>();
00148     }
00149 
00150     static PendingStringList *listNames(const QDBusConnection &bus = QDBusConnection::sessionBus());
00151 
00152 protected:
00153     ConnectionManager(const QString &name);
00154     ConnectionManager(const QDBusConnection &bus, const QString &name);
00155 
00156     Client::ConnectionManagerInterface *baseInterface() const;
00157 
00158 private Q_SLOTS:
00159     void gotMainProperties(QDBusPendingCallWatcher *);
00160     void gotProtocols(QDBusPendingCallWatcher *);
00161     void gotParameters(QDBusPendingCallWatcher *);
00162 
00163 private:
00164     Q_DISABLE_COPY(ConnectionManager);
00165 
00166     struct Private;
00167     friend struct Private;
00168     friend class PendingConnection;
00169     Private *mPriv;
00170 };
00171 
00172 } // Tp
00173 
00174 #endif


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