00001
00023 #ifndef _TelepathyQt4_channel_factory_h_HEADER_GUARD_
00024 #define _TelepathyQt4_channel_factory_h_HEADER_GUARD_
00025
00026 #ifndef IN_TELEPATHY_QT4_HEADER
00027 #error IN_TELEPATHY_QT4_HEADER
00028 #endif
00029
00030 #include <TelepathyQt4/DBusProxyFactory>
00031 #include <TelepathyQt4/SharedPtr>
00032 #include <TelepathyQt4/Types>
00033
00034
00035 #include <QtGlobal>
00036 #include <QString>
00037 #include <QVariantMap>
00038
00039 class QDBusConnection;
00040
00041 namespace Tp
00042 {
00043
00044 class ChannelClassSpec;
00045
00046 class TELEPATHY_QT4_EXPORT ChannelFactory : public DBusProxyFactory
00047 {
00048 Q_OBJECT
00049 Q_DISABLE_COPY(ChannelFactory)
00050
00051 public:
00052 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00053 struct TELEPATHY_QT4_EXPORT Constructor : public RefCounted
00054 {
00055 virtual ~Constructor() {}
00056
00057 virtual ChannelPtr construct(const ConnectionPtr &conn, const QString &objectPath,
00058 const QVariantMap &immutableProperties) const = 0;
00059 };
00060 typedef SharedPtr<Constructor> ConstructorPtr;
00061 typedef SharedPtr<const Constructor> ConstructorConstPtr;
00062 #endif
00063
00064 static ChannelFactoryPtr create(const QDBusConnection &bus);
00065
00066 virtual ~ChannelFactory();
00067
00068 Features featuresForTextChats(const QVariantMap &additionalProps = QVariantMap()) const;
00069 void addFeaturesForTextChats(const Features &features,
00070 const QVariantMap &additionalProps = QVariantMap());
00071
00072 ConstructorConstPtr constructorForTextChats(
00073 const QVariantMap &additionalProps = QVariantMap()) const;
00074
00075 template<typename Subclass>
00076 void setSubclassForTextChats(const QVariantMap &additionalProps = QVariantMap())
00077 {
00078 setConstructorForTextChats(SubclassCtor<Subclass>::create(), additionalProps);
00079 }
00080
00081 void setConstructorForTextChats(const ConstructorConstPtr &ctor,
00082 const QVariantMap &additionalProps = QVariantMap());
00083
00084 Features featuresForTextChatrooms(const QVariantMap &additionalProps = QVariantMap()) const;
00085 void addFeaturesForTextChatrooms(const Features &features,
00086 const QVariantMap &additionalProps = QVariantMap());
00087
00088 ConstructorConstPtr constructorForTextChatrooms(
00089 const QVariantMap &additionalProps = QVariantMap()) const;
00090
00091 template<typename Subclass>
00092 void setSubclassForTextChatrooms(const QVariantMap &additionalProps = QVariantMap())
00093 {
00094 setConstructorForTextChatrooms(SubclassCtor<Subclass>::create(), additionalProps);
00095 }
00096
00097 void setConstructorForTextChatrooms(const ConstructorConstPtr &ctor,
00098 const QVariantMap &additionalProps = QVariantMap());
00099
00100 Features featuresForStreamedMediaCalls(const QVariantMap &additionalProps = QVariantMap()) const;
00101 void addFeaturesForStreamedMediaCalls(const Features &features,
00102 const QVariantMap &additionalProps = QVariantMap());
00103
00104 ConstructorConstPtr constructorForStreamedMediaCalls(
00105 const QVariantMap &additionalProps = QVariantMap()) const;
00106
00107 template<typename Subclass>
00108 void setSubclassForStreamedMediaCalls(const QVariantMap &additionalProps = QVariantMap())
00109 {
00110 setConstructorForStreamedMediaCalls(SubclassCtor<Subclass>::create(), additionalProps);
00111 }
00112
00113 void setConstructorForStreamedMediaCalls(const ConstructorConstPtr &ctor,
00114 const QVariantMap &additionalProps = QVariantMap());
00115
00116 Features featuresForRoomLists(const QVariantMap &additionalProps = QVariantMap()) const;
00117 void addFeaturesForRoomLists(const Features &features,
00118 const QVariantMap &additionalProps = QVariantMap());
00119
00120 ConstructorConstPtr constructorForRoomLists(
00121 const QVariantMap &additionalProps = QVariantMap()) const;
00122
00123 template<typename Subclass>
00124 void setSubclassForRoomLists(const QVariantMap &additionalProps = QVariantMap())
00125 {
00126 setConstructorForRoomLists(SubclassCtor<Subclass>::create(), additionalProps);
00127 }
00128
00129 void setConstructorForRoomLists(const ConstructorConstPtr &ctor,
00130 const QVariantMap &additionalProps = QVariantMap());
00131
00132 Features featuresForOutgoingFileTransfers(const QVariantMap &additionalProps = QVariantMap()) const;
00133 void addFeaturesForOutgoingFileTransfers(const Features &features,
00134 const QVariantMap &additionalProps = QVariantMap());
00135
00136 ConstructorConstPtr constructorForOutgoingFileTransfers(
00137 const QVariantMap &additionalProps = QVariantMap()) const;
00138
00139 template<typename Subclass>
00140 void setSubclassForOutgoingFileTransfers(const QVariantMap &additionalProps = QVariantMap())
00141 {
00142 setConstructorForOutgoingFileTransfers(SubclassCtor<Subclass>::create(), additionalProps);
00143 }
00144
00145 void setConstructorForOutgoingFileTransfers(const ConstructorConstPtr &ctor,
00146 const QVariantMap &additionalProps = QVariantMap());
00147
00148 Features featuresForIncomingFileTransfers(const QVariantMap &additionalProps = QVariantMap()) const;
00149 void addFeaturesForIncomingFileTransfers(const Features &features,
00150 const QVariantMap &additionalProps = QVariantMap());
00151
00152 ConstructorConstPtr constructorForIncomingFileTransfers(
00153 const QVariantMap &additionalProps = QVariantMap()) const;
00154
00155 template<typename Subclass>
00156 void setSubclassForIncomingFileTransfers(const QVariantMap &additionalProps = QVariantMap())
00157 {
00158 setConstructorForIncomingFileTransfers(SubclassCtor<Subclass>::create(), additionalProps);
00159 }
00160
00161 void setConstructorForIncomingFileTransfers(const ConstructorConstPtr &ctor,
00162 const QVariantMap &additionalProps = QVariantMap());
00163
00164 Features featuresForOutgoingStreamTubes(const QVariantMap &additionalProps = QVariantMap()) const;
00165 void addFeaturesForOutgoingStreamTubes(const Features &features,
00166 const QVariantMap &additionalProps = QVariantMap());
00167
00168 ConstructorConstPtr constructorForOutgoingStreamTubes(
00169 const QVariantMap &additionalProps = QVariantMap()) const;
00170
00171 template<typename Subclass>
00172 void setSubclassForOutgoingStreamTubes(const QVariantMap &additionalProps = QVariantMap())
00173 {
00174 setConstructorForOutgoingStreamTubes(SubclassCtor<Subclass>::create(), additionalProps);
00175 }
00176
00177 void setConstructorForOutgoingStreamTubes(const ConstructorConstPtr &ctor,
00178 const QVariantMap &additionalProps = QVariantMap());
00179
00180 Features featuresForIncomingStreamTubes(const QVariantMap &additionalProps = QVariantMap()) const;
00181 void addFeaturesForIncomingStreamTubes(const Features &features,
00182 const QVariantMap &additionalProps = QVariantMap());
00183
00184 ConstructorConstPtr constructorForIncomingStreamTubes(
00185 const QVariantMap &additionalProps = QVariantMap()) const;
00186
00187 template<typename Subclass>
00188 void setSubclassForIncomingStreamTubes(const QVariantMap &additionalProps = QVariantMap())
00189 {
00190 setConstructorForIncomingStreamTubes(SubclassCtor<Subclass>::create(), additionalProps);
00191 }
00192
00193 void setConstructorForIncomingStreamTubes(const ConstructorConstPtr &ctor,
00194 const QVariantMap &additionalProps = QVariantMap());
00195
00196 Features featuresForOutgoingRoomStreamTubes(const QVariantMap &additionalProps = QVariantMap()) const;
00197 void addFeaturesForOutgoingRoomStreamTubes(const Features &features,
00198 const QVariantMap &additionalProps = QVariantMap());
00199
00200 ConstructorConstPtr constructorForOutgoingRoomStreamTubes(
00201 const QVariantMap &additionalProps = QVariantMap()) const;
00202
00203 template<typename Subclass>
00204 void setSubclassForOutgoingRoomStreamTubes(const QVariantMap &additionalProps = QVariantMap())
00205 {
00206 setConstructorForOutgoingRoomStreamTubes(SubclassCtor<Subclass>::create(), additionalProps);
00207 }
00208
00209 void setConstructorForOutgoingRoomStreamTubes(const ConstructorConstPtr &ctor,
00210 const QVariantMap &additionalProps = QVariantMap());
00211
00212 Features featuresForIncomingRoomStreamTubes(const QVariantMap &additionalProps = QVariantMap()) const;
00213 void addFeaturesForIncomingRoomStreamTubes(const Features &features,
00214 const QVariantMap &additionalProps = QVariantMap());
00215
00216 ConstructorConstPtr constructorForIncomingRoomStreamTubes(
00217 const QVariantMap &additionalProps = QVariantMap()) const;
00218
00219 template<typename Subclass>
00220 void setSubclassForIncomingRoomStreamTubes(const QVariantMap &additionalProps = QVariantMap())
00221 {
00222 setConstructorForIncomingRoomStreamTubes(SubclassCtor<Subclass>::create(), additionalProps);
00223 }
00224
00225 void setConstructorForIncomingRoomStreamTubes(const ConstructorConstPtr &ctor,
00226 const QVariantMap &additionalProps = QVariantMap());
00227
00228 Features featuresForContactSearches(const QVariantMap &additionalProps = QVariantMap()) const;
00229 void addFeaturesForContactSearches(const Features &features,
00230 const QVariantMap &additionalProps = QVariantMap());
00231
00232 ConstructorConstPtr constructorForContactSearches(
00233 const QVariantMap &additionalProps = QVariantMap()) const;
00234
00235 template<typename Subclass>
00236 void setSubclassForContactSearches(const QVariantMap &additionalProps = QVariantMap())
00237 {
00238 setConstructorForContactSearches(SubclassCtor<Subclass>::create(), additionalProps);
00239 }
00240
00241 void setConstructorForContactSearches(const ConstructorConstPtr &ctor,
00242 const QVariantMap &additionalProps = QVariantMap());
00243
00244 Features commonFeatures() const;
00245 void addCommonFeatures(const Features &features);
00246
00247 ConstructorConstPtr fallbackConstructor() const;
00248
00249 template <typename Subclass>
00250 void setFallbackSubclass()
00251 {
00252 setFallbackConstructor(SubclassCtor<Subclass>::create());
00253 }
00254
00255 void setFallbackConstructor(const ConstructorConstPtr &ctor);
00256
00257 Features featuresFor(const ChannelClassSpec &channelClass) const;
00258 void addFeaturesFor(const ChannelClassSpec &channelClass, const Features &features);
00259
00260 template <typename Subclass>
00261 void setSubclassFor(const ChannelClassSpec &channelClass)
00262 {
00263 setConstructorFor(channelClass, SubclassCtor<Subclass>::create());
00264 }
00265
00266 ConstructorConstPtr constructorFor(const ChannelClassSpec &channelClass) const;
00267 void setConstructorFor(const ChannelClassSpec &channelClass, const ConstructorConstPtr &ctor);
00268
00269 PendingReady *proxy(const ConnectionPtr &connection, const QString &channelPath,
00270 const QVariantMap &immutableProperties) const;
00271
00272 protected:
00273 ChannelFactory(const QDBusConnection &bus);
00274
00275 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00276 template <typename Subclass>
00277 struct SubclassCtor : public Constructor
00278 {
00279 static ConstructorPtr create()
00280 {
00281 return ConstructorPtr(new SubclassCtor<Subclass>());
00282 }
00283
00284 virtual ~SubclassCtor() {}
00285
00286 ChannelPtr construct(const ConnectionPtr &conn, const QString &objectPath,
00287 const QVariantMap &immutableProperties) const
00288 {
00289 return Subclass::create(conn, objectPath, immutableProperties);
00290 }
00291 };
00292 #endif
00293
00294 virtual QString finalBusNameFrom(const QString &uniqueOrWellKnown) const;
00295
00296 virtual Features featuresFor(const DBusProxyPtr &proxy) const;
00297
00298 private:
00299 struct Private;
00300 Private *mPriv;
00301 };
00302
00303 }
00304
00305 #endif