[telepathy-qt4/master] MediaStream: Return StreamedMediaChannelPtr on channel() method.
Andre Moreira Magalhaes (andrunko)
andre.magalhaes at collabora.co.uk
Tue Mar 31 15:25:55 PDT 2009
---
TelepathyQt4/Client/streamed-media-channel.cpp | 44 ++++++++++++-----------
TelepathyQt4/Client/streamed-media-channel.h | 12 ++----
tests/dbus/streamed-media-chan.cpp | 2 +-
3 files changed, 28 insertions(+), 30 deletions(-)
diff --git a/TelepathyQt4/Client/streamed-media-channel.cpp b/TelepathyQt4/Client/streamed-media-channel.cpp
index 07aa186..7576ec1 100644
--- a/TelepathyQt4/Client/streamed-media-channel.cpp
+++ b/TelepathyQt4/Client/streamed-media-channel.cpp
@@ -39,22 +39,21 @@ namespace Client
struct PendingMediaStreams::Private
{
- Private(PendingMediaStreams *parent, StreamedMediaChannel *channel)
+ Private(PendingMediaStreams *parent, const StreamedMediaChannelPtr &channel)
: parent(parent), channel(channel), streamsReady(0)
{
}
PendingMediaStreams *parent;
- StreamedMediaChannel *channel;
+ WeakPtr<StreamedMediaChannel> channel;
MediaStreams streams;
uint streamsReady;
};
-PendingMediaStreams::PendingMediaStreams(StreamedMediaChannel *channel,
+PendingMediaStreams::PendingMediaStreams(const StreamedMediaChannelPtr &channel,
ContactPtr contact,
- QList<Telepathy::MediaStreamType> types,
- QObject *parent)
- : PendingOperation(parent),
+ QList<Telepathy::MediaStreamType> types)
+ : PendingOperation(channel.data()),
mPriv(new Private(this, channel))
{
Telepathy::UIntList l;
@@ -105,26 +104,27 @@ void PendingMediaStreams::gotStreams(QDBusPendingCallWatcher *watcher)
Telepathy::MediaStreamInfoList list = reply.value();
MediaStreamPtr stream;
+ StreamedMediaChannelPtr channel(mPriv->channel);
foreach (const Telepathy::MediaStreamInfo &streamInfo, list) {
- stream = mPriv->channel->lookupStreamById(streamInfo.identifier);
+ stream = channel->lookupStreamById(streamInfo.identifier);
if (!stream) {
stream = MediaStreamPtr(
- new MediaStream(mPriv->channel,
+ new MediaStream(channel,
streamInfo.identifier,
streamInfo.contact,
(Telepathy::MediaStreamType) streamInfo.type,
(Telepathy::MediaStreamState) streamInfo.state,
(Telepathy::MediaStreamDirection) streamInfo.direction,
(Telepathy::MediaStreamPendingSend) streamInfo.pendingSendFlags));
- mPriv->channel->addStream(stream);
+ channel->addStream(stream);
} else {
- mPriv->channel->onStreamDirectionChanged(streamInfo.identifier,
+ channel->onStreamDirectionChanged(streamInfo.identifier,
streamInfo.direction, streamInfo.pendingSendFlags);
- mPriv->channel->onStreamStateChanged(streamInfo.identifier,
+ channel->onStreamStateChanged(streamInfo.identifier,
streamInfo.state);
}
mPriv->streams.append(stream);
- connect(mPriv->channel,
+ connect(channel.data(),
SIGNAL(streamRemoved(Telepathy::Client::MediaStreamPtr)),
SLOT(onStreamRemoved(Telepathy::Client::MediaStreamPtr)));
connect(stream->becomeReady(),
@@ -166,7 +166,7 @@ void PendingMediaStreams::onStreamReady(PendingOperation *op)
struct MediaStream::Private
{
- Private(MediaStream *parent, StreamedMediaChannel *channel, uint id,
+ Private(MediaStream *parent, const StreamedMediaChannelPtr &channel, uint id,
uint contactHandle, MediaStreamType type,
MediaStreamState state, MediaStreamDirection direction,
MediaStreamPendingSend pendingSend);
@@ -175,7 +175,7 @@ struct MediaStream::Private
MediaStream *parent;
ReadinessHelper *readinessHelper;
- StreamedMediaChannel *channel;
+ WeakPtr<StreamedMediaChannel> channel;
uint id;
uint contactHandle;
ContactPtr contact;
@@ -186,7 +186,7 @@ struct MediaStream::Private
};
MediaStream::Private::Private(MediaStream *parent,
- StreamedMediaChannel *channel, uint id,
+ const StreamedMediaChannelPtr &channel, uint id,
uint contactHandle, MediaStreamType type,
MediaStreamState state, MediaStreamDirection direction,
MediaStreamPendingSend pendingSend)
@@ -221,7 +221,8 @@ void MediaStream::Private::introspectContact(MediaStream::Private *self)
return;
}
- ContactManager *contactManager = self->channel->connection()->contactManager();
+ StreamedMediaChannelPtr chan(self->channel);
+ ContactManager *contactManager = chan->connection()->contactManager();
self->parent->connect(
contactManager->contactsForHandles(UIntList() << self->contactHandle),
SIGNAL(finished(Telepathy::Client::PendingOperation *)),
@@ -230,7 +231,7 @@ void MediaStream::Private::introspectContact(MediaStream::Private *self)
const Feature MediaStream::FeatureContact = Feature(MediaStream::staticMetaObject.className(), 0);
-MediaStream::MediaStream(StreamedMediaChannel *channel, uint id,
+MediaStream::MediaStream(const StreamedMediaChannelPtr &channel, uint id,
uint contactHandle, MediaStreamType type,
MediaStreamState state, MediaStreamDirection direction,
MediaStreamPendingSend pendingSend)
@@ -246,7 +247,7 @@ MediaStream::~MediaStream()
delete mPriv;
}
-StreamedMediaChannel *MediaStream::channel() const
+StreamedMediaChannelPtr MediaStream::channel() const
{
return mPriv->channel;
}
@@ -364,8 +365,9 @@ Telepathy::MediaStreamPendingSend MediaStream::pendingSend() const
PendingOperation *MediaStream::requestDirection(
Telepathy::MediaStreamDirection direction)
{
+ StreamedMediaChannelPtr chan(mPriv->channel);
return new PendingVoidMethodCall(this,
- mPriv->channel->streamedMediaInterface()->RequestStreamDirection(mPriv->id, direction));
+ chan->streamedMediaInterface()->RequestStreamDirection(mPriv->id, direction));
}
/**
@@ -636,14 +638,14 @@ PendingMediaStreams *StreamedMediaChannel::requestStream(
Telepathy::MediaStreamType type)
{
return new PendingMediaStreams(this, contact,
- QList<Telepathy::MediaStreamType>() << type, this);
+ QList<Telepathy::MediaStreamType>() << type);
}
PendingMediaStreams *StreamedMediaChannel::requestStreams(
const ContactPtr &contact,
QList<Telepathy::MediaStreamType> types)
{
- return new PendingMediaStreams(this, contact, types, this);
+ return new PendingMediaStreams(this, contact, types);
}
void StreamedMediaChannel::gotStreams(QDBusPendingCallWatcher *watcher)
diff --git a/TelepathyQt4/Client/streamed-media-channel.h b/TelepathyQt4/Client/streamed-media-channel.h
index d003e12..923fbb6 100644
--- a/TelepathyQt4/Client/streamed-media-channel.h
+++ b/TelepathyQt4/Client/streamed-media-channel.h
@@ -57,13 +57,9 @@ private Q_SLOTS:
private:
friend class StreamedMediaChannel;
- PendingMediaStreams(StreamedMediaChannel *channel,
+ PendingMediaStreams(const StreamedMediaChannelPtr &channel,
ContactPtr contact,
- QList<Telepathy::MediaStreamType> types,
- QObject *parent = 0);
- PendingMediaStreams(StreamedMediaChannel *channel,
- const MediaStreams &streams,
- QObject *parent = 0);
+ QList<Telepathy::MediaStreamType> types);
struct Private;
friend struct Private;
@@ -80,7 +76,7 @@ class MediaStream : public QObject,
public:
~MediaStream();
- StreamedMediaChannel *channel() const;
+ StreamedMediaChannelPtr channel() const;
uint id() const;
ContactPtr contact() const;
@@ -109,7 +105,7 @@ private:
static const Feature FeatureContact;
- MediaStream(StreamedMediaChannel *channel, uint id,
+ MediaStream(const StreamedMediaChannelPtr &channel, uint id,
uint contactHandle, MediaStreamType type,
MediaStreamState state, MediaStreamDirection direction,
MediaStreamPendingSend pendingSend);
diff --git a/tests/dbus/streamed-media-chan.cpp b/tests/dbus/streamed-media-chan.cpp
index 4367b8a..e070e4a 100644
--- a/tests/dbus/streamed-media-chan.cpp
+++ b/tests/dbus/streamed-media-chan.cpp
@@ -715,7 +715,7 @@ void TestStreamedMediaChan::testIncomingCall()
QCOMPARE(mChan->streams().size(), 1);
MediaStreamPtr stream = mChan->streams().first();
- QCOMPARE(stream->channel(), mChan.data());
+ QCOMPARE(stream->channel(), mChan);
QCOMPARE(stream->type(), Telepathy::MediaStreamTypeAudio);
// RequestStreams with bad type must fail
--
1.5.6.5
More information about the telepathy-commits
mailing list