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

channel-class-spec.h

00001 /*
00002  * This file is part of TelepathyQt4
00003  *
00004  * Copyright (C) 2010 Collabora Ltd. <http://www.collabora.co.uk/>
00005  * Copyright (C) 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_channel_class_spec_h_HEADER_GUARD_
00023 #define _TelepathyQt4_channel_class_spec_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/Global>
00031 #include <TelepathyQt4/Types>
00032 
00033 #include <QSharedDataPointer>
00034 #include <QVariant>
00035 
00036 namespace Tp
00037 {
00038 
00039 class TELEPATHY_QT4_EXPORT ChannelClassSpec
00040 {
00041 public:
00042     ChannelClassSpec();
00043     ChannelClassSpec(const ChannelClass &cc);
00044     ChannelClassSpec(const QVariantMap &props);
00045     ChannelClassSpec(const QString &channelType, uint targetHandleType,
00046             const QVariantMap &otherProperties = QVariantMap());
00047     ChannelClassSpec(const QString &channelType, uint targetHandleType, bool requested,
00048             const QVariantMap &otherProperties = QVariantMap());
00049     ChannelClassSpec(const ChannelClassSpec &other,
00050             const QVariantMap &additionalProperties = QVariantMap());
00051     ~ChannelClassSpec();
00052 
00053     bool isValid() const;
00054 
00055     ChannelClassSpec &operator=(const ChannelClassSpec &other);
00056 
00057     bool operator==(const ChannelClassSpec &other) const
00058     {
00059         return this->isSubsetOf(other) && this->allProperties().size() ==
00060             other.allProperties().size();
00061     }
00062 
00063     bool isSubsetOf(const ChannelClassSpec &other) const;
00064     bool matches(const QVariantMap &immutableProperties) const;
00065 
00066     QString channelType() const
00067     {
00068         return qdbus_cast<QString>(
00069                 property(QLatin1String(TELEPATHY_INTERFACE_CHANNEL ".ChannelType")));
00070     }
00071 
00072     void setChannelType(const QString &type)
00073     {
00074         setProperty(QLatin1String(TELEPATHY_INTERFACE_CHANNEL ".ChannelType"),
00075                 QVariant::fromValue(type));
00076     }
00077 
00078     uint targetHandleType() const
00079     {
00080         return qdbus_cast<uint>(
00081                 property(
00082                     QLatin1String(TELEPATHY_INTERFACE_CHANNEL ".TargetHandleType")));
00083     }
00084 
00085     void setTargetHandleType(uint type)
00086     {
00087         setProperty(QLatin1String(TELEPATHY_INTERFACE_CHANNEL ".TargetHandleType"),
00088                 QVariant::fromValue(type));
00089     }
00090 
00091     bool hasRequested() const
00092     {
00093         return hasProperty(QLatin1String(TELEPATHY_INTERFACE_CHANNEL ".Requested"));
00094     }
00095 
00096     bool isRequested() const
00097     {
00098         return qdbus_cast<bool>(
00099                 property(QLatin1String(TELEPATHY_INTERFACE_CHANNEL ".Requested")));
00100     }
00101 
00102     void setRequested(bool requested)
00103     {
00104         setProperty(QLatin1String(TELEPATHY_INTERFACE_CHANNEL ".Requested"),
00105                 QVariant::fromValue(requested));
00106     }
00107 
00108     void unsetRequested()
00109     {
00110         unsetProperty(QLatin1String(TELEPATHY_INTERFACE_CHANNEL ".Requested"));
00111     }
00112 
00113     bool hasStreamedMediaInitialAudioFlag() const
00114     {
00115         return qdbus_cast<bool>(
00116                 property(QLatin1String(TELEPATHY_INTERFACE_CHANNEL_TYPE_STREAMED_MEDIA
00117                         ".InitialAudio")));
00118     }
00119 
00120     void setStreamedMediaInitialAudioFlag()
00121     {
00122         setProperty(QLatin1String(TELEPATHY_INTERFACE_CHANNEL_TYPE_STREAMED_MEDIA ".InitialAudio"),
00123                 QVariant::fromValue(true));
00124     }
00125 
00126     void unsetStreamedMediaInitialAudioFlag()
00127     {
00128         unsetProperty(QLatin1String(TELEPATHY_INTERFACE_CHANNEL_TYPE_STREAMED_MEDIA
00129                     ".InitialAudio"));
00130     }
00131 
00132     bool hasStreamedMediaInitialVideoFlag() const
00133     {
00134         return qdbus_cast<bool>(
00135                 property(QLatin1String(TELEPATHY_INTERFACE_CHANNEL_TYPE_STREAMED_MEDIA
00136                         ".InitialVideo")));
00137     }
00138 
00139     void setStreamedMediaInitialVideoFlag()
00140     {
00141         setProperty(QLatin1String(TELEPATHY_INTERFACE_CHANNEL_TYPE_STREAMED_MEDIA ".InitialVideo"),
00142                 QVariant::fromValue(true));
00143     }
00144 
00145     void unsetStreamedMediaInitialVideoFlag()
00146     {
00147         unsetProperty(QLatin1String(TELEPATHY_INTERFACE_CHANNEL_TYPE_STREAMED_MEDIA
00148                     ".InitialVideo"));
00149     }
00150 
00151     bool hasProperty(const QString &qualifiedName) const;
00152     QVariant property(const QString &qualifiedName) const;
00153 
00154     void setProperty(const QString &qualifiedName, const QVariant &value);
00155     void unsetProperty(const QString &qualifiedName);
00156 
00157     QVariantMap allProperties() const;
00158     ChannelClass bareClass() const;
00159 
00160     static ChannelClassSpec textChat(const QVariantMap &additionalProperties = QVariantMap());
00161     static ChannelClassSpec textChatroom(const QVariantMap &additionalProperties = QVariantMap());
00162     static ChannelClassSpec streamedMediaCall(const QVariantMap &additionalProperties = QVariantMap());
00163     static ChannelClassSpec streamedMediaAudioCall(const QVariantMap &additionalProperties =
00164             QVariantMap());
00165     static ChannelClassSpec streamedMediaVideoCall(const QVariantMap &additionalProperties =
00166             QVariantMap());
00167     static ChannelClassSpec streamedMediaVideoCallWithAudio(const QVariantMap &additionalProperties =
00168             QVariantMap());
00169     // TODO: add Call when it's undrafted
00170     static ChannelClassSpec roomList(const QVariantMap &additionalProperties = QVariantMap());
00171     static ChannelClassSpec outgoingFileTransfer(const QVariantMap &additionalProperties = QVariantMap());
00172     static ChannelClassSpec incomingFileTransfer(const QVariantMap &additionalProperties = QVariantMap());
00173     // TODO: add dbus tubes, stream tubes when they're implemented
00174     static ChannelClassSpec contactSearch(const QVariantMap &additionalProperties = QVariantMap());
00175 
00176 private:
00177     struct Private;
00178     friend struct Private;
00179     QSharedDataPointer<Private> mPriv;
00180 };
00181 
00182 class TELEPATHY_QT4_EXPORT ChannelClassSpecList :
00183                 public QList<ChannelClassSpec>
00184 {
00185 public:
00186     ChannelClassSpecList() { }
00187 
00188     ChannelClassSpecList(const ChannelClassSpec &spec)
00189     {
00190         append(spec);
00191     }
00192 
00193     ChannelClassSpecList(const QList<ChannelClassSpec> &other)
00194         : QList<ChannelClassSpec>(other)
00195     {
00196     }
00197 
00198     ChannelClassSpecList(const ChannelClassList &classes)
00199     {
00200         // Why doesn't Qt have range constructors like STL... stupid, so stupid.
00201         Q_FOREACH (const ChannelClass &cc, classes) {
00202             append(cc);
00203         }
00204     }
00205 
00206     ChannelClassList bareClasses() const
00207     {
00208         ChannelClassList list;
00209         Q_FOREACH (const ChannelClassSpec &spec, *this) {
00210             list.append(spec.bareClass());
00211         }
00212         return list;
00213     }
00214 };
00215 
00216 } // Tp
00217 
00218 #endif


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