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


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