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

call-channel.h

00001 /*
00002  * This file is part of TelepathyQt4Yell
00003  *
00004  * Copyright (C) 2010 Collabora Ltd. <http://www.collabora.co.uk/>
00005  *
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Lesser General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2.1 of the License, or (at your option) any later version.
00010  *
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with this library; if not, write to the Free Software
00018  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00019  */
00020 
00021 #ifndef _TelepathyQt4Yell_call_channel_h_HEADER_GUARD_
00022 #define _TelepathyQt4Yell_call_channel_h_HEADER_GUARD_
00023 
00024 #ifndef IN_TELEPATHY_QT4_YELL_HEADER
00025 #error IN_TELEPATHY_QT4_YELL_HEADER
00026 #endif
00027 
00028 #include <TelepathyQt4Yell/Channel>
00029 #include <TelepathyQt4Yell/Constants>
00030 #include <TelepathyQt4Yell/Types>
00031 
00032 #include <TelepathyQt4/Channel>
00033 #include <TelepathyQt4/ChannelClassSpec>
00034 #include <TelepathyQt4/ChannelFactory>
00035 #include <TelepathyQt4/PendingOperation>
00036 #include <TelepathyQt4/Types>
00037 #include <TelepathyQt4/SharedPtr>
00038 
00039 namespace Tpy
00040 {
00041 
00042 class CallChannel;
00043 
00044 typedef QList<CallContentPtr> CallContents;
00045 typedef QList<CallStreamPtr> CallStreams;
00046 
00047 class TELEPATHY_QT4_YELL_EXPORT CallStream : public Tp::StatefulDBusProxy,
00048                     public Tp::OptionalInterfaceFactory<CallStream>
00049 {
00050     Q_OBJECT
00051     Q_DISABLE_COPY(CallStream)
00052 
00053 public:
00054     ~CallStream();
00055 
00056     CallContentPtr content() const;
00057 
00058     Tp::Contacts members() const;
00059 
00060     SendingState localSendingState() const;
00061     SendingState remoteSendingState(const Tp::ContactPtr &contact) const;
00062 
00063     Tp::PendingOperation *requestSending(bool send);
00064     Tp::PendingOperation *requestReceiving(const Tp::ContactPtr &contact, bool receive);
00065 
00066 Q_SIGNALS:
00067     void localSendingStateChanged(Tpy::SendingState localSendingState);
00068     void remoteSendingStateChanged(
00069             const QHash<Tp::ContactPtr, Tpy::SendingState> &remoteSendingStates);
00070     void remoteMembersRemoved(const Tp::Contacts &remoteMembers);
00071 
00072 private Q_SLOTS:
00073     void gotMainProperties(QDBusPendingCallWatcher *watcher);
00074     void gotRemoteMembersContacts(Tp::PendingOperation *op);
00075 
00076     void onRemoteMembersChanged(const Tpy::ContactSendingStateMap &updates,
00077             const Tpy::UIntList &removed);
00078     void onLocalSendingStateChanged(uint);
00079 
00080 private:
00081     friend class CallChannel;
00082     friend class CallContent;
00083 
00084     static const Tp::Feature FeatureCore;
00085 
00086     CallStream(const CallContentPtr &content, const QDBusObjectPath &streamPath);
00087 
00088     struct Private;
00089     friend struct Private;
00090     Private *mPriv;
00091 };
00092 
00093 class TELEPATHY_QT4_YELL_EXPORT PendingCallContent : public Tp::PendingOperation
00094 {
00095     Q_OBJECT
00096     Q_DISABLE_COPY(PendingCallContent)
00097 
00098 public:
00099     ~PendingCallContent();
00100 
00101     CallContentPtr content() const;
00102 
00103 private Q_SLOTS:
00104     void gotContent(QDBusPendingCallWatcher *watcher);
00105 
00106     void onContentReady(Tp::PendingOperation *op);
00107     void onContentRemoved(const Tpy::CallContentPtr &content);
00108 
00109 private:
00110     friend class CallChannel;
00111 
00112     PendingCallContent(const CallChannelPtr &channel,
00113             const QString &contentName, Tp::MediaStreamType type);
00114 
00115     struct Private;
00116     friend struct Private;
00117     Private *mPriv;
00118 };
00119 
00120 class TELEPATHY_QT4_YELL_EXPORT CallContent : public Tp::StatefulDBusProxy,
00121                     public Tp::OptionalInterfaceFactory<CallContent>
00122 {
00123     Q_OBJECT
00124     Q_DISABLE_COPY(CallContent)
00125 
00126 public:
00127     ~CallContent();
00128 
00129     CallChannelPtr channel() const;
00130 
00131     QString name() const;
00132     Tp::MediaStreamType type() const;
00133 
00134     CallContentDisposition disposition() const;
00135 
00136     CallStreams streams() const;
00137 
00138 Q_SIGNALS:
00139     void streamAdded(const Tpy::CallStreamPtr &stream);
00140     void streamRemoved(const Tpy::CallStreamPtr &stream);
00141 
00142 private Q_SLOTS:
00143     void gotMainProperties(QDBusPendingCallWatcher *watcher);
00144     void onStreamsAdded(const Tpy::ObjectPathList &streamPath);
00145     void onStreamsRemoved(const Tpy::ObjectPathList &streamPath);
00146     void onStreamReady(Tp::PendingOperation *op);
00147 
00148 private:
00149     friend class CallChannel;
00150     friend class PendingCallContent;
00151 
00152     static const Tp::Feature FeatureCore;
00153 
00154     CallContent(const CallChannelPtr &channel,
00155             const QDBusObjectPath &contentPath);
00156 
00157     struct Private;
00158     friend struct Private;
00159     Private *mPriv;
00160 };
00161 
00162 class TELEPATHY_QT4_YELL_EXPORT CallChannel : public Tp::Channel
00163 {
00164     Q_OBJECT
00165     Q_DISABLE_COPY(CallChannel)
00166 
00167 public:
00168     static const Tp::Feature FeatureContents;
00169     static const Tp::Feature FeatureLocalHoldState;
00170 
00171     // TODO: add helpers to ensure/create call channel using Account
00172 
00173     static CallChannelPtr create(const Tp::ConnectionPtr &connection,
00174             const QString &objectPath, const QVariantMap &immutableProperties);
00175 
00176     virtual ~CallChannel();
00177 
00178     CallState state() const;
00179     CallFlags flags() const;
00180     CallStateReason stateReason() const;
00181     QVariantMap stateDetails() const;
00182 
00183     bool handlerStreamingRequired() const;
00184     StreamTransportType initialTransportType() const;
00185     bool hasInitialAudio() const;
00186     bool hasInitialVideo() const;
00187     QString initialAudioName() const;
00188     QString initialVideoName() const;
00189     bool hasMutableContents() const;
00190 
00191     Tp::PendingOperation *accept();
00192     Tp::PendingOperation *hangup(CallStateChangeReason reason,
00193             const QString &detailedReason, const QString &message);
00194 
00195     CallContents contents() const;
00196     CallContents contentsForType(Tp::MediaStreamType type) const;
00197     PendingCallContent *requestContent(const QString &name, Tp::MediaStreamType type);
00198     Tp::PendingOperation *removeContent(const CallContentPtr &content,
00199             ContentRemovalReason reason, const QString &detailedReason, const QString &message);
00200 
00201     Tp::LocalHoldState localHoldState() const;
00202     Tp::LocalHoldStateReason localHoldStateReason() const;
00203     Tp::PendingOperation *requestHold(bool hold);
00204 
00205 Q_SIGNALS:
00206     void contentAdded(const Tpy::CallContentPtr &content);
00207     void contentRemoved(const Tpy::CallContentPtr &content);
00208     void stateChanged(Tpy::CallState state);
00209 
00210     void localHoldStateChanged(Tp::LocalHoldState state, Tp::LocalHoldStateReason reason);
00211 
00212 protected:
00213     CallChannel(const Tp::ConnectionPtr &connection,
00214             const QString &objectPath, const QVariantMap &immutableProperties,
00215             const Tp::Feature &coreFeature = Tp::Channel::FeatureCore);
00216 
00217 private Q_SLOTS:
00218     void gotMainProperties(QDBusPendingCallWatcher *watcher);
00219     void onContentAdded(const QDBusObjectPath &contentPath);
00220     void onContentRemoved(const QDBusObjectPath &contentPath);
00221     void onContentReady(Tp::PendingOperation *op);
00222     void onCallStateChanged(uint state, uint flags,
00223             const Tpy::CallStateReason &stateReason, const QVariantMap &stateDetails);
00224 
00225     void gotLocalHoldState(QDBusPendingCallWatcher *);
00226     void onLocalHoldStateChanged(uint, uint);
00227 
00228 private:
00229     friend class PendingCallContent;
00230 
00231     CallContentPtr addContent(const QDBusObjectPath &contentPath);
00232     CallContentPtr lookupContent(const QDBusObjectPath &contentPath) const;
00233 
00234     struct Private;
00235     friend struct Private;
00236     Private *mPriv;
00237 };
00238 
00239 } // Tp
00240 
00241 #endif


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