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

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


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