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

abstract-client.h

    00001
    00023 #ifndef _TelepathyQt_abstract_client_h_HEADER_GUARD_
    00024 #define _TelepathyQt_abstract_client_h_HEADER_GUARD_
    00025
    00026 #ifndef IN_TP_QT_HEADER
    00027 #error IN_TP_QT_HEADER
    00028 #endif
    00029
    00030 #include <TelepathyQt/Constants>
    00031 #include <TelepathyQt/SharedPtr>
    00032 #include <TelepathyQt/Types>
    00033
    00034 #include <QList>
    00035 #include <QObject>
    00036 #include <QSharedDataPointer>
    00037 #include <QString>
    00038 #include <QVariantMap>
    00039
    00040 namespace Tp
    00041 {
    00042
    00043 class ClientRegistrar;
    00044 class ChannelClassSpecList;
    00045
    00046 class TP_QT_EXPORT AbstractClient : public RefCounted
    00047 {
    00048     Q_DISABLE_COPY(AbstractClient)
    00049
    00050 public:
    00051     AbstractClient();
    00052     virtual ~AbstractClient();
    00053
    00054     bool isRegistered() const;
    00055
    00056 private:
    00057     friend class ClientRegistrar;
    00058
    00059     void setRegistered(bool registered);
    00060
    00061     struct Private;
    00062     friend struct Private;
    00063     Private *mPriv;
    00064 };
    00065
    00066 class TP_QT_EXPORT AbstractClientObserver : public virtual AbstractClient
    00067 {
    00068     Q_DISABLE_COPY(AbstractClientObserver)
    00069
    00070 public:
    00071     class ObserverInfo
    00072     {
    00073     public:
    00074         ObserverInfo(const QVariantMap &info = QVariantMap());
    00075         ObserverInfo(const ObserverInfo &other);
    00076         ~ObserverInfo();
    00077
    00078         ObserverInfo &operator=(const ObserverInfo &other);
    00079
    00080         bool isRecovering() const { return qdbus_cast<bool>(allInfo().value(QLatin1String("recovering"))); }
    00081
    00082         QVariantMap allInfo() const;
    00083
    00084     private:
    00085         struct Private;
    00086         QSharedDataPointer<Private> mPriv;
    00087     };
    00088
    00089     virtual ~AbstractClientObserver();
    00090
    00091     ChannelClassSpecList observerFilter() const;
    00092
    00093     bool shouldRecover() const;
    00094
    00095     virtual void observeChannels(const MethodInvocationContextPtr<> &context,
    00096             const AccountPtr &account,
    00097             const ConnectionPtr &connection,
    00098             const QList<ChannelPtr> &channels,
    00099             const ChannelDispatchOperationPtr &dispatchOperation,
    00100             const QList<ChannelRequestPtr> &requestsSatisfied,
    00101             const ObserverInfo &observerInfo) = 0;
    00102
    00103 protected:
    00104     AbstractClientObserver(const ChannelClassSpecList &channelFilter, bool shouldRecover = false);
    00105
    00106 private:
    00107     struct Private;
    00108     friend struct Private;
    00109     Private *mPriv;
    00110 };
    00111
    00112 class TP_QT_EXPORT AbstractClientApprover : public virtual AbstractClient
    00113 {
    00114     Q_DISABLE_COPY(AbstractClientApprover)
    00115
    00116 public:
    00117     virtual ~AbstractClientApprover();
    00118
    00119     ChannelClassSpecList approverFilter() const;
    00120
    00121     virtual void addDispatchOperation(const MethodInvocationContextPtr<> &context,
    00122             const ChannelDispatchOperationPtr &dispatchOperation) = 0;
    00123
    00124 protected:
    00125     AbstractClientApprover(const ChannelClassSpecList &channelFilter);
    00126
    00127 private:
    00128     struct Private;
    00129     friend struct Private;
    00130     Private *mPriv;
    00131 };
    00132
    00133 /*
    00134  * TODO: use case specific subclasses:
    00135  *  - StreamTubeHandler(QString(List) protocol(s))
    00136  *    - handleTube(DBusTubeChannelPtr, userActionTime)
    00137  *  - DBusTubeHandler(QString(List) serviceName(s))
    00138  *    - handleTube(DBusTubeChannelPtr, userActionTime)
    00139  */
    00140 class TP_QT_EXPORT AbstractClientHandler : public virtual AbstractClient
    00141 {
    00142     Q_DISABLE_COPY(AbstractClientHandler)
    00143
    00144 public:
    00145     class Capabilities
    00146     {
    00147     public:
    00148         Capabilities(const QStringList &tokens = QStringList());
    00149         Capabilities(const Capabilities &other);
    00150         ~Capabilities();
    00151
    00152         Capabilities &operator=(const Capabilities &other);
    00153
    00154         bool hasGTalkP2PNATTraversalToken() const
    00155         {
    00156             return hasToken(TP_QT_IFACE_CHANNEL_INTERFACE_MEDIA_SIGNALLING +
    00157                 QLatin1String("/gtalk-p2p"));
    00158         }
    00159
    00160         void setGTalkP2PNATTraversalToken()
    00161         {
    00162             setToken(TP_QT_IFACE_CHANNEL_INTERFACE_MEDIA_SIGNALLING +
    00163                 QLatin1String("/gtalk-p2p"));
    00164         }
    00165
    00166         void unsetGTalkP2PNATTraversalToken()
    00167         {
    00168             unsetToken(TP_QT_IFACE_CHANNEL_INTERFACE_MEDIA_SIGNALLING +
    00169                 QLatin1String("/gtalk-p2p"));
    00170         }
    00171
    00172         bool hasICEUDPNATTraversalToken() const
    00173         {
    00174             return hasToken(TP_QT_IFACE_CHANNEL_INTERFACE_MEDIA_SIGNALLING +
    00175                 QLatin1String("/ice-udp"));
    00176         }
    00177
    00178         void setICEUDPNATTraversalToken()
    00179         {
    00180             setToken(TP_QT_IFACE_CHANNEL_INTERFACE_MEDIA_SIGNALLING +
    00181                 QLatin1String("/ice-udp"));
    00182         }
    00183
    00184         void unsetICEUDPNATTraversalToken()
    00185         {
    00186             unsetToken(TP_QT_IFACE_CHANNEL_INTERFACE_MEDIA_SIGNALLING +
    00187                 QLatin1String("/ice-udp"));
    00188         }
    00189
    00190         bool hasWLM85NATTraversalToken() const
    00191         {
    00192             return hasToken(TP_QT_IFACE_CHANNEL_INTERFACE_MEDIA_SIGNALLING +
    00193                 QLatin1String("/wlm-8.5"));
    00194         }
    00195
    00196         void setWLM85NATTraversalToken()
    00197         {
    00198             setToken(TP_QT_IFACE_CHANNEL_INTERFACE_MEDIA_SIGNALLING +
    00199                 QLatin1String("/wlm-8.5"));
    00200         }
    00201
    00202         void unsetWLM85NATTraversalToken()
    00203         {
    00204             unsetToken(TP_QT_IFACE_CHANNEL_INTERFACE_MEDIA_SIGNALLING +
    00205                 QLatin1String("/wlm-8.5"));
    00206         }
    00207
    00208         bool hasWLM2009NATTraversalToken() const
    00209         {
    00210             return hasToken(TP_QT_IFACE_CHANNEL_INTERFACE_MEDIA_SIGNALLING +
    00211                 QLatin1String("/wlm-2009"));
    00212         }
    00213
    00214         void setWLM2009NATTraversalToken()
    00215         {
    00216             setToken(TP_QT_IFACE_CHANNEL_INTERFACE_MEDIA_SIGNALLING +
    00217                 QLatin1String("/wlm-2009"));
    00218         }
    00219
    00220         void unsetWLM2009NATTraversalToken()
    00221         {
    00222             unsetToken(TP_QT_IFACE_CHANNEL_INTERFACE_MEDIA_SIGNALLING +
    00223                 QLatin1String("/wlm-2009"));
    00224         }
    00225
    00226         bool hasAudioCodecToken(const QString &mimeSubType) const
    00227         {
    00228             return hasToken(TP_QT_IFACE_CHANNEL_INTERFACE_MEDIA_SIGNALLING +
    00229                 QLatin1String("/audio/") + mimeSubType.toLower());
    00230         }
    00231
    00232         void setAudioCodecToken(const QString &mimeSubType)
    00233         {
    00234             setToken(TP_QT_IFACE_CHANNEL_INTERFACE_MEDIA_SIGNALLING +
    00235                 QLatin1String("/audio/") + mimeSubType.toLower());
    00236         }
    00237
    00238         void unsetAudioCodecToken(const QString &mimeSubType)
    00239         {
    00240             unsetToken(TP_QT_IFACE_CHANNEL_INTERFACE_MEDIA_SIGNALLING +
    00241                 QLatin1String("/audio/") + mimeSubType.toLower());
    00242         }
    00243
    00244         bool hasVideoCodecToken(const QString &mimeSubType) const
    00245         {
    00246             return hasToken(TP_QT_IFACE_CHANNEL_INTERFACE_MEDIA_SIGNALLING +
    00247                 QLatin1String("/video/") + mimeSubType.toLower());
    00248         }
    00249
    00250         void setVideoCodecToken(const QString &mimeSubType)
    00251         {
    00252             setToken(TP_QT_IFACE_CHANNEL_INTERFACE_MEDIA_SIGNALLING +
    00253                 QLatin1String("/video/") + mimeSubType.toLower());
    00254         }
    00255
    00256         void unsetVideoCodecToken(const QString &mimeSubType)
    00257         {
    00258             unsetToken(TP_QT_IFACE_CHANNEL_INTERFACE_MEDIA_SIGNALLING +
    00259                 QLatin1String("/video/") + mimeSubType.toLower());
    00260         }
    00261
    00262         bool hasToken(const QString &token) const;
    00263         void setToken(const QString &token);
    00264         void unsetToken(const QString &token);
    00265
    00266         QStringList allTokens() const;
    00267
    00268     private:
    00269         struct Private;
    00270         QSharedDataPointer<Private> mPriv;
    00271     };
    00272
    00273     class HandlerInfo
    00274     {
    00275     public:
    00276         HandlerInfo(const QVariantMap &info = QVariantMap());
    00277         HandlerInfo(const HandlerInfo &other);
    00278         ~HandlerInfo();
    00279
    00280         HandlerInfo &operator=(const HandlerInfo &other);
    00281
    00282         QVariantMap allInfo() const;
    00283
    00284     private:
    00285         struct Private;
    00286         QSharedDataPointer<Private> mPriv;
    00287     };
    00288
    00289     virtual ~AbstractClientHandler();
    00290
    00291     ChannelClassSpecList handlerFilter() const;
    00292
    00293     Capabilities handlerCapabilities() const;
    00294
    00295     virtual bool bypassApproval() const = 0;
    00296
    00297     virtual void handleChannels(const MethodInvocationContextPtr<> &context,
    00298             const AccountPtr &account,
    00299             const ConnectionPtr &connection,
    00300             const QList<ChannelPtr> &channels,
    00301             const QList<ChannelRequestPtr> &requestsSatisfied,
    00302             const QDateTime &userActionTime,
    00303             const HandlerInfo &handlerInfo) = 0;
    00304
    00305     bool wantsRequestNotification() const;
    00306     virtual void addRequest(const ChannelRequestPtr &request);
    00307     virtual void removeRequest(const ChannelRequestPtr &request,
    00308             const QString &errorName, const QString &errorMessage);
    00309
    00310 protected:
    00311     AbstractClientHandler(const ChannelClassSpecList &channelFilter,
    00312             const Capabilities &capabilities = Capabilities(),
    00313             bool wantsRequestNotification = false);
    00314
    00315 private:
    00316     struct Private;
    00317     friend struct Private;
    00318     Private *mPriv;
    00319 };
    00320
    00321 } // Tp
    00322
    00323 Q_DECLARE_METATYPE(Tp::AbstractClientObserver::ObserverInfo);
    00324 Q_DECLARE_METATYPE(Tp::AbstractClientHandler::Capabilities);
    00325 Q_DECLARE_METATYPE(Tp::AbstractClientHandler::HandlerInfo);
    00326
    00327 #endif