[Telepathy-commits] [telepathy-qt4/master] Change close() to return a QDBusPendingReply when not used as a slot.
George Goldberg
george.goldberg at collabora.co.uk
Wed Nov 19 06:03:09 PST 2008
---
TelepathyQt4/cli-channel.cpp | 16 +++++++++++-----
TelepathyQt4/cli-channel.h | 7 ++++++-
2 files changed, 17 insertions(+), 6 deletions(-)
diff --git a/TelepathyQt4/cli-channel.cpp b/TelepathyQt4/cli-channel.cpp
index c013677..bd643e6 100644
--- a/TelepathyQt4/cli-channel.cpp
+++ b/TelepathyQt4/cli-channel.cpp
@@ -447,13 +447,19 @@ uint Channel::targetHandle() const
return mPriv->targetHandle;
}
-void Channel::close()
+QDBusPendingReply<> Channel::close()
{
+ // REVIEWME: should we just call close anyway, even if it doesn't make sense, like in methods above?
// Closing a channel only makes sense if the readiness is Full.
- if(mPriv->readiness == ReadinessFull)
- mPriv->baseInterface->Close();
- else
- warning() << "Channel::close() used with readiness" << mPriv->readiness << "!= ReadinessFull";
+ if (mPriv->readiness == ReadinessFull) {
+ return mPriv->baseInterface->Close();
+ } else {
+ // If the channel is in a readiness where it can't be closed, we emit
+ // a warning and return an invalid QDBusPendingReply.
+ warning() << "Channel::close() used with readiness" << mPriv->readiness << "!= ReadinessFull";
+ return QDBusPendingReply<>();
+ }
+
}
uint Channel::groupFlags() const
diff --git a/TelepathyQt4/cli-channel.h b/TelepathyQt4/cli-channel.h
index da4d5e1..d512c15 100644
--- a/TelepathyQt4/cli-channel.h
+++ b/TelepathyQt4/cli-channel.h
@@ -190,8 +190,13 @@ public:
public Q_SLOTS:
/**
* Close the channel.
+ *
+ * When this method is used as a slot, it is fire-and-forget. If you want
+ * to know if an error occurs when closing the channel, then you should
+ * use the returned object.
+ *
*/
- void close();
+ QDBusPendingReply<> close();
Q_SIGNALS:
/**
--
1.5.6.5
More information about the Telepathy-commits
mailing list