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

channel-factory.h

00001 /*
00002  * This file is part of TelepathyQt4
00003  *
00004  * Copyright (C) 2009-2010 Collabora Ltd. <http://www.collabora.co.uk/>
00005  * Copyright (C) 2009-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_channel_factory_h_HEADER_GUARD_
00023 #define _TelepathyQt4_channel_factory_h_HEADER_GUARD_
00024 
00025 #include <TelepathyQt4/DBusProxyFactory>
00026 #include <TelepathyQt4/SharedPtr>
00027 #include <TelepathyQt4/Types>
00028 
00029 // For Q_DISABLE_COPY
00030 #include <QtGlobal>
00031 #include <QString>
00032 #include <QVariantMap>
00033 
00034 class QDBusConnection;
00035 
00036 namespace Tp
00037 {
00038 
00039 class ChannelClassSpec;
00040 
00041 class TELEPATHY_QT4_EXPORT ChannelFactory : public DBusProxyFactory
00042 {
00043     Q_DISABLE_COPY(ChannelFactory)
00044 
00045 public:
00046     struct TELEPATHY_QT4_EXPORT Constructor : public RefCounted
00047     {
00048         virtual ~Constructor() {}
00049 
00050         virtual ChannelPtr construct(const ConnectionPtr &conn, const QString &objectPath,
00051                 const QVariantMap &immutableProperties) const = 0;
00052     };
00053     typedef SharedPtr<Constructor> ConstructorPtr;
00054     typedef SharedPtr<const Constructor> ConstructorConstPtr;
00055 
00056     static ChannelFactoryPtr create(const QDBusConnection &bus);
00057 
00058     virtual ~ChannelFactory();
00059 
00060     Features featuresForTextChats(const QVariantMap &additionalProps = QVariantMap()) const;
00061     void addFeaturesForTextChats(const Features &features,
00062             const QVariantMap &additionalProps = QVariantMap());
00063 
00064     ConstructorConstPtr constructorForTextChats(
00065             const QVariantMap &additionalProps = QVariantMap()) const;
00066 
00067     template<typename Subclass>
00068     void setSubclassForTextChats(const QVariantMap &additionalProps = QVariantMap())
00069     {
00070         setConstructorForTextChats(SubclassCtor<Subclass>::create(), additionalProps);
00071     }
00072 
00073     void setConstructorForTextChats(const ConstructorConstPtr &ctor,
00074             const QVariantMap &additionalProps = QVariantMap());
00075 
00076     Features featuresForTextChatrooms(const QVariantMap &additionalProps = QVariantMap()) const;
00077     void addFeaturesForTextChatrooms(const Features &features,
00078             const QVariantMap &additionalProps = QVariantMap());
00079 
00080     ConstructorConstPtr constructorForTextChatrooms(
00081             const QVariantMap &additionalProps = QVariantMap()) const;
00082 
00083     template<typename Subclass>
00084     void setSubclassForTextChatrooms(const QVariantMap &additionalProps = QVariantMap())
00085     {
00086         setConstructorForTextChatrooms(SubclassCtor<Subclass>::create(), additionalProps);
00087     }
00088 
00089     void setConstructorForTextChatrooms(const ConstructorConstPtr &ctor,
00090             const QVariantMap &additionalProps = QVariantMap());
00091 
00092     Features featuresForStreamedMediaCalls(const QVariantMap &additionalProps = QVariantMap()) const;
00093     void addFeaturesForStreamedMediaCalls(const Features &features,
00094             const QVariantMap &additionalProps = QVariantMap());
00095 
00096     ConstructorConstPtr constructorForStreamedMediaCalls(
00097             const QVariantMap &additionalProps = QVariantMap()) const;
00098 
00099     template<typename Subclass>
00100     void setSubclassForStreamedMediaCalls(const QVariantMap &additionalProps = QVariantMap())
00101     {
00102         setConstructorForStreamedMediaCalls(SubclassCtor<Subclass>::create(), additionalProps);
00103     }
00104 
00105     void setConstructorForStreamedMediaCalls(const ConstructorConstPtr &ctor,
00106             const QVariantMap &additionalProps = QVariantMap());
00107 
00108     Features featuresForRoomLists(const QVariantMap &additionalProps = QVariantMap()) const;
00109     void addFeaturesForRoomLists(const Features &features,
00110             const QVariantMap &additionalProps = QVariantMap());
00111 
00112     ConstructorConstPtr constructorForRoomLists(
00113             const QVariantMap &additionalProps = QVariantMap()) const;
00114 
00115     template<typename Subclass>
00116     void setSubclassForRoomLists(const QVariantMap &additionalProps = QVariantMap())
00117     {
00118         setConstructorForRoomLists(SubclassCtor<Subclass>::create(), additionalProps);
00119     }
00120 
00121     void setConstructorForRoomLists(const ConstructorConstPtr &ctor,
00122             const QVariantMap &additionalProps = QVariantMap());
00123 
00124     Features featuresForOutgoingFileTransfers(const QVariantMap &additionalProps = QVariantMap()) const;
00125     void addFeaturesForOutgoingFileTransfers(const Features &features,
00126             const QVariantMap &additionalProps = QVariantMap());
00127 
00128     ConstructorConstPtr constructorForOutgoingFileTransfers(
00129             const QVariantMap &additionalProps = QVariantMap()) const;
00130 
00131     template<typename Subclass>
00132     void setSubclassForOutgoingFileTransfers(const QVariantMap &additionalProps = QVariantMap())
00133     {
00134         setConstructorForOutgoingFileTransfers(SubclassCtor<Subclass>::create(), additionalProps);
00135     }
00136 
00137     void setConstructorForOutgoingFileTransfers(const ConstructorConstPtr &ctor,
00138             const QVariantMap &additionalProps = QVariantMap());
00139 
00140     Features featuresForIncomingFileTransfers(const QVariantMap &additionalProps = QVariantMap()) const;
00141     void addFeaturesForIncomingFileTransfers(const Features &features,
00142             const QVariantMap &additionalProps = QVariantMap());
00143 
00144     ConstructorConstPtr constructorForIncomingFileTransfers(
00145             const QVariantMap &additionalProps = QVariantMap()) const;
00146 
00147     template<typename Subclass>
00148     void setSubclassForIncomingFileTransfers(const QVariantMap &additionalProps = QVariantMap())
00149     {
00150         setConstructorForIncomingFileTransfers(SubclassCtor<Subclass>::create(), additionalProps);
00151     }
00152 
00153     void setConstructorForIncomingFileTransfers(const ConstructorConstPtr &ctor,
00154             const QVariantMap &additionalProps = QVariantMap());
00155 
00156     Features featuresForContactSearches(const QVariantMap &additionalProps = QVariantMap()) const;
00157     void addFeaturesForContactSearches(const Features &features,
00158             const QVariantMap &additionalProps = QVariantMap());
00159 
00160     ConstructorConstPtr constructorForContactSearches(
00161             const QVariantMap &additionalProps = QVariantMap()) const;
00162 
00163     template<typename Subclass>
00164     void setSubclassForContactSearches(const QVariantMap &additionalProps = QVariantMap())
00165     {
00166         setConstructorForContactSearches(SubclassCtor<Subclass>::create(), additionalProps);
00167     }
00168 
00169     void setConstructorForContactSearches(const ConstructorConstPtr &ctor,
00170             const QVariantMap &additionalProps = QVariantMap());
00171 
00172     // When merged, Tube channels should have export/import variants too like FT has for send/receive
00173 
00174     Features commonFeatures() const;
00175     void addCommonFeatures(const Features &features);
00176 
00177     ConstructorConstPtr fallbackConstructor() const;
00178 
00179     template <typename Subclass>
00180     void setFallbackSubclass()
00181     {
00182         setFallbackConstructor(SubclassCtor<Subclass>::create());
00183     }
00184 
00185     void setFallbackConstructor(const ConstructorConstPtr &ctor);
00186 
00187     Features featuresFor(const ChannelClassSpec &channelClass) const;
00188     void addFeaturesFor(const ChannelClassSpec &channelClass, const Features &features);
00189 
00190     template <typename Subclass>
00191     void setSubclassFor(const ChannelClassSpec &channelClass)
00192     {
00193         setConstructorFor(channelClass, SubclassCtor<Subclass>::create());
00194     }
00195 
00196     ConstructorConstPtr constructorFor(const ChannelClassSpec &channelClass) const;
00197     void setConstructorFor(const ChannelClassSpec &channelClass, const ConstructorConstPtr &ctor);
00198 
00199     PendingReady *proxy(const ConnectionPtr &connection, const QString &channelPath,
00200             const QVariantMap &immutableProperties) const;
00201 
00202 protected:
00203     ChannelFactory(const QDBusConnection &bus);
00204 
00205     template <typename Subclass>
00206     struct SubclassCtor : public Constructor
00207     {
00208         static ConstructorPtr create()
00209         {
00210             return ConstructorPtr(new SubclassCtor<Subclass>());
00211         }
00212 
00213         virtual ~SubclassCtor() {}
00214 
00215         ChannelPtr construct(const ConnectionPtr &conn, const QString &objectPath,
00216                 const QVariantMap &immutableProperties) const
00217         {
00218             return Subclass::create(conn, objectPath, immutableProperties);
00219         }
00220     };
00221 
00222     virtual QString finalBusNameFrom(const QString &uniqueOrWellKnown) const;
00223     // Nothing we'd like to prepare()
00224     virtual Features featuresFor(const SharedPtr<RefCounted> &proxy) const;
00225 
00226 private:
00227     struct Private;
00228     Private *mPriv;
00229 };
00230 
00231 } // Tp
00232 
00233 #endif


Copyright © 2008-2010 Collabora Ltd. and Nokia Corporation
Telepathy-Qt4 0.4.4