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


Copyright © 2008-2011 Collabora Ltd. and Nokia Corporation
Telepathy-Qt4 0.8.0