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

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