[Telepathy-commits] [telepathy-qt4/master] Channel: add protected methods to look for the self-handle in local pending, and add it
Simon McVittie
simon.mcvittie at collabora.co.uk
Mon Mar 23 06:26:21 PDT 2009
While using Contact objects is nice from a high-level-API point of view,
it's not so convenient if all we want to do is to accept an invitation or
VoIP call.
The high-level semantics of moving yourself from local-pending to members
depend on the channel type, so subclasses should introduce wrappers for
these methods with a friendlier name, where appropriate.
---
TelepathyQt4/Client/channel.cpp | 53 +++++++++++++++++++++++++++++++++++++++
TelepathyQt4/Client/channel.h | 6 ++++
2 files changed, 59 insertions(+), 0 deletions(-)
diff --git a/TelepathyQt4/Client/channel.cpp b/TelepathyQt4/Client/channel.cpp
index 6e7f4c0..9ee2af6 100644
--- a/TelepathyQt4/Client/channel.cpp
+++ b/TelepathyQt4/Client/channel.cpp
@@ -1524,6 +1524,59 @@ ContactPtr Channel::groupSelfContact() const
}
/**
+ * Return whether the local user is in the "local pending" state. This
+ * indicates that the local user needs to take action to accept an invitation,
+ * an incoming call, etc.
+ *
+ * \return Whether the local user is in this channel's local-pending set.
+ */
+bool Channel::groupSelfHandleIsLocalPending() const
+{
+ if (!isReady()) {
+ warning() << "Channel::groupSelfHandleIsLocalPending() used when "
+ "channel not ready";
+ return false;
+ }
+
+ uint selfHandle = mPriv->groupSelfHandle;
+
+ if (selfHandle == 0) {
+ selfHandle = mPriv->connection->selfHandle();
+ }
+
+ return mPriv->groupLocalPendingContacts.contains(selfHandle);
+}
+
+/**
+ * Attempt to add the local user to this channel. In some channel types,
+ * such as Text and StreamedMedia, this is used to accept an invitation or an
+ * incoming call.
+ *
+ * \return A pending operation which will emit finished on success or failure
+ */
+PendingOperation *Channel::groupAddSelfHandle()
+{
+ if (!isReady()) {
+ warning() << "Channel::groupAddSelfHandle() used when channel not "
+ "ready";
+ return new PendingFailure(this,
+ TELEPATHY_ERROR_INVALID_ARGUMENT,
+ "Telepathy-Qt4: Channel object not ready");
+ }
+
+ UIntList handles;
+
+ if (mPriv->groupSelfHandle == 0) {
+ handles << mPriv->connection->selfHandle();
+ } else {
+ handles << mPriv->groupSelfHandle;
+ }
+
+ return new PendingVoidMethodCall(this,
+ mPriv->group->AddMembers(handles, ""));
+}
+
+/**
* \fn void Channel::groupFlagsChanged(uint flags, uint added, uint removed)
*
* Emitted when the value returned by groupFlags() changes.
diff --git a/TelepathyQt4/Client/channel.h b/TelepathyQt4/Client/channel.h
index 012167b..8b74253 100644
--- a/TelepathyQt4/Client/channel.h
+++ b/TelepathyQt4/Client/channel.h
@@ -159,6 +159,12 @@ Q_SIGNALS:
void groupSelfContactChanged();
+protected:
+ bool groupSelfHandleIsLocalPending() const;
+
+protected Q_SLOTS:
+ PendingOperation *groupAddSelfHandle();
+
public:
template <class Interface>
inline Interface *optionalInterface(
--
1.5.6.5
More information about the telepathy-commits
mailing list