[Telepathy-commits] [telepathy-qt4/master] Move PendingChannel to a separate header file from Connection's

Olli Salli olli.salli at collabora.co.uk
Tue Dec 9 07:30:45 PST 2008


---
 TelepathyQt4/Makefile.am             |    3 +
 TelepathyQt4/cli-connection.cpp      |   76 -------------------
 TelepathyQt4/cli-connection.h        |   85 ++-------------------
 TelepathyQt4/cli-pending-channel.cpp |  110 +++++++++++++++++++++++++++
 TelepathyQt4/cli-pending-channel.h   |  137 ++++++++++++++++++++++++++++++++++
 5 files changed, 257 insertions(+), 154 deletions(-)
 create mode 100644 TelepathyQt4/cli-pending-channel.cpp
 create mode 100644 TelepathyQt4/cli-pending-channel.h

diff --git a/TelepathyQt4/Makefile.am b/TelepathyQt4/Makefile.am
index d9fdc3c..8e8d265 100644
--- a/TelepathyQt4/Makefile.am
+++ b/TelepathyQt4/Makefile.am
@@ -45,6 +45,7 @@ libtelepathy_qt4_la_SOURCES = \
     cli-media-session-handler.cpp \
     cli-media-stream-handler.cpp \
     cli-optional-interface-factory.cpp \
+    cli-pending-channel.cpp \
     cli-pending-operation.cpp \
     cli-properties.cpp \
     debug.cpp \
@@ -75,6 +76,7 @@ nodist_libtelepathy_qt4_la_SOURCES = \
     cli-channel.moc.hpp \
     cli-connection.moc.hpp \
     cli-dbus-proxy.moc.hpp \
+    cli-pending-channel.moc.hpp \
     cli-pending-operation.moc.hpp \
     cli-simple-pending-operations.moc.hpp
 
@@ -92,6 +94,7 @@ tpqt4include_HEADERS = \
     cli-media-session-handler.h \
     cli-media-stream-handler.h \
     cli-optional-interface-factory.h \
+    cli-pending-channel.h \
     cli-pending-operation.h \
     cli-properties.h \
     cli-simple-pending-operations.h \
diff --git a/TelepathyQt4/cli-connection.cpp b/TelepathyQt4/cli-connection.cpp
index c3ca4c4..4219987 100644
--- a/TelepathyQt4/cli-connection.cpp
+++ b/TelepathyQt4/cli-connection.cpp
@@ -478,81 +478,5 @@ PendingOperation* Connection::requestDisconnect()
     return new PendingVoidMethodCall(this, this->Disconnect());
 }
 
-struct PendingChannel::Private
-{
-    QString channelType;
-    uint handleType;
-    uint handle;
-    QDBusObjectPath objectPath;
-};
-
-PendingChannel::PendingChannel(Connection* connection, const QString& channelType, uint handleType, uint handle)
-    : PendingOperation(connection), mPriv(new Private)
-{
-    mPriv->channelType = channelType;
-    mPriv->handleType = handleType;
-    mPriv->handle = handle;
-}
-
-PendingChannel::~PendingChannel()
-{
-    delete mPriv;
-}
-
-Connection* PendingChannel::connection() const
-{
-    return qobject_cast<Connection*>(parent());
-}
-
-const QString& PendingChannel::channelType() const
-{
-    return mPriv->channelType;
-}
-
-uint PendingChannel::handleType() const
-{
-    return mPriv->handleType;
-}
-
-uint PendingChannel::handle() const
-{
-    return mPriv->handle;
-}
-
-Channel* PendingChannel::channel(QObject* parent) const
-{
-    if (!isFinished()) {
-        warning() << "PendingChannel::channel called before finished, returning 0";
-        return 0;
-    } else if (!isValid()) {
-        warning() << "PendingChannel::channel called when not valid, returning 0";
-        return 0;
-    }
-
-    Channel* channel =
-        new Channel(connection(),
-                    mPriv->objectPath.path(),
-                    parent);
-    return channel;
-}
-
-void PendingChannel::onCallFinished(QDBusPendingCallWatcher* watcher)
-{
-    QDBusPendingReply<QDBusObjectPath> reply = *watcher;
-
-    debug() << "Received reply to RequestChannel";
-
-    if (!reply.isError()) {
-        debug() << " Success: object path" << reply.value().path();
-        mPriv->objectPath = reply.value();
-        setFinished();
-    } else {
-        debug().nospace() << " Failure: error " << reply.error().name() << ": " << reply.error().message();
-        setFinishedWithError(reply.error());
-    }
-
-    watcher->deleteLater();
-}
-
 }
 }
diff --git a/TelepathyQt4/cli-connection.h b/TelepathyQt4/cli-connection.h
index aaac8c7..4c4acf5 100644
--- a/TelepathyQt4/cli-connection.h
+++ b/TelepathyQt4/cli-connection.h
@@ -41,24 +41,25 @@
  * interfaces.
  */
 
-#include <TelepathyQt4/_gen/cli-connection.h>
-
-#include <QDBusPendingCallWatcher>
-#include <QStringList>
-
 namespace Telepathy {
 namespace Client {
 class Connection;
-class PendingChannel;
 }
 }
 
+#include <TelepathyQt4/_gen/cli-connection.h>
+
+#include <QDBusPendingCallWatcher>
+#include <QStringList>
+
 #include <TelepathyQt4/Constants>
 #include <TelepathyQt4/Client/Channel>
 #include <TelepathyQt4/Client/DBus>
 #include <TelepathyQt4/Client/OptionalInterfaceFactory>
 #include <TelepathyQt4/Client/PendingOperation>
 
+#include "cli-pending-channel.h"
+
 namespace Telepathy
 {
 namespace Client
@@ -451,78 +452,6 @@ private:
     Private *mPriv;
 };
 
-/**
- * \class PendingChannel
- * \ingroup clientconn
- * \headerfile <TelepathyQt4/cli-connection.h> <TelepathyQt4/Client/Connection>
- *
- * Class containing the parameters of and the reply to an asynchronous channel
- * request. Instances of this class cannot be constructed directly; the only way
- * to get one is to use Connection::requestChannel().
- */
-class PendingChannel : public PendingOperation
-{
-    Q_OBJECT
-
-public:
-    /**
-     * Class destructor.
-     */
-    ~PendingChannel();
-
-    /**
-     * Returns the Connection object through which the channel request was made.
-     *
-     * \return Pointer to the Connection.
-     */
-    Connection* connection() const;
-
-    /**
-     * Returns the channel type specified in the channel request.
-     *
-     * \return The D-Bus interface name of the interface specific to the
-     *         requested channel type.
-     */
-    const QString& channelType() const;
-
-    /**
-     * Returns the handle type specified in the channel request.
-     *
-     * \return The handle type, as specified in #HandleType.
-     */
-    uint handleType() const;
-
-    /**
-     * Returns the handle specified in the channel request.
-     *
-     * \return The handle.
-     */
-    uint handle() const;
-
-    /**
-     * Returns a newly constructed 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 0 will be returned.
-     *
-     * \param parent Passed to the Channel constructor.
-     * \return Pointer to the new Channel object.
-     */
-    Channel* channel(QObject* parent = 0) const;
-
-private Q_SLOTS:
-    void onCallFinished(QDBusPendingCallWatcher* watcher);
-
-private:
-    friend class Connection;
-
-    PendingChannel(Connection* connection, const QString& type, uint handleType, uint handle);
-
-    struct Private;
-    friend struct Private;
-    Private *mPriv;
-};
-
 }
 }
 
diff --git a/TelepathyQt4/cli-pending-channel.cpp b/TelepathyQt4/cli-pending-channel.cpp
new file mode 100644
index 0000000..22fccc2
--- /dev/null
+++ b/TelepathyQt4/cli-pending-channel.cpp
@@ -0,0 +1,110 @@
+/*
+ * 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-channel.h"
+
+#include "cli-pending-channel.moc.hpp"
+
+#include "debug-internal.hpp"
+
+namespace Telepathy
+{
+namespace Client
+{
+
+struct PendingChannel::Private
+{
+    QString channelType;
+    uint handleType;
+    uint handle;
+    QDBusObjectPath objectPath;
+};
+
+PendingChannel::PendingChannel(Connection* connection, const QString& channelType, uint handleType, uint handle)
+    : PendingOperation(connection), mPriv(new Private)
+{
+    mPriv->channelType = channelType;
+    mPriv->handleType = handleType;
+    mPriv->handle = handle;
+}
+
+PendingChannel::~PendingChannel()
+{
+    delete mPriv;
+}
+
+Connection* PendingChannel::connection() const
+{
+    return qobject_cast<Connection*>(parent());
+}
+
+const QString& PendingChannel::channelType() const
+{
+    return mPriv->channelType;
+}
+
+uint PendingChannel::handleType() const
+{
+    return mPriv->handleType;
+}
+
+uint PendingChannel::handle() const
+{
+    return mPriv->handle;
+}
+
+Channel* PendingChannel::channel(QObject* parent) const
+{
+    if (!isFinished()) {
+        warning() << "PendingChannel::channel called before finished, returning 0";
+        return 0;
+    } else if (!isValid()) {
+        warning() << "PendingChannel::channel called when not valid, returning 0";
+        return 0;
+    }
+
+    Channel* channel =
+        new Channel(connection(),
+                    mPriv->objectPath.path(),
+                    parent);
+    return channel;
+}
+
+void PendingChannel::onCallFinished(QDBusPendingCallWatcher* watcher)
+{
+    QDBusPendingReply<QDBusObjectPath> reply = *watcher;
+
+    debug() << "Received reply to RequestChannel";
+
+    if (!reply.isError()) {
+        debug() << " Success: object path" << reply.value().path();
+        mPriv->objectPath = reply.value();
+        setFinished();
+    } else {
+        debug().nospace() << " Failure: error " << reply.error().name() << ": " << reply.error().message();
+        setFinishedWithError(reply.error());
+    }
+
+    watcher->deleteLater();
+}
+
+} // Telepathy::Client
+} // Telepathy
diff --git a/TelepathyQt4/cli-pending-channel.h b/TelepathyQt4/cli-pending-channel.h
new file mode 100644
index 0000000..95d4243
--- /dev/null
+++ b/TelepathyQt4/cli-pending-channel.h
@@ -0,0 +1,137 @@
+/*
+ * 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_channel_h_HEADER_GUARD_
+#define _TelepathyQt4_cli_pending_channel_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 PendingChannel;
+}
+}
+
+#include <TelepathyQt4/Constants>
+#include <TelepathyQt4/Types>
+#include <TelepathyQt4/Client/Connection>
+#include <TelepathyQt4/Client/PendingOperation>
+
+namespace Telepathy
+{
+namespace Client
+{
+
+/**
+ * \class PendingChannel
+ * \ingroup clientconn
+ * \headerfile <TelepathyQt4/cli-pending-channel.h> <TelepathyQt4/Client/Connection>
+ *
+ * Class containing the parameters of and the reply to an asynchronous channel
+ * request. Instances of this class cannot be constructed directly; the only way
+ * to get one is to use Connection::requestChannel().
+ */
+class PendingChannel : public PendingOperation
+{
+    Q_OBJECT
+
+public:
+    /**
+     * Class destructor.
+     */
+    ~PendingChannel();
+
+    /**
+     * Returns the Connection object through which the channel request was made.
+     *
+     * \return Pointer to the Connection.
+     */
+    Connection* connection() const;
+
+    /**
+     * Returns the channel type specified in the channel request.
+     *
+     * \return The D-Bus interface name of the interface specific to the
+     *         requested channel type.
+     */
+    const QString& channelType() const;
+
+    /**
+     * Returns the handle type specified in the channel request.
+     *
+     * \return The handle type, as specified in #HandleType.
+     */
+    uint handleType() const;
+
+    /**
+     * Returns the handle specified in the channel request.
+     *
+     * \return The handle.
+     */
+    uint handle() const;
+
+    /**
+     * Returns a newly constructed 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 0 will be returned.
+     *
+     * \param parent Passed to the Channel constructor.
+     * \return Pointer to the new Channel object.
+     */
+    Channel* channel(QObject* parent = 0) const;
+
+private Q_SLOTS:
+    void onCallFinished(QDBusPendingCallWatcher* watcher);
+
+private:
+    friend class Connection;
+
+    PendingChannel(Connection* connection, const QString& type, uint handleType, uint handle);
+
+    struct Private;
+    friend struct Private;
+    Private *mPriv;
+};
+
+} // Telepathy::Client
+} // Telepathy
+
+#endif
-- 
1.5.6.5




More information about the Telepathy-commits mailing list