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


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