[Telepathy-commits] [telepathy-qt4/master] Connection: Removed requestChannel.
Andre Moreira Magalhaes (andrunko)
andre.magalhaes at collabora.co.uk
Mon Jan 26 12:07:12 PST 2009
Removing requestChannel we also removed test/pinnochio/chan-basics,
tests for channel will be added as soon as we have a test CM that
implements ensure/createChannel.
---
TelepathyQt4/Client/connection.cpp | 45 ----
TelepathyQt4/Client/connection.h | 3 -
TelepathyQt4/Client/pending-channel.cpp | 43 ----
TelepathyQt4/Client/pending-channel.h | 3 -
tests/pinocchio/Makefile.am | 4 -
tests/pinocchio/chan-basics.cpp | 403 -------------------------------
6 files changed, 0 insertions(+), 501 deletions(-)
delete mode 100644 tests/pinocchio/chan-basics.cpp
diff --git a/TelepathyQt4/Client/connection.cpp b/TelepathyQt4/Client/connection.cpp
index 663a340..da249f5 100644
--- a/TelepathyQt4/Client/connection.cpp
+++ b/TelepathyQt4/Client/connection.cpp
@@ -1000,51 +1000,6 @@ ConnectionInterface *Connection::baseInterface() const
}
/**
- * Asynchronously requests a channel satisfying the given channel type and
- * communicating with the contact, room, list etc. given by the handle type
- * and handle.
- *
- * Upon completion, the reply to the request can be retrieved through the
- * returned PendingChannel object. The object also provides access to the
- * parameters with which the call was made and a signal to connect to to get
- * notification of the request finishing processing. See the documentation
- * for that class for more info.
- *
- * The returned PendingChannel object should be freed using
- * its QObject::deleteLater() method after it is no longer used. However,
- * all PendingChannel objects resulting from requests to a particular
- * Connection will be freed when the Connection itself is freed. Conversely,
- * this means that the PendingChannel object should not be used after the
- * Connection is destroyed.
- *
- * \sa PendingChannel
- *
- * \param channelType D-Bus interface name of the channel type to request,
- * such as TELEPATHY_INTERFACE_CHANNEL_TYPE_TEXT.
- * \param handleType Type of the handle given, as specified in #HandleType.
- * \param handle Handle specifying the remote entity to communicate with.
- * \return Pointer to a newly constructed PendingChannel object, tracking
- * the progress of the request.
- */
-PendingChannel *Connection::requestChannel(const QString &channelType,
- uint handleType, uint handle)
-{
- if (mPriv->readiness != Private::ReadinessFull) {
- warning() << "Calling requestChannel with connection not yet connected";
- return new PendingChannel(this, TELEPATHY_ERROR_NOT_AVAILABLE,
- "Connection not yet connected");
- }
-
- debug() << "Requesting a Channel with type" << channelType
- << "and handle" << handle << "of type" << handleType;
-
- PendingChannel *channel =
- new PendingChannel(this, channelType, handleType, handle);
-
- return channel;
-}
-
-/**
* Asynchronously creates a channel satisfying the given request.
*
* The request MUST contain the following keys:
diff --git a/TelepathyQt4/Client/connection.h b/TelepathyQt4/Client/connection.h
index e134767..f2c3d9f 100644
--- a/TelepathyQt4/Client/connection.h
+++ b/TelepathyQt4/Client/connection.h
@@ -147,9 +147,6 @@ public:
return optionalInterface<DBus::PropertiesInterface>(BypassInterfaceCheck);
}
- PendingChannel *requestChannel(const QString &channelType,
- uint handleType, uint handle);
-
PendingChannel *createChannel(const QVariantMap &request);
PendingChannel *ensureChannel(const QVariantMap &request);
diff --git a/TelepathyQt4/Client/pending-channel.cpp b/TelepathyQt4/Client/pending-channel.cpp
index 29cab49..457d9a0 100644
--- a/TelepathyQt4/Client/pending-channel.cpp
+++ b/TelepathyQt4/Client/pending-channel.cpp
@@ -84,31 +84,6 @@ PendingChannel::PendingChannel(Connection *connection, const QString &errorName,
* Construct a new PendingChannel object.
*
* \param connection Connection to use.
- * \param channelType The channel type.
- * \param handleType The handle type.
- * \param handle The handle.
- */
-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;
-
- QDBusPendingCallWatcher *watcher =
- new QDBusPendingCallWatcher(connection->baseInterface()->RequestChannel(
- channelType, handleType, handle, true), this);
- connect(watcher,
- SIGNAL(finished(QDBusPendingCallWatcher *)),
- SLOT(onCallRequestChannelFinished(QDBusPendingCallWatcher *)));
-}
-
-/**
- * Construct a new PendingChannel object.
- *
- * \param connection Connection to use.
* \param request A dictionary containing the desirable properties.
* \param create Whether createChannel or ensureChannel should be called.
*/
@@ -212,24 +187,6 @@ Channel *PendingChannel::channel(QObject *parent) const
return channel;
}
-void PendingChannel::onCallRequestChannelFinished(QDBusPendingCallWatcher *watcher)
-{
- QDBusPendingReply<QDBusObjectPath> reply = *watcher;
-
- if (!reply.isError()) {
- debug() << "Got reply to Connection.RequestChannel - object path:" <<
- reply.value().path();
- mPriv->objectPath = reply.value();
- setFinished();
- } else {
- debug().nospace() << "RequestChannel failed:" <<
- reply.error().name() << ": " << reply.error().message();
- setFinishedWithError(reply.error());
- }
-
- watcher->deleteLater();
-}
-
void PendingChannel::onCallCreateChannelFinished(QDBusPendingCallWatcher *watcher)
{
QDBusPendingReply<QDBusObjectPath, QVariantMap> reply = *watcher;
diff --git a/TelepathyQt4/Client/pending-channel.h b/TelepathyQt4/Client/pending-channel.h
index 618bff4..e251bc7 100644
--- a/TelepathyQt4/Client/pending-channel.h
+++ b/TelepathyQt4/Client/pending-channel.h
@@ -57,7 +57,6 @@ public:
Channel *channel(QObject *parent = 0) const;
private Q_SLOTS:
- void onCallRequestChannelFinished(QDBusPendingCallWatcher *watcher);
void onCallCreateChannelFinished(QDBusPendingCallWatcher *watcher);
void onCallEnsureChannelFinished(QDBusPendingCallWatcher *watcher);
@@ -67,8 +66,6 @@ private:
PendingChannel(Connection *connection,
const QString &errorName, const QString &errorMessage);
PendingChannel(Connection *connection,
- const QString &type, uint handleType, uint handle);
- PendingChannel(Connection *connection,
const QVariantMap &request, bool create);
struct Private;
diff --git a/tests/pinocchio/Makefile.am b/tests/pinocchio/Makefile.am
index e326646..4b83953 100644
--- a/tests/pinocchio/Makefile.am
+++ b/tests/pinocchio/Makefile.am
@@ -7,14 +7,12 @@ EXTRA_DIST = \
lib.h
TESTS = \
- test-chan-basics \
test-cm-basics \
test-conn-basics \
test-do-nothing \
test-handles
BUILT_SOURCES = \
- _gen/chan-basics.cpp.moc.hpp \
_gen/cm-basics.cpp.moc.hpp \
_gen/conn-basics.cpp.moc.hpp \
_gen/do-nothing.cpp.moc.hpp \
@@ -27,8 +25,6 @@ _gen/%.moc.hpp: %
noinst_PROGRAMS = $(TESTS)
-test_chan_basics_SOURCES = chan-basics.cpp lib.cpp
-
test_cm_basics_SOURCES = cm-basics.cpp lib.cpp
test_conn_basics_SOURCES = conn-basics.cpp lib.cpp
diff --git a/tests/pinocchio/chan-basics.cpp b/tests/pinocchio/chan-basics.cpp
deleted file mode 100644
index 516ef0c..0000000
--- a/tests/pinocchio/chan-basics.cpp
+++ /dev/null
@@ -1,403 +0,0 @@
-#include <QtCore/QDebug>
-#include <QtCore/QTimer>
-
-#include <QtDBus/QtDBus>
-
-#include <TelepathyQt4/Constants>
-#include <TelepathyQt4/Client/DBus>
-#include <TelepathyQt4/Client/Channel>
-#include <TelepathyQt4/Client/Connection>
-#include <TelepathyQt4/Client/ConnectionManager>
-#include <TelepathyQt4/Client/PendingChannel>
-#include <TelepathyQt4/Client/PendingHandles>
-
-#include <tests/pinocchio/lib.h>
-
-using namespace Telepathy::Client;
-
-class TestChanBasics : public PinocchioTest
-{
- Q_OBJECT
-
-private:
- ConnectionManagerInterface* mCM;
-
- QString mConnBusName;
- QString mConnObjectPath;
- Connection *mConn;
-
- uint mSubscribeHandle;
- QString mSubscribeChanObjectPath;
- Channel *mChan;
-
-protected Q_SLOTS:
- // these ought to be private, but if they were, QTest would think they
- // were test cases. So, they're protected instead
- void expectConnReady(uint, uint);
- void expectChanReady(uint);
- void expectPendingChannelFinished(Telepathy::Client::PendingOperation*);
- void expectPendingChannelError(Telepathy::Client::PendingOperation*);
- void expectRequestHandlesFinished(Telepathy::Client::PendingOperation*);
- void expectRequestChannelFinished(Telepathy::Client::PendingOperation*);
-
-private Q_SLOTS:
- void initTestCase();
- void init();
-
- void testBasics();
- void testPendingChannel();
- void testPendingChannelError();
-
- void cleanup();
- void cleanupTestCase();
-};
-
-
-void TestChanBasics::expectConnReady(uint newStatus, uint newStatusReason)
-{
- switch (newStatus) {
- case Connection::StatusDisconnected:
- qWarning() << "Disconnected";
- mLoop->exit(1);
- break;
- case Connection::StatusConnecting:
- /* do nothing */
- break;
- case Connection::StatusConnected:
- qDebug() << "Ready";
- mLoop->exit(0);
- break;
- default:
- qWarning().nospace() << "What sort of status is "
- << newStatus << "?!";
- mLoop->exit(2);
- break;
- }
-}
-
-
-void TestChanBasics::initTestCase()
-{
- initTestCaseImpl();
-
- // Wait for the CM to start up
- QVERIFY(waitForPinocchio(5000));
-
- // Escape to the low-level API to make a Connection; this uses
- // pseudo-blocking calls for simplicity. Do not do this in production code
-
- mCM = new Telepathy::Client::ConnectionManagerInterface(
- pinocchioBusName(), pinocchioObjectPath());
-
- QDBusPendingReply<QString, QDBusObjectPath> reply;
- QVariantMap parameters;
- parameters.insert(QLatin1String("account"),
- QVariant::fromValue(QString::fromAscii("empty")));
- parameters.insert(QLatin1String("password"),
- QVariant::fromValue(QString::fromAscii("s3kr1t")));
-
- reply = mCM->RequestConnection("dummy", parameters);
- reply.waitForFinished();
- if (!reply.isValid()) {
- qWarning().nospace() << reply.error().name()
- << ": " << reply.error().message();
- QVERIFY(reply.isValid());
- }
- mConnBusName = reply.argumentAt<0>();
- mConnObjectPath = reply.argumentAt<1>().path();
-
- // Get a connected Connection
- mConn = new Connection(mConnBusName, mConnObjectPath);
-
- qDebug() << "calling Connect()";
- QVERIFY(connect(mConn->requestConnect(),
- SIGNAL(finished(Telepathy::Client::PendingOperation*)),
- this,
- SLOT(expectSuccessfulCall(Telepathy::Client::PendingOperation*))));
- QCOMPARE(mLoop->exec(), 0);
-
- QVERIFY(connect(mConn, SIGNAL(statusChanged(uint, uint)),
- this, SLOT(expectConnReady(uint, uint))));
- QCOMPARE(mLoop->exec(), 0);
- QVERIFY(disconnect(mConn, SIGNAL(statusChanged(uint, uint)),
- this, SLOT(expectConnReady(uint, uint))));
-
- QVERIFY(connect(mConn->requestHandles(Telepathy::HandleTypeList,
- QStringList() << "subscribe"),
- SIGNAL(finished(Telepathy::Client::PendingOperation*)),
- this,
- SLOT(expectRequestHandlesFinished(Telepathy::Client::PendingOperation*))));
- QCOMPARE(mLoop->exec(), 0);
-
- connect(mConn->requestChannel(TELEPATHY_INTERFACE_CHANNEL_TYPE_CONTACT_LIST,
- Telepathy::HandleTypeList, mSubscribeHandle),
- SIGNAL(finished(Telepathy::Client::PendingOperation*)),
- this,
- SLOT(expectRequestChannelFinished(Telepathy::Client::PendingOperation*)));
- QCOMPARE(mLoop->exec(), 0);
-
- if (mConn->requestsInterface()) {
- QVariantMap map;
- map.insert(QLatin1String(TELEPATHY_INTERFACE_ACCOUNT ".ChannelType"),
- TELEPATHY_INTERFACE_CHANNEL_TYPE_CONTACT_LIST);
- map.insert(QLatin1String(TELEPATHY_INTERFACE_ACCOUNT ".TargetHandleType"),
- Telepathy::HandleTypeList);
- map.insert(QLatin1String(TELEPATHY_INTERFACE_ACCOUNT ".TargetHandle"),
- mSubscribeHandle);
- connect(mConn->ensureChannel(map),
- SIGNAL(finished(Telepathy::Client::PendingOperation*)),
- this,
- SLOT(expectRequestChannelFinished(Telepathy::Client::PendingOperation*)));
- QCOMPARE(mLoop->exec(), 0);
- }
-}
-
-
-void TestChanBasics::init()
-{
- initImpl();
-}
-
-
-void TestChanBasics::expectChanReady(uint newReadiness)
-{
- switch (newReadiness) {
- case Channel::ReadinessJustCreated:
- qWarning() << "Changing from JustCreated to JustCreated is silly";
- mLoop->exit(1);
- break;
- case Channel::ReadinessFull:
- qDebug() << "Ready";
- mLoop->exit(0);
- break;
- case Channel::ReadinessClosed:
- // fall through
- case Channel::ReadinessDead:
- qWarning() << "Dead or closed!";
- mLoop->exit(3);
- break;
- default:
- qWarning().nospace() << "What sort of readiness is "
- << newReadiness << "?!";
- mLoop->exit(4);
- break;
- }
-}
-
-
-void TestChanBasics::testBasics()
-{
- mChan = new Channel(mConn, mSubscribeChanObjectPath);
-
- QCOMPARE(mChan->readiness(), Channel::ReadinessJustCreated);
- QEXPECT_FAIL("", "Doesn't seem to work", Continue);
- QCOMPARE(mChan->connection(), mConn);
-
- // Wait for readiness to reach Full
-
- qDebug() << "waiting for Full readiness";
- QVERIFY(connect(mChan, SIGNAL(readinessChanged(uint)),
- this, SLOT(expectChanReady(uint))));
- QCOMPARE(mLoop->exec(), 0);
- QVERIFY(disconnect(mChan, SIGNAL(readinessChanged(uint)),
- this, SLOT(expectChanReady(uint))));
-
- QCOMPARE(mChan->readiness(), Channel::ReadinessFull);
-
- QCOMPARE(mChan->channelType(),
- QString::fromAscii(TELEPATHY_INTERFACE_CHANNEL_TYPE_CONTACT_LIST));
- QCOMPARE(mChan->targetHandleType(),
- static_cast<uint>(Telepathy::HandleTypeList));
- QCOMPARE(mChan->targetHandle(), mSubscribeHandle);
-
- delete mChan;
-}
-
-
-void TestChanBasics::expectPendingChannelFinished(PendingOperation* op)
-{
- if (!op->isFinished()) {
- qWarning() << "unfinished";
- mLoop->exit(1);
- return;
- }
-
- if (op->isError()) {
- qWarning().nospace() << op->errorName()
- << ": " << op->errorMessage();
- mLoop->exit(2);
- return;
- }
-
- if (!op->isValid()) {
- qWarning() << "inconsistent results";
- mLoop->exit(3);
- return;
- }
-
- PendingChannel *pc = qobject_cast<PendingChannel*>(op);
- mChan = pc->channel();
- mLoop->exit(0);
-}
-
-void TestChanBasics::expectRequestHandlesFinished(PendingOperation* op)
-{
- if (!op->isFinished()) {
- qWarning() << "unfinished";
- mLoop->exit(1);
- return;
- }
-
- if (op->isError()) {
- qWarning().nospace() << op->errorName()
- << ": " << op->errorMessage();
- mLoop->exit(2);
- return;
- }
-
- if (!op->isValid()) {
- qWarning() << "inconsistent results";
- mLoop->exit(3);
- return;
- }
-
- PendingHandles *ph = qobject_cast<PendingHandles*>(op);
- mSubscribeHandle = ph->handles().at(0);
- mLoop->exit(0);
-}
-
-void TestChanBasics::expectRequestChannelFinished(PendingOperation* op)
-{
- if (!op->isFinished()) {
- qWarning() << "unfinished";
- mLoop->exit(1);
- return;
- }
-
- if (op->isError()) {
- qWarning().nospace() << op->errorName()
- << ": " << op->errorMessage();
- mLoop->exit(2);
- return;
- }
-
- if (!op->isValid()) {
- qWarning() << "inconsistent results";
- mLoop->exit(3);
- return;
- }
-
- PendingChannel *pc = qobject_cast<PendingChannel*>(op);
- Channel *chan = pc->channel();
- mSubscribeChanObjectPath = chan->objectPath();
- mLoop->exit(0);
-}
-
-void TestChanBasics::testPendingChannel()
-{
- PendingChannel *pc = mConn->requestChannel(
- QLatin1String(TELEPATHY_INTERFACE_CHANNEL_TYPE_CONTACT_LIST),
- Telepathy::HandleTypeList,
- mSubscribeHandle);
-
- QVERIFY(connect(pc, SIGNAL(finished(Telepathy::Client::PendingOperation*)),
- this, SLOT(expectPendingChannelFinished(Telepathy::Client::PendingOperation*))));
- QCOMPARE(mLoop->exec(), 0);
- QVERIFY(disconnect(pc, SIGNAL(finished(Telepathy::Client::PendingOperation*)),
- this, SLOT(expectPendingChannelFinished(Telepathy::Client::PendingOperation*))));
-
- QVERIFY(mChan);
-
- QCOMPARE(mChan->readiness(), Channel::ReadinessJustCreated);
- QEXPECT_FAIL("", "Doesn't seem to work", Continue);
- QCOMPARE(mChan->connection(), mConn);
-
- // Wait for readiness to reach Full
- // FIXME: eventually, this should be encapsulated in the PendingChannel
-
- qDebug() << "waiting for Full readiness";
- QVERIFY(connect(mChan, SIGNAL(readinessChanged(uint)),
- this, SLOT(expectChanReady(uint))));
- QCOMPARE(mLoop->exec(), 0);
- QVERIFY(disconnect(mChan, SIGNAL(readinessChanged(uint)),
- this, SLOT(expectChanReady(uint))));
-
- QCOMPARE(mChan->readiness(), Channel::ReadinessFull);
-
- QCOMPARE(mChan->channelType(),
- QString::fromAscii(TELEPATHY_INTERFACE_CHANNEL_TYPE_CONTACT_LIST));
- QCOMPARE(mChan->targetHandleType(),
- static_cast<uint>(Telepathy::HandleTypeList));
- QCOMPARE(mChan->targetHandle(), mSubscribeHandle);
-
- delete mChan;
-}
-
-void TestChanBasics::expectPendingChannelError(PendingOperation* op)
-{
- if (!op->isFinished()) {
- qWarning() << "unfinished";
- mLoop->exit(1);
- return;
- }
-
- if (!op->isError()) {
- qWarning() << "no error";
- mLoop->exit(2);
- return;
- }
-
- qDebug().nospace() << op->errorName()
- << ": " << op->errorMessage();
-
- if (op->isValid()) {
- qWarning() << "inconsistent results";
- mLoop->exit(3);
- return;
- }
-
- mLoop->exit(0);
-}
-
-
-void TestChanBasics::testPendingChannelError()
-{
- PendingChannel *pc = mConn->requestChannel(
- QLatin1String(TELEPATHY_INTERFACE_CHANNEL_TYPE_CONTACT_LIST),
- Telepathy::HandleTypeList,
- 31337);
-
- QVERIFY(connect(pc, SIGNAL(finished(Telepathy::Client::PendingOperation*)),
- this, SLOT(expectPendingChannelError(Telepathy::Client::PendingOperation*))));
- QCOMPARE(mLoop->exec(), 0);
- QVERIFY(disconnect(pc, SIGNAL(finished(Telepathy::Client::PendingOperation*)),
- this, SLOT(expectPendingChannelError(Telepathy::Client::PendingOperation*))));
-}
-
-
-void TestChanBasics::cleanup()
-{
- cleanupImpl();
-}
-
-
-void TestChanBasics::cleanupTestCase()
-{
- QVERIFY(connect(mConn->requestDisconnect(),
- SIGNAL(finished(Telepathy::Client::PendingOperation*)),
- this,
- SLOT(expectSuccessfulCall(Telepathy::Client::PendingOperation*))));
- QCOMPARE(mLoop->exec(), 0);
-
- delete mConn;
- mConn = NULL;
-
- delete mCM;
- mCM = NULL;
-
- cleanupTestCaseImpl();
-}
-
-
-QTEST_MAIN(TestChanBasics)
-#include "_gen/chan-basics.cpp.moc.hpp"
--
1.5.6.5
More information about the Telepathy-commits
mailing list