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     // FIXME: (API/ABI break) Use TargetHandleType instead of uint
00046     ChannelClassSpec(const QString &channelType, uint targetHandleType,
00047             const QVariantMap &otherProperties = QVariantMap());
00048     // FIXME: (API/ABI break) Use TargetHandleType instead of uint
00049     ChannelClassSpec(const QString &channelType, uint targetHandleType, bool requested,
00050             const QVariantMap &otherProperties = QVariantMap());
00051     ChannelClassSpec(const ChannelClassSpec &other,
00052             const QVariantMap &additionalProperties = QVariantMap());
00053     ~ChannelClassSpec();
00054 
00055     bool isValid() const;
00056 
00057     ChannelClassSpec &operator=(const ChannelClassSpec &other);
00058 
00059     bool operator==(const ChannelClassSpec &other) const
00060     {
00061         return this->isSubsetOf(other) && this->allProperties().size() ==
00062             other.allProperties().size();
00063     }
00064 
00065     bool isSubsetOf(const ChannelClassSpec &other) const;
00066     bool matches(const QVariantMap &immutableProperties) const;
00067 
00068     // TODO: Use new TP_QT4_... constants
00069     QString channelType() const
00070     {
00071         return qdbus_cast<QString>(
00072                 property(QLatin1String(TELEPATHY_INTERFACE_CHANNEL ".ChannelType")));
00073     }
00074 
00075     void setChannelType(const QString &type)
00076     {
00077         setProperty(QLatin1String(TELEPATHY_INTERFACE_CHANNEL ".ChannelType"),
00078                 QVariant::fromValue(type));
00079     }
00080 
00081     // FIXME: (API/ABI break) Use TargetHandleType instead of uint
00082     uint targetHandleType() const
00083     {
00084         return qdbus_cast<uint>(
00085                 property(
00086                     QLatin1String(TELEPATHY_INTERFACE_CHANNEL ".TargetHandleType")));
00087     }
00088 
00089     // FIXME: (API/ABI break) Use TargetHandleType instead of uint
00090     void setTargetHandleType(uint type)
00091     {
00092         setProperty(QLatin1String(TELEPATHY_INTERFACE_CHANNEL ".TargetHandleType"),
00093                 QVariant::fromValue(type));
00094     }
00095 
00096     bool hasRequested() const
00097     {
00098         return hasProperty(QLatin1String(TELEPATHY_INTERFACE_CHANNEL ".Requested"));
00099     }
00100 
00101     bool isRequested() const
00102     {
00103         return qdbus_cast<bool>(
00104                 property(QLatin1String(TELEPATHY_INTERFACE_CHANNEL ".Requested")));
00105     }
00106 
00107     void setRequested(bool requested)
00108     {
00109         setProperty(QLatin1String(TELEPATHY_INTERFACE_CHANNEL ".Requested"),
00110                 QVariant::fromValue(requested));
00111     }
00112 
00113     void unsetRequested()
00114     {
00115         unsetProperty(QLatin1String(TELEPATHY_INTERFACE_CHANNEL ".Requested"));
00116     }
00117 
00118     bool hasStreamedMediaInitialAudioFlag() const
00119     {
00120         return qdbus_cast<bool>(
00121                 property(QLatin1String(TELEPATHY_INTERFACE_CHANNEL_TYPE_STREAMED_MEDIA
00122                         ".InitialAudio")));
00123     }
00124 
00125     void setStreamedMediaInitialAudioFlag()
00126     {
00127         setProperty(QLatin1String(TELEPATHY_INTERFACE_CHANNEL_TYPE_STREAMED_MEDIA ".InitialAudio"),
00128                 QVariant::fromValue(true));
00129     }
00130 
00131     void unsetStreamedMediaInitialAudioFlag()
00132     {
00133         unsetProperty(QLatin1String(TELEPATHY_INTERFACE_CHANNEL_TYPE_STREAMED_MEDIA
00134                     ".InitialAudio"));
00135     }
00136 
00137     bool hasStreamedMediaInitialVideoFlag() const
00138     {
00139         return qdbus_cast<bool>(
00140                 property(QLatin1String(TELEPATHY_INTERFACE_CHANNEL_TYPE_STREAMED_MEDIA
00141                         ".InitialVideo")));
00142     }
00143 
00144     void setStreamedMediaInitialVideoFlag()
00145     {
00146         setProperty(QLatin1String(TELEPATHY_INTERFACE_CHANNEL_TYPE_STREAMED_MEDIA ".InitialVideo"),
00147                 QVariant::fromValue(true));
00148     }
00149 
00150     void unsetStreamedMediaInitialVideoFlag()
00151     {
00152         unsetProperty(QLatin1String(TELEPATHY_INTERFACE_CHANNEL_TYPE_STREAMED_MEDIA
00153                     ".InitialVideo"));
00154     }
00155 
00156     bool hasProperty(const QString &qualifiedName) const;
00157     QVariant property(const QString &qualifiedName) const;
00158 
00159     void setProperty(const QString &qualifiedName, const QVariant &value);
00160     void unsetProperty(const QString &qualifiedName);
00161 
00162     QVariantMap allProperties() const;
00163     ChannelClass bareClass() const;
00164 
00165     static ChannelClassSpec textChat(const QVariantMap &additionalProperties = QVariantMap());
00166     static ChannelClassSpec textChatroom(const QVariantMap &additionalProperties = QVariantMap());
00167     static ChannelClassSpec unnamedTextChat(const QVariantMap &additionalProperties = QVariantMap());
00168 
00169     static ChannelClassSpec streamedMediaCall(const QVariantMap &additionalProperties = QVariantMap());
00170     static ChannelClassSpec streamedMediaAudioCall(const QVariantMap &additionalProperties =
00171             QVariantMap());
00172     static ChannelClassSpec streamedMediaVideoCall(const QVariantMap &additionalProperties =
00173             QVariantMap());
00174     static ChannelClassSpec streamedMediaVideoCallWithAudio(const QVariantMap &additionalProperties =
00175             QVariantMap());
00176 
00177     static ChannelClassSpec unnamedStreamedMediaCall(const QVariantMap &additionalProperties =
00178             QVariantMap());
00179     static ChannelClassSpec unnamedStreamedMediaAudioCall(const QVariantMap &additionalProperties =
00180             QVariantMap());
00181     static ChannelClassSpec unnamedStreamedMediaVideoCall(const QVariantMap &additionalProperties =
00182             QVariantMap());
00183     static ChannelClassSpec unnamedStreamedMediaVideoCallWithAudio(const QVariantMap &additionalProperties =
00184             QVariantMap());
00185 
00186     // TODO: add Call when it's undrafted
00187     static ChannelClassSpec roomList(const QVariantMap &additionalProperties = QVariantMap());
00188     static ChannelClassSpec outgoingFileTransfer(const QVariantMap &additionalProperties = QVariantMap());
00189     static ChannelClassSpec incomingFileTransfer(const QVariantMap &additionalProperties = QVariantMap());
00190     // TODO: add dbus tubes, stream tubes when they're implemented
00191     static ChannelClassSpec contactSearch(const QVariantMap &additionalProperties = QVariantMap());
00192 
00193 private:
00194     struct Private;
00195     friend struct Private;
00196     QSharedDataPointer<Private> mPriv;
00197 };
00198 
00199 class TELEPATHY_QT4_EXPORT ChannelClassSpecList :
00200                 public QList<ChannelClassSpec>
00201 {
00202 public:
00203     ChannelClassSpecList() { }
00204 
00205     ChannelClassSpecList(const ChannelClassSpec &spec)
00206     {
00207         append(spec);
00208     }
00209 
00210     ChannelClassSpecList(const QList<ChannelClassSpec> &other)
00211         : QList<ChannelClassSpec>(other)
00212     {
00213     }
00214 
00215     ChannelClassSpecList(const ChannelClassList &classes)
00216     {
00217         // Why doesn't Qt have range constructors like STL... stupid, so stupid.
00218         Q_FOREACH (const ChannelClass &cc, classes) {
00219             append(cc);
00220         }
00221     }
00222 
00223     ChannelClassList bareClasses() const
00224     {
00225         ChannelClassList list;
00226         Q_FOREACH (const ChannelClassSpec &spec, *this) {
00227             list.append(spec.bareClass());
00228         }
00229         return list;
00230     }
00231 };
00232 
00233 } // Tp
00234 
00235 Q_DECLARE_METATYPE(Tp::ChannelClassSpec);
00236 Q_DECLARE_METATYPE(Tp::ChannelClassSpecList);
00237 
00238 #endif


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