[Telepathy-commits] [telepathy-qt4/master] Move PendingHandles to its own files
Olli Salli
olli.salli at collabora.co.uk
Wed Jan 21 04:42:15 PST 2009
---
TelepathyQt4/Makefile.am | 3 +
TelepathyQt4/cli-connection.cpp | 130 --------------------
TelepathyQt4/cli-connection.h | 152 +------------------------
TelepathyQt4/cli-pending-handles.cpp | 164 ++++++++++++++++++++++++++
TelepathyQt4/cli-pending-handles.h | 215 ++++++++++++++++++++++++++++++++++
5 files changed, 383 insertions(+), 281 deletions(-)
create mode 100644 TelepathyQt4/cli-pending-handles.cpp
create mode 100644 TelepathyQt4/cli-pending-handles.h
diff --git a/TelepathyQt4/Makefile.am b/TelepathyQt4/Makefile.am
index a972051..387ac9a 100644
--- a/TelepathyQt4/Makefile.am
+++ b/TelepathyQt4/Makefile.am
@@ -46,6 +46,7 @@ libtelepathy_qt4_la_SOURCES = \
cli-media-stream-handler.cpp \
cli-optional-interface-factory.cpp \
cli-pending-channel.cpp \
+ cli-pending-handles.cpp \
cli-pending-operation.cpp \
cli-properties.cpp \
cli-referenced-handles.cpp \
@@ -78,6 +79,7 @@ nodist_libtelepathy_qt4_la_SOURCES = \
cli-connection.moc.hpp \
cli-dbus-proxy.moc.hpp \
cli-pending-channel.moc.hpp \
+ cli-pending-handles.moc.hpp \
cli-pending-operation.moc.hpp \
cli-simple-pending-operations.moc.hpp
@@ -96,6 +98,7 @@ tpqt4include_HEADERS = \
cli-media-stream-handler.h \
cli-optional-interface-factory.h \
cli-pending-channel.h \
+ cli-pending-handles.h \
cli-pending-operation.h \
cli-properties.h \
cli-referenced-handles.h \
diff --git a/TelepathyQt4/cli-connection.cpp b/TelepathyQt4/cli-connection.cpp
index 00a0114..2318fbe 100644
--- a/TelepathyQt4/cli-connection.cpp
+++ b/TelepathyQt4/cli-connection.cpp
@@ -518,135 +518,5 @@ void Connection::unrefHandle(uint handle)
// FIXME implement
}
-struct PendingHandles::Private
-{
- Connection* connection;
- uint handleType;
- bool isRequest;
- QStringList namesRequested;
- UIntList handlesToReference;
- QDBusError error;
- ReferencedHandles handles;
-};
-
-PendingHandles::PendingHandles(Connection* connection, uint handleType, const QStringList& names)
- : QObject(connection), mPriv(new Private)
-{
- mPriv->connection = connection;
- mPriv->handleType = handleType;
- mPriv->isRequest = true;
- mPriv->namesRequested = names;
-}
-
-PendingHandles::PendingHandles(Connection* connection, uint handleType, const UIntList& handles, bool allHeld)
- : QObject(connection), mPriv(new Private)
-{
- mPriv->connection = connection;
- mPriv->handleType = handleType;
- mPriv->isRequest = false;
- mPriv->handlesToReference = handles;
-
- if (allHeld)
- mPriv->handles = ReferencedHandles(connection, handleType, handles);
-}
-
-PendingHandles::~PendingHandles()
-{
- delete mPriv;
-}
-
-Connection* PendingHandles::connection() const
-{
- return mPriv->connection;
-}
-
-uint PendingHandles::handleType() const
-{
- return mPriv->handleType;
-}
-
-bool PendingHandles::isRequest() const
-{
- return mPriv->isRequest;
-}
-
-bool PendingHandles::isReference() const
-{
- return !isRequest();
-}
-
-const QStringList& PendingHandles::namesRequested() const
-{
- return mPriv->namesRequested;
-}
-
-const UIntList& PendingHandles::handlesToReference() const
-{
- return mPriv->handlesToReference;
-}
-
-bool PendingHandles::isFinished() const
-{
- return mPriv->handles.connection() == connection() || !mPriv->error.message().isEmpty();
-}
-
-bool PendingHandles::isError() const
-{
- return !mPriv->error.message().isEmpty();
-}
-
-const QDBusError& PendingHandles::error() const
-{
- if (isValid())
- warning() << "PendingHandles::error() called when valid";
- else if (!isFinished())
- warning() << "PendingHandles::error() called before finished";
-
- return mPriv->error;
-}
-
-bool PendingHandles::isValid() const
-{
- return isFinished() && !isError();
-}
-
-ReferencedHandles PendingHandles::handles() const
-{
- return mPriv->handles;
-}
-
-void PendingHandles::onCallFinished(QDBusPendingCallWatcher* watcher)
-{
- // Thanks QDBus for this the need for this error-handling code duplication
- if (mPriv->isRequest) {
- QDBusPendingReply<UIntList> reply;
-
- debug() << "Received reply to RequestHandles";
-
- if (reply.isError()) {
- debug().nospace() << " Failure: error " << reply.error().name() << ": " << reply.error().message();
- mPriv->error = reply.error();
- } else {
- mPriv->handles = ReferencedHandles(connection(), handleType(), reply.value());
- }
- } else {
- QDBusPendingReply<void> reply;
-
- debug() << "Received reply to HoldHandles";
-
- if (reply.isError()) {
- debug().nospace() << " Failure: error " << reply.error().name() << ": " << reply.error().message();
- mPriv->error = reply.error();
- } else {
- mPriv->handles = ReferencedHandles(connection(), handleType(), handlesToReference());
- }
- }
-
- debug() << " Emitting finished()";
- emit finished(this);
-
- watcher->deleteLater();
-}
-
}
}
diff --git a/TelepathyQt4/cli-connection.h b/TelepathyQt4/cli-connection.h
index c2c2e37..af9d417 100644
--- a/TelepathyQt4/cli-connection.h
+++ b/TelepathyQt4/cli-connection.h
@@ -44,7 +44,6 @@
namespace Telepathy {
namespace Client {
class Connection;
-class PendingHandles;
}
}
@@ -61,6 +60,7 @@ class PendingHandles;
#include <TelepathyQt4/Client/ReferencedHandles>
#include "cli-pending-channel.h"
+#include "cli-pending-handles.h"
namespace Telepathy
{
@@ -512,156 +512,6 @@ private:
Private *mPriv;
};
-/**
- * \class PendingHandles
- * \ingroup clientconn
- * \headerfile <TelepathyQt4/cli-connection.h> <TelepathyQt4/Client/Connection>
- *
- * Class containing the parameters of and the reply to an asynchronous handle
- * request/hold. Instances of this class cannot be constructed directly; the
- * only ways to get one are to use Connection::requestHandles() or
- * Connection::referenceHandles().
- */
-class PendingHandles : public QObject
-{
- Q_OBJECT
-
-public:
- /**
- * Class destructor.
- */
- ~PendingHandles();
-
- /**
- * Returns the Connection object through which the operation was made.
- *
- * \return Pointer to the Connection.
- */
- Connection* connection() const;
-
- /**
- * Returns the handle type specified in the operation.
- *
- * \return The handle type, as specified in #HandleType.
- */
- uint handleType() const;
-
- /**
- * Returns whether the operation was a handle request (as opposed to a
- * reference of existing handles).
- *
- * \sa isReference()
- *
- * \return Whether the operation was a request (== !isReference()).
- */
- bool isRequest() const;
-
- /**
- * Returns whether the operation was a handle reference (as opposed to a
- * request for new handles).
- *
- * \sa isRequest()
- *
- * \return Whether the operation was a reference (== !isRequest()).
- */
- bool isReference() const;
-
- /**
- * If the operation was a request (as returned by isRequest()), returns the
- * names of the entities for which handles were requested for. Otherwise,
- * returns an empty list.
- *
- * \return Reference to a list of the names of the entities.
- */
- const QStringList& namesRequested() const;
-
- /**
- * If the operation was a reference (as returned by isReference()), returns
- * the handles which were to be referenced. Otherwise, returns an empty
- * list.
- *
- * \return Reference to a list of the handles specified to be referenced.
- */
- const UIntList& handlesToReference() const;
-
- /**
- * Returns whether or not the operation has finished processing.
- *
- * \sa finished()
- *
- * \return If the operation is finished.
- */
- bool isFinished() const;
-
- /**
- * Returns whether or not the operation resulted in an error. If the
- * operation has not yet finished processing (isFinished() returns
- * <code>false</code>), this cannot yet be known, and <code>false</code>
- * will be returned.
- *
- * \return <code>true</code> iff the operation has finished processing AND
- * has resulted in an error.
- */
- bool isError() const;
-
- /**
- * Returns the error which the operation resulted in, if any. If isError()
- * returns <code>false</code>, the operation has not (at least yet) resulted
- * in an error, and an undefined value will be returned.
- *
- * \return The error as a QDBusError.
- */
- const QDBusError& error() const;
-
- /**
- * Returns whether or not the operation completed successfully. If the operation
- * has not yet finished processing (isFinished() returns <code>false</code>),
- * this cannot yet be known, and <code>false</code> will be returned.
- *
- * \return <code>true</code> iff the operation has finished processing AND has
- * completed successfully.
- */
- bool isValid() const;
-
- /**
- * Returns the now-referenced handles resulting from the operation. If the
- * operation has not (yet) finished successfully (isFinished() returns
- * <code>false</code>), the return value is undefined.
- *
- * For requests of new handles, <code>handles()[i]</code> will be the handle
- * corresponding to the entity name <code>namesToRequest()[i]</code>. For
- * references of existing handles, <code>handles()[i] ==
- * handlesToReference()[i]</code> will be true for any <code>i</code>.
- *
- * \return ReferencedHandles instance containing the handles.
- */
- ReferencedHandles handles() const;
-
-Q_SIGNALS:
- /**
- * Emitted when the operation finishes processing. isFinished() will then
- * start returning <code>true</code> and isError(), error(), isValid() and
- * channel() will become meaningful to use.
- *
- * \param pendingHandles The PendingHandles object for which the operation has
- * finished.
- */
- void finished(Telepathy::Client::PendingHandles* pendingHandles);
-
-private Q_SLOTS:
- void onCallFinished(QDBusPendingCallWatcher* watcher);
-
-private:
- friend class Connection;
-
- PendingHandles(Connection* connection, uint handleType, const QStringList& names);
- PendingHandles(Connection* connection, uint handleType, const UIntList& handles, bool allHeld);
-
- struct Private;
- friend struct Private;
- Private *mPriv;
-};
-
}
}
diff --git a/TelepathyQt4/cli-pending-handles.cpp b/TelepathyQt4/cli-pending-handles.cpp
new file mode 100644
index 0000000..dbdc688
--- /dev/null
+++ b/TelepathyQt4/cli-pending-handles.cpp
@@ -0,0 +1,164 @@
+/*
+ * This file is part of TelepathyQt4
+ *
+ * Copyright (C) 2008 Collabora Ltd. <http://www.collabora.co.uk/>
+ * Copyright (C) 2008 Nokia Corporation
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "cli-pending-handles.h"
+
+#include "cli-pending-handles.moc.hpp"
+
+#include "debug-internal.hpp"
+
+namespace Telepathy
+{
+namespace Client
+{
+
+struct PendingHandles::Private
+{
+ Connection* connection;
+ uint handleType;
+ bool isRequest;
+ QStringList namesRequested;
+ UIntList handlesToReference;
+ QDBusError error;
+ ReferencedHandles handles;
+};
+
+PendingHandles::PendingHandles(Connection* connection, uint handleType, const QStringList& names)
+ : QObject(connection), mPriv(new Private)
+{
+ mPriv->connection = connection;
+ mPriv->handleType = handleType;
+ mPriv->isRequest = true;
+ mPriv->namesRequested = names;
+}
+
+PendingHandles::PendingHandles(Connection* connection, uint handleType, const UIntList& handles, bool allHeld)
+ : QObject(connection), mPriv(new Private)
+{
+ mPriv->connection = connection;
+ mPriv->handleType = handleType;
+ mPriv->isRequest = false;
+ mPriv->handlesToReference = handles;
+
+ if (allHeld)
+ mPriv->handles = ReferencedHandles(connection, handleType, handles);
+}
+
+PendingHandles::~PendingHandles()
+{
+ delete mPriv;
+}
+
+Connection* PendingHandles::connection() const
+{
+ return mPriv->connection;
+}
+
+uint PendingHandles::handleType() const
+{
+ return mPriv->handleType;
+}
+
+bool PendingHandles::isRequest() const
+{
+ return mPriv->isRequest;
+}
+
+bool PendingHandles::isReference() const
+{
+ return !isRequest();
+}
+
+const QStringList& PendingHandles::namesRequested() const
+{
+ return mPriv->namesRequested;
+}
+
+const UIntList& PendingHandles::handlesToReference() const
+{
+ return mPriv->handlesToReference;
+}
+
+bool PendingHandles::isFinished() const
+{
+ return mPriv->handles.connection() == connection() || !mPriv->error.message().isEmpty();
+}
+
+bool PendingHandles::isError() const
+{
+ return !mPriv->error.message().isEmpty();
+}
+
+const QDBusError& PendingHandles::error() const
+{
+ if (isValid())
+ warning() << "PendingHandles::error() called when valid";
+ else if (!isFinished())
+ warning() << "PendingHandles::error() called before finished";
+
+ return mPriv->error;
+}
+
+bool PendingHandles::isValid() const
+{
+ return isFinished() && !isError();
+}
+
+ReferencedHandles PendingHandles::handles() const
+{
+ return mPriv->handles;
+}
+
+void PendingHandles::onCallFinished(QDBusPendingCallWatcher* watcher)
+{
+ // Thanks QDBus for this the need for this error-handling code duplication
+ if (mPriv->isRequest) {
+ QDBusPendingReply<UIntList> reply;
+
+ debug() << "Received reply to RequestHandles";
+
+ if (reply.isError()) {
+ debug().nospace() << " Failure: error " << reply.error().name() << ": " << reply.error().message();
+ mPriv->error = reply.error();
+ } else {
+ mPriv->handles = ReferencedHandles(connection(), handleType(), reply.value());
+ }
+ } else {
+ QDBusPendingReply<void> reply;
+
+ debug() << "Received reply to HoldHandles";
+
+ if (reply.isError()) {
+ debug().nospace() << " Failure: error " << reply.error().name() << ": " << reply.error().message();
+ mPriv->error = reply.error();
+ } else {
+ mPriv->handles = ReferencedHandles(connection(), handleType(), handlesToReference());
+ }
+ }
+
+ debug() << " Emitting finished()";
+ emit finished(this);
+
+ watcher->deleteLater();
+}
+
+} // Telepathy::Client
+} // Telepathy
diff --git a/TelepathyQt4/cli-pending-handles.h b/TelepathyQt4/cli-pending-handles.h
new file mode 100644
index 0000000..8db253d
--- /dev/null
+++ b/TelepathyQt4/cli-pending-handles.h
@@ -0,0 +1,215 @@
+/*
+ * This file is part of TelepathyQt4
+ *
+ * Copyright (C) 2008 Collabora Ltd. <http://www.collabora.co.uk/>
+ * Copyright (C) 2008 Nokia Corporation
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef _TelepathyQt4_cli_pending_handles_h_HEADER_GUARD_
+#define _TelepathyQt4_cli_pending_handles_h_HEADER_GUARD_
+
+/**
+ * \addtogroup clientsideproxies Client-side proxies
+ *
+ * Proxy objects representing remote service objects accessed via D-Bus.
+ *
+ * In addition to providing direct access to methods, signals and properties
+ * exported by the remote objects, some of these proxies offer features like
+ * automatic inspection of remote object capabilities, property tracking,
+ * backwards compatibility helpers for older services and other utilities.
+ */
+
+/**
+ * \defgroup clientconn Connection proxies
+ * \ingroup clientsideproxies
+ *
+ * Proxy objects representing remote Telepathy Connections and their optional
+ * interfaces.
+ */
+
+namespace Telepathy
+{
+namespace Client
+{
+class PendingHandles;
+}
+}
+
+#include <TelepathyQt4/Constants>
+#include <TelepathyQt4/Types>
+#include <TelepathyQt4/Client/Connection>
+#include <TelepathyQt4/Client/ReferencedHandles>
+
+namespace Telepathy
+{
+namespace Client
+{
+
+/**
+ * \class PendingHandles
+ * \ingroup clientconn
+ * \headerfile <TelepathyQt4/cli-pending-handles.h> <TelepathyQt4/Client/Connection>
+ *
+ * Class containing the parameters of and the reply to an asynchronous handle
+ * request/hold. Instances of this class cannot be constructed directly; the
+ * only ways to get one are to use Connection::requestHandles() or
+ * Connection::referenceHandles().
+ */
+class PendingHandles : public QObject
+{
+ Q_OBJECT
+
+public:
+ /**
+ * Class destructor.
+ */
+ ~PendingHandles();
+
+ /**
+ * Returns the Connection object through which the operation was made.
+ *
+ * \return Pointer to the Connection.
+ */
+ Connection* connection() const;
+
+ /**
+ * Returns the handle type specified in the operation.
+ *
+ * \return The handle type, as specified in #HandleType.
+ */
+ uint handleType() const;
+
+ /**
+ * Returns whether the operation was a handle request (as opposed to a
+ * reference of existing handles).
+ *
+ * \sa isReference()
+ *
+ * \return Whether the operation was a request (== !isReference()).
+ */
+ bool isRequest() const;
+
+ /**
+ * Returns whether the operation was a handle reference (as opposed to a
+ * request for new handles).
+ *
+ * \sa isRequest()
+ *
+ * \return Whether the operation was a reference (== !isRequest()).
+ */
+ bool isReference() const;
+
+ /**
+ * If the operation was a request (as returned by isRequest()), returns the
+ * names of the entities for which handles were requested for. Otherwise,
+ * returns an empty list.
+ *
+ * \return Reference to a list of the names of the entities.
+ */
+ const QStringList& namesRequested() const;
+
+ /**
+ * If the operation was a reference (as returned by isReference()), returns
+ * the handles which were to be referenced. Otherwise, returns an empty
+ * list.
+ *
+ * \return Reference to a list of the handles specified to be referenced.
+ */
+ const UIntList& handlesToReference() const;
+
+ /**
+ * Returns whether or not the operation has finished processing.
+ *
+ * \sa finished()
+ *
+ * \return If the operation is finished.
+ */
+ bool isFinished() const;
+
+ /**
+ * Returns whether or not the operation resulted in an error. If the
+ * operation has not yet finished processing (isFinished() returns
+ * <code>false</code>), this cannot yet be known, and <code>false</code>
+ * will be returned.
+ *
+ * \return <code>true</code> iff the operation has finished processing AND
+ * has resulted in an error.
+ */
+ bool isError() const;
+
+ /**
+ * Returns the error which the operation resulted in, if any. If isError()
+ * returns <code>false</code>, the operation has not (at least yet) resulted
+ * in an error, and an undefined value will be returned.
+ *
+ * \return The error as a QDBusError.
+ */
+ const QDBusError& error() const;
+
+ /**
+ * Returns whether or not the operation completed successfully. If the operation
+ * has not yet finished processing (isFinished() returns <code>false</code>),
+ * this cannot yet be known, and <code>false</code> will be returned.
+ *
+ * \return <code>true</code> iff the operation has finished processing AND has
+ * completed successfully.
+ */
+ bool isValid() const;
+
+ /**
+ * Returns the now-referenced handles resulting from the operation. If the
+ * operation has not (yet) finished successfully (isFinished() returns
+ * <code>false</code>), the return value is undefined.
+ *
+ * For requests of new handles, <code>handles()[i]</code> will be the handle
+ * corresponding to the entity name <code>namesToRequest()[i]</code>. For
+ * references of existing handles, <code>handles()[i] ==
+ * handlesToReference()[i]</code> will be true for any <code>i</code>.
+ *
+ * \return ReferencedHandles instance containing the handles.
+ */
+ ReferencedHandles handles() const;
+
+Q_SIGNALS:
+ /**
+ * Emitted when the operation finishes processing. isFinished() will then
+ * start returning <code>true</code> and isError(), error(), isValid() and
+ * handles() will become meaningful to use.
+ *
+ * \param pendingHandles The PendingHandles object for which the operation has
+ * finished.
+ */
+ void finished(Telepathy::Client::PendingHandles* pendingHandles);
+
+private Q_SLOTS:
+ void onCallFinished(QDBusPendingCallWatcher* watcher);
+
+private:
+ friend class Connection;
+
+ PendingHandles(Connection* connection, uint handleType, const QStringList& names);
+ PendingHandles(Connection* connection, uint handleType, const UIntList& handles, bool allHeld);
+
+ struct Private;
+ friend struct Private;
+ Private *mPriv;
+};
+
+} // Telepathy::Client
+} // Telepathy
+
+#endif
--
1.5.6.5
More information about the Telepathy-commits
mailing list