[Telepathy-commits] [telepathy-qt4/master] PendingChannel: Return ChannelPtr on channel() method.
Andre Moreira Magalhaes (andrunko)
andre.magalhaes at collabora.co.uk
Wed Mar 18 10:10:20 PDT 2009
---
TelepathyQt4/Client/connection.cpp | 6 +++---
TelepathyQt4/Client/contact-manager.cpp | 12 ++++++------
TelepathyQt4/Client/contact-manager.h | 2 +-
TelepathyQt4/Client/pending-channel.cpp | 20 ++++++++++----------
TelepathyQt4/Client/pending-channel.h | 3 +--
tests/dbus/chan-basics.cpp | 6 +++---
tests/dbus/chan-group.cpp | 6 +++---
tests/dbus/conn-requests.cpp | 4 ++--
8 files changed, 29 insertions(+), 30 deletions(-)
diff --git a/TelepathyQt4/Client/connection.cpp b/TelepathyQt4/Client/connection.cpp
index 83ffd61..0837681 100644
--- a/TelepathyQt4/Client/connection.cpp
+++ b/TelepathyQt4/Client/connection.cpp
@@ -983,14 +983,14 @@ void Connection::gotContactListChannel(PendingOperation *op)
}
PendingChannel *pending = qobject_cast<PendingChannel*>(op);
- QSharedPointer<Channel> channel = pending->channel();
+ ChannelPtr channel = pending->channel();
uint handle = pending->handle();
- Q_ASSERT(!channel.isNull());
+ Q_ASSERT(channel);
Q_ASSERT(handle);
for (int i = 0; i < ContactManager::ContactListChannel::LastType; ++i) {
if (mPriv->contactListsChannels[i].handle.size() > 0 &&
mPriv->contactListsChannels[i].handle[0] == handle) {
- Q_ASSERT(mPriv->contactListsChannels[i].channel.isNull());
+ Q_ASSERT(!mPriv->contactListsChannels[i].channel);
mPriv->contactListsChannels[i].channel = channel;
connect(channel->becomeReady(),
SIGNAL(finished(Telepathy::Client::PendingOperation *)),
diff --git a/TelepathyQt4/Client/contact-manager.cpp b/TelepathyQt4/Client/contact-manager.cpp
index 1e1c52d..54959b5 100644
--- a/TelepathyQt4/Client/contact-manager.cpp
+++ b/TelepathyQt4/Client/contact-manager.cpp
@@ -76,10 +76,10 @@ struct ContactManager::Private
QSet<Contact::Feature> supportedFeatures;
QMap<uint, ContactListChannel> contactListsChannels;
- QSharedPointer<Channel> subscribeChannel;
- QSharedPointer<Channel> publishChannel;
- QSharedPointer<Channel> storedChannel;
- QSharedPointer<Channel> denyChannel;
+ ChannelPtr subscribeChannel;
+ ChannelPtr publishChannel;
+ ChannelPtr storedChannel;
+ ChannelPtr denyChannel;
Contacts allKnownContacts() const;
void updateContactsPresenceState();
@@ -779,7 +779,7 @@ void ContactManager::setContactListChannels(
QMap<uint, ContactListChannel>::const_iterator i = contactListsChannels.constBegin();
QMap<uint, ContactListChannel>::const_iterator end = contactListsChannels.constEnd();
uint type;
- QSharedPointer<Channel> channel;
+ ChannelPtr channel;
const char *method;
while (i != end) {
type = i.key();
@@ -883,7 +883,7 @@ Contacts ContactManager::Private::allKnownContacts() const
{
Contacts contacts;
foreach (const ContactListChannel &contactListChannel, contactListsChannels) {
- QSharedPointer<Channel> channel = contactListChannel.channel;
+ ChannelPtr channel = contactListChannel.channel;
if (!channel) {
continue;
}
diff --git a/TelepathyQt4/Client/contact-manager.h b/TelepathyQt4/Client/contact-manager.h
index b14bfb7..1ea2f7c 100644
--- a/TelepathyQt4/Client/contact-manager.h
+++ b/TelepathyQt4/Client/contact-manager.h
@@ -151,7 +151,7 @@ class ContactManager : public QObject
Type type;
ReferencedHandles handle;
- QSharedPointer<Channel> channel;
+ ChannelPtr channel;
};
ContactManager(Connection *parent);
diff --git a/TelepathyQt4/Client/pending-channel.cpp b/TelepathyQt4/Client/pending-channel.cpp
index 9f8b9e5..418db17 100644
--- a/TelepathyQt4/Client/pending-channel.cpp
+++ b/TelepathyQt4/Client/pending-channel.cpp
@@ -57,7 +57,7 @@ struct PendingChannel::Private
uint handle;
QDBusObjectPath objectPath;
QVariantMap immutableProperties;
- QSharedPointer<Channel> channel;
+ ChannelPtr channel;
};
/**
@@ -232,18 +232,18 @@ QVariantMap PendingChannel::immutableProperties() const
* Returns a shared pointer to a Channel high-level proxy object associated
* with the remote channel resulting from the channel request. If isValid()
* returns <code>false</code>, the request has not (at least yet) completed
- * successfully, and a null QSharedPointer will be returned.
+ * successfully, and a null ChannelPtr will be returned.
*
* \return Shared pointer to the new Channel object, 0 if an error occurred.
*/
-QSharedPointer<Channel> PendingChannel::channel() const
+ChannelPtr PendingChannel::channel() const
{
if (!isFinished()) {
warning() << "PendingChannel::channel called before finished, returning 0";
- return QSharedPointer<Channel>();
+ return ChannelPtr();
} else if (!isValid()) {
warning() << "PendingChannel::channel called when not valid, returning 0";
- return QSharedPointer<Channel>();
+ return ChannelPtr();
}
if (mPriv->channel) {
@@ -251,29 +251,29 @@ QSharedPointer<Channel> PendingChannel::channel() const
}
if (channelType() == TELEPATHY_INTERFACE_CHANNEL_TYPE_TEXT) {
- mPriv->channel = QSharedPointer<Channel>(
+ mPriv->channel = ChannelPtr(
new TextChannel(connection(), mPriv->objectPath.path(),
mPriv->immutableProperties));
}
else if (channelType() == TELEPATHY_INTERFACE_CHANNEL_TYPE_STREAMED_MEDIA) {
- mPriv->channel = QSharedPointer<Channel>(
+ mPriv->channel = ChannelPtr(
new StreamedMediaChannel(connection(), mPriv->objectPath.path(),
mPriv->immutableProperties));
}
else if (channelType() == TELEPATHY_INTERFACE_CHANNEL_TYPE_ROOM_LIST) {
- mPriv->channel = QSharedPointer<Channel>(
+ mPriv->channel = ChannelPtr(
new RoomList(connection(), mPriv->objectPath.path(),
mPriv->immutableProperties));
}
// FIXME: update spec so we can do this properly
else if (channelType() == "org.freedesktop.Telepathy.Channel.Type.FileTransfer") {
- mPriv->channel = QSharedPointer<Channel>(
+ mPriv->channel = ChannelPtr(
new FileTransfer(connection(), mPriv->objectPath.path(),
mPriv->immutableProperties));
}
else {
// ContactList, old-style Tubes, or a future channel type
- mPriv->channel = QSharedPointer<Channel>(
+ mPriv->channel = ChannelPtr(
new Channel(connection(), mPriv->objectPath.path(),
mPriv->immutableProperties));
}
diff --git a/TelepathyQt4/Client/pending-channel.h b/TelepathyQt4/Client/pending-channel.h
index 17a9119..b787791 100644
--- a/TelepathyQt4/Client/pending-channel.h
+++ b/TelepathyQt4/Client/pending-channel.h
@@ -29,7 +29,6 @@
#include <TelepathyQt4/Client/Channel>
#include <TelepathyQt4/Client/PendingOperation>
-#include <QSharedPointer>
#include <QString>
#include <QVariantMap>
@@ -62,7 +61,7 @@ public:
QVariantMap immutableProperties() const;
- QSharedPointer<Channel> channel() const;
+ ChannelPtr channel() const;
private Q_SLOTS:
void onCallCreateChannelFinished(QDBusPendingCallWatcher *watcher);
diff --git a/tests/dbus/chan-basics.cpp b/tests/dbus/chan-basics.cpp
index 5d8bbd4..ebede15 100644
--- a/tests/dbus/chan-basics.cpp
+++ b/tests/dbus/chan-basics.cpp
@@ -51,7 +51,7 @@ private:
QString mConnName, mConnPath;
ExampleEcho2Connection *mConnService;
Connection *mConn;
- QSharedPointer<Channel> mChan;
+ ChannelPtr mChan;
QString mChanObjectPath;
uint mHandle;
};
@@ -284,7 +284,7 @@ void TestChanBasics::testCreateChannel()
toCheck.sort();
QCOMPARE(ids, toCheck);
- mChan.clear();
+ mChan.reset();
}
}
@@ -330,7 +330,7 @@ void TestChanBasics::testEnsureChannel()
QCOMPARE(mLoop->exec(), 0);
QCOMPARE(mChan->isValid(), false);
- mChan.clear();
+ mChan.reset();
}
}
diff --git a/tests/dbus/chan-group.cpp b/tests/dbus/chan-group.cpp
index 13fe232..705e525 100644
--- a/tests/dbus/chan-group.cpp
+++ b/tests/dbus/chan-group.cpp
@@ -69,7 +69,7 @@ private:
QString mConnName, mConnPath;
ExampleCSHConnection *mConnService;
Connection *mConn;
- QSharedPointer<Channel> mChan;
+ ChannelPtr mChan;
QString mChanObjectPath;
uint mRoomNumber;
uint mRoomCount;
@@ -408,7 +408,7 @@ void TestChanGroup::doTestCreateChannel()
SIGNAL(finished(Telepathy::Client::PendingOperation*)),
SLOT(expectCreateChannelFinished(Telepathy::Client::PendingOperation*))));
QCOMPARE(mLoop->exec(), 0);
- QVERIFY(mChan != 0);
+ QVERIFY(mChan);
QVERIFY(connect(mChan->becomeReady(),
SIGNAL(finished(Telepathy::Client::PendingOperation*)),
@@ -560,7 +560,7 @@ void TestChanGroup::doTestCreateChannel()
expectedIds.sort();
checkExpectedIds(mChan->groupContacts(), expectedIds);
- mChan.clear();
+ mChan.reset();
}
void TestChanGroup::cleanup()
diff --git a/tests/dbus/conn-requests.cpp b/tests/dbus/conn-requests.cpp
index 539e0b0..a9f2dfb 100644
--- a/tests/dbus/conn-requests.cpp
+++ b/tests/dbus/conn-requests.cpp
@@ -108,7 +108,7 @@ void TestConnRequests::expectCreateChannelFinished(PendingOperation* op)
}
PendingChannel *pc = qobject_cast<PendingChannel*>(op);
- QSharedPointer<Channel> chan = pc->channel();
+ ChannelPtr chan = pc->channel();
mChanObjectPath = chan->objectPath();
mLoop->exit(0);
}
@@ -135,7 +135,7 @@ void TestConnRequests::expectEnsureChannelFinished(PendingOperation* op)
}
PendingChannel *pc = qobject_cast<PendingChannel*>(op);
- QSharedPointer<Channel> chan = pc->channel();
+ ChannelPtr chan = pc->channel();
QCOMPARE(pc->yours(), false);
QCOMPARE(chan->objectPath(), mChanObjectPath);
mLoop->exit(0);
--
1.5.6.5
More information about the telepathy-commits
mailing list