diff options
author | Dario Freddi <dario.freddi@collabora.co.uk> | 2011-03-12 14:49:45 +0100 |
---|---|---|
committer | Dario Freddi <dario.freddi@collabora.com> | 2012-07-02 18:23:52 +0200 |
commit | ccdd91ea8d506023b17de41f052f0286da1a0711 (patch) | |
tree | f24f84da0c3ccc38091c34fc397b8dd88635b1b6 | |
parent | 25e909053f670292da94052f9ba2dedfcd0dd9ff (diff) |
dbus-tubes: Remove private inheritance, and references to unimplemented Qt API.
As with Stream Tubes, now DBus tubes return the bare DBus address instead of a QDBusConnection or
a QDBusServer.
-rw-r--r-- | TelepathyQt/dbus-tube-channel-internal.h | 62 | ||||
-rw-r--r-- | TelepathyQt/dbus-tube-channel.cpp | 134 | ||||
-rw-r--r-- | TelepathyQt/dbus-tube-channel.h | 18 | ||||
-rw-r--r-- | TelepathyQt/incoming-dbus-tube-channel.cpp | 64 | ||||
-rw-r--r-- | TelepathyQt/incoming-dbus-tube-channel.h | 13 | ||||
-rw-r--r-- | TelepathyQt/outgoing-dbus-tube-channel.cpp | 58 | ||||
-rw-r--r-- | TelepathyQt/outgoing-dbus-tube-channel.h | 12 |
7 files changed, 127 insertions, 234 deletions
diff --git a/TelepathyQt/dbus-tube-channel-internal.h b/TelepathyQt/dbus-tube-channel-internal.h deleted file mode 100644 index 4c7e2a70..00000000 --- a/TelepathyQt/dbus-tube-channel-internal.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * This file is part of TelepathyQt - * - * Copyright (C) 2010 Collabora Ltd. <http://www.collabora.co.uk/> - * - * 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 _TelepathyQt_dbus_tube_channel_internal_h_HEADER_GUARD_ -#define _TelepathyQt_dbus_tube_channel_internal_h_HEADER_GUARD_ - -#include <TelepathyQt/DBusTubeChannel> - -namespace Tp { - -class TP_QT_NO_EXPORT DBusTubeChannelPrivate -{ - Q_DECLARE_PUBLIC(DBusTubeChannel) -protected: - DBusTubeChannel * const q_ptr; - -public: - DBusTubeChannelPrivate(DBusTubeChannel *parent); - virtual ~DBusTubeChannelPrivate(); - - void init(); - - void extractProperties(const QVariantMap &props); - void extractParticipants(const Tp::DBusTubeParticipants &participants); - - static void introspectDBusTube(DBusTubeChannelPrivate *self); - static void introspectBusNamesMonitoring(DBusTubeChannelPrivate *self); - - ReadinessHelper *readinessHelper; - - // Properties - UIntList accessControls; - QString serviceName; - QHash< ContactPtr, QString > busNames; - QString address; - - // Private slots - void gotDBusTubeProperties(QDBusPendingCallWatcher *watcher); - void onDBusNamesChanged(const Tp::DBusTubeParticipants &added, const Tp::UIntList &removed); - -}; - -} - -#endif diff --git a/TelepathyQt/dbus-tube-channel.cpp b/TelepathyQt/dbus-tube-channel.cpp index 619c48f7..e91c971d 100644 --- a/TelepathyQt/dbus-tube-channel.cpp +++ b/TelepathyQt/dbus-tube-channel.cpp @@ -18,7 +18,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "TelepathyQt/dbus-tube-channel-internal.h" +#include <TelepathyQt/DBusTubeChannel> #include <TelepathyQt/Connection> #include <TelepathyQt/ContactManager> @@ -28,20 +28,34 @@ namespace Tp { -DBusTubeChannelPrivate::DBusTubeChannelPrivate(DBusTubeChannel *parent) - : q_ptr(parent) +struct TP_QT_NO_EXPORT DBusTubeChannel::Private { -} + Private(DBusTubeChannel *parent); + virtual ~Private(); -DBusTubeChannelPrivate::~DBusTubeChannelPrivate() -{ -} + void extractProperties(const QVariantMap &props); + void extractParticipants(const Tp::DBusTubeParticipants &participants); + + static void introspectDBusTube(Private *self); + static void introspectBusNamesMonitoring(Private *self); + + ReadinessHelper *readinessHelper; + + // Public object + DBusTubeChannel *parent; + + // Properties + UIntList accessControls; + QString serviceName; + QHash< ContactPtr, QString > busNames; + QString address; +}; -void DBusTubeChannelPrivate::init() +DBusTubeChannel::Private::Private(DBusTubeChannel *parent) + : parent(parent) { - Q_Q(DBusTubeChannel); // Initialize readinessHelper + introspectables here - readinessHelper = q->readinessHelper(); + readinessHelper = parent->readinessHelper(); ReadinessHelper::Introspectables introspectables; @@ -49,7 +63,7 @@ void DBusTubeChannelPrivate::init() QSet<uint>() << 0, // makesSenseForStatuses Features() << TubeChannel::FeatureCore, // dependsOnFeatures (core) QStringList(), // dependsOnInterfaces - (ReadinessHelper::IntrospectFunc) &DBusTubeChannelPrivate::introspectDBusTube, + (ReadinessHelper::IntrospectFunc) &Private::introspectDBusTube, this); introspectables[DBusTubeChannel::FeatureDBusTube] = introspectableDBusTube; @@ -57,84 +71,84 @@ void DBusTubeChannelPrivate::init() QSet<uint>() << 0, // makesSenseForStatuses Features() << DBusTubeChannel::FeatureDBusTube, // dependsOnFeatures (core) QStringList(), // dependsOnInterfaces - (ReadinessHelper::IntrospectFunc) &DBusTubeChannelPrivate::introspectBusNamesMonitoring, + (ReadinessHelper::IntrospectFunc) &Private::introspectBusNamesMonitoring, this); introspectables[DBusTubeChannel::FeatureBusNamesMonitoring] = introspectableBusNamesMonitoring; readinessHelper->addIntrospectables(introspectables); } -void DBusTubeChannelPrivate::extractProperties(const QVariantMap& props) +DBusTubeChannel::Private::~Private() +{ +} + +void DBusTubeChannel::Private::extractProperties(const QVariantMap& props) { serviceName = qdbus_cast<QString>(props[QLatin1String("Service")]); accessControls = qdbus_cast<UIntList>(props[QLatin1String("SupportedAccessControls")]); extractParticipants(qdbus_cast<DBusTubeParticipants>(props[QLatin1String("DBusNames")])); } -void DBusTubeChannelPrivate::extractParticipants(const Tp::DBusTubeParticipants& participants) +void DBusTubeChannel::Private::extractParticipants(const Tp::DBusTubeParticipants& participants) { - Q_Q(DBusTubeChannel); - busNames.clear(); for (DBusTubeParticipants::const_iterator i = participants.constBegin(); i != participants.constEnd(); ++i) { - busNames.insert(q->connection()->contactManager()->lookupContactByHandle(i.key()), + busNames.insert(parent->connection()->contactManager()->lookupContactByHandle(i.key()), i.value()); } } -void DBusTubeChannelPrivate::gotDBusTubeProperties(QDBusPendingCallWatcher* watcher) +void DBusTubeChannel::gotDBusTubeProperties(QDBusPendingCallWatcher* watcher) { QDBusPendingReply<QVariantMap> reply = *watcher; if (!reply.isError()) { QVariantMap props = reply.value(); - extractProperties(props); + mPriv->extractProperties(props); debug() << "Got reply to Properties::GetAll(DBusTubeChannel)"; - readinessHelper->setIntrospectCompleted(DBusTubeChannel::FeatureDBusTube, true); + mPriv->readinessHelper->setIntrospectCompleted(DBusTubeChannel::FeatureDBusTube, true); } else { warning().nospace() << "Properties::GetAll(DBusTubeChannel) failed " "with " << reply.error().name() << ": " << reply.error().message(); - readinessHelper->setIntrospectCompleted(DBusTubeChannel::FeatureDBusTube, false, + mPriv->readinessHelper->setIntrospectCompleted(DBusTubeChannel::FeatureDBusTube, false, reply.error()); } } -void DBusTubeChannelPrivate::onDBusNamesChanged( - const Tp::DBusTubeParticipants& added, - const Tp::UIntList& removed) +void DBusTubeChannel::onDBusNamesChanged( + const Tp::DBusTubeParticipants &added, + const Tp::UIntList &removed) { - Q_Q(DBusTubeChannel); - QHash< ContactPtr, QString > realAdded; QList< ContactPtr > realRemoved; for (DBusTubeParticipants::const_iterator i = added.constBegin(); i != added.constEnd(); ++i) { - ContactPtr contact = q->connection()->contactManager()->lookupContactByHandle(i.key()); + ContactPtr contact = connection()->contactManager()->lookupContactByHandle(i.key()); realAdded.insert(contact, i.value()); // Add it to our hash as well - busNames.insert(contact, i.value()); + mPriv->busNames.insert(contact, i.value()); } foreach (uint handle, removed) { - ContactPtr contact = q->connection()->contactManager()->lookupContactByHandle(handle); + ContactPtr contact = connection()->contactManager()->lookupContactByHandle(handle); realRemoved << contact; // Remove it from our hash as well - busNames.remove(contact); + mPriv->busNames.remove(contact); } // Emit the "real" signal - emit q->busNamesChanged(realAdded, realRemoved); + emit busNamesChanged(realAdded, realRemoved); } -void DBusTubeChannelPrivate::introspectBusNamesMonitoring( - DBusTubeChannelPrivate* self) +void DBusTubeChannel::Private::introspectBusNamesMonitoring( + DBusTubeChannel::Private* self) { - DBusTubeChannel *parent = self->q_func(); + DBusTubeChannel *parent = self->parent; Client::ChannelTypeDBusTubeInterface *dbusTubeInterface = parent->interface<Client::ChannelTypeDBusTubeInterface>(); @@ -153,10 +167,10 @@ void DBusTubeChannelPrivate::introspectBusNamesMonitoring( self->readinessHelper->setIntrospectCompleted(DBusTubeChannel::FeatureBusNamesMonitoring, true); } -void DBusTubeChannelPrivate::introspectDBusTube( - DBusTubeChannelPrivate* self) +void DBusTubeChannel::Private::introspectDBusTube( + DBusTubeChannel::Private* self) { - DBusTubeChannel *parent = self->q_func(); + DBusTubeChannel *parent = self->parent; debug() << "Introspect dbus tube properties"; @@ -247,32 +261,16 @@ DBusTubeChannel::DBusTubeChannel(const ConnectionPtr &connection, const QString &objectPath, const QVariantMap &immutableProperties) : TubeChannel(connection, objectPath, immutableProperties), - d_ptr(new DBusTubeChannelPrivate(this)) -{ - // Initialize - Q_D(DBusTubeChannel); - d->init(); -} - -DBusTubeChannel::DBusTubeChannel(const ConnectionPtr& connection, - const QString& objectPath, - const QVariantMap& immutableProperties, - DBusTubeChannelPrivate& dd) - : TubeChannel(connection, objectPath, immutableProperties) - , d_ptr(&dd) + mPriv(new Private(this)) { - // Initialize - Q_D(DBusTubeChannel); - d->init(); } - /** * Class destructor. */ DBusTubeChannel::~DBusTubeChannel() { - delete d_ptr; + delete mPriv; } /** @@ -286,9 +284,7 @@ QString DBusTubeChannel::serviceName() const return QString(); } - Q_D(const DBusTubeChannel); - - return d->serviceName; + return mPriv->serviceName; } @@ -308,18 +304,9 @@ bool DBusTubeChannel::supportsCredentials() const return false; } - Q_D(const DBusTubeChannel); - - return d->accessControls.contains(static_cast<uint>(Tp::SocketAccessControlCredentials)); + return mPriv->accessControls.contains(static_cast<uint>(Tp::SocketAccessControlCredentials)); } - -void DBusTubeChannel::connectNotify(const char* signal) -{ - TubeChannel::connectNotify(signal); -} - - /** * If the tube has been opened, this function returns the private bus address you should be listening * to for using this tube. Please note that specialized superclasses such as IncomingDBusTubeChannel and @@ -335,9 +322,7 @@ QString DBusTubeChannel::address() const return QString(); } - Q_D(const DBusTubeChannel); - - return d->address; + return mPriv->address; } @@ -356,9 +341,12 @@ QHash< ContactPtr, QString > DBusTubeChannel::busNames() const return QHash< ContactPtr, QString >(); } - Q_D(const DBusTubeChannel); + return mPriv->busNames; +} - return d->busNames; +UIntList DBusTubeChannel::accessControls() const +{ + return mPriv->accessControls; } } diff --git a/TelepathyQt/dbus-tube-channel.h b/TelepathyQt/dbus-tube-channel.h index 379cfe37..07cd907d 100644 --- a/TelepathyQt/dbus-tube-channel.h +++ b/TelepathyQt/dbus-tube-channel.h @@ -36,11 +36,6 @@ class TP_QT_EXPORT DBusTubeChannel : public TubeChannel { Q_OBJECT Q_DISABLE_COPY(DBusTubeChannel) - Q_DECLARE_PRIVATE(DBusTubeChannel) - - // private slots: - Q_PRIVATE_SLOT(d_func(), void gotDBusTubeProperties(QDBusPendingCallWatcher*)) - Q_PRIVATE_SLOT(d_func(), void onDBusNamesChanged(Tp::DBusTubeParticipants,Tp::UIntList)) public: static const Feature FeatureDBusTube; @@ -59,20 +54,19 @@ public: QString address() const; + UIntList accessControls() const; + protected: DBusTubeChannel(const ConnectionPtr &connection, const QString &objectPath, const QVariantMap &immutableProperties); - // For private class inheriters - DBusTubeChannel(const ConnectionPtr &connection, const QString &objectPath, - const QVariantMap &immutableProperties, DBusTubeChannelPrivate &dd); - - virtual void connectNotify(const char* signal); - - DBusTubeChannelPrivate * const d_ptr; Q_SIGNALS: void busNamesChanged(const QHash< ContactPtr, QString > &added, const QList< ContactPtr > &removed); +private Q_SLOTS: + void gotDBusTubeProperties(QDBusPendingCallWatcher *watcher); + void onDBusNamesChanged(const Tp::DBusTubeParticipants &added, const Tp::UIntList &removed); + private: struct Private; friend struct Private; diff --git a/TelepathyQt/incoming-dbus-tube-channel.cpp b/TelepathyQt/incoming-dbus-tube-channel.cpp index 36b1de62..1e463fa1 100644 --- a/TelepathyQt/incoming-dbus-tube-channel.cpp +++ b/TelepathyQt/incoming-dbus-tube-channel.cpp @@ -19,7 +19,6 @@ */ #include <TelepathyQt/IncomingDBusTubeChannel> -#include "TelepathyQt/dbus-tube-channel-internal.h" #include <TelepathyQt/Connection> #include <TelepathyQt/ContactManager> @@ -31,28 +30,27 @@ namespace Tp { -class TP_QT_NO_EXPORT IncomingDBusTubeChannelPrivate : public DBusTubeChannelPrivate +struct TP_QT_NO_EXPORT IncomingDBusTubeChannel::Private { - Q_DECLARE_PUBLIC(IncomingDBusTubeChannel) public: - IncomingDBusTubeChannelPrivate(IncomingDBusTubeChannel* parent); - virtual ~IncomingDBusTubeChannelPrivate(); + Private(IncomingDBusTubeChannel* parent); + virtual ~Private(); - QDBusConnection connection; + // Public object + IncomingDBusTubeChannel *parent; + + QString address; }; -IncomingDBusTubeChannelPrivate::IncomingDBusTubeChannelPrivate(IncomingDBusTubeChannel* parent) - : DBusTubeChannelPrivate(parent) - , connection(QLatin1String("none")) +IncomingDBusTubeChannel::Private::Private(IncomingDBusTubeChannel* parent) + : parent(parent) { } -IncomingDBusTubeChannelPrivate::~IncomingDBusTubeChannelPrivate() +IncomingDBusTubeChannel::Private::~Private() { } - - struct TP_QT_NO_EXPORT PendingDBusTubeAcceptPrivate { PendingDBusTubeAcceptPrivate(PendingDBusTubeAccept *parent); @@ -89,7 +87,7 @@ void PendingDBusTubeAcceptPrivate::onAcceptFinished(PendingOperation* op) // Now get the address and set it PendingString *ps = qobject_cast< PendingString* >(op); - tube->d_func()->address = ps->result(); + tube->mPriv->address = ps->result(); // It might have been already opened - check if (tube->state() == TubeChannelStateOpen) { @@ -105,20 +103,8 @@ void PendingDBusTubeAcceptPrivate::onStateChanged(TubeChannelState state) { debug() << "Tube state changed to " << state; if (state == TubeChannelStateOpen) { - // The tube is ready: let's create the QDBusConnection and set the tube's object path as the name - QDBusConnection connection = QDBusConnection::sessionBus();/* = QDBusConnection::connectToPeer(tube->d_func()->address, - tube->objectPath());*/ - - if (!connection.isConnected()) { - // Something went wrong - warning() << "Could not create a QDBusConnection"; - parent->setFinishedWithError(QLatin1String("Connection refused"), - QLatin1String("Could not create a valid QDBusConnection from the tube")); - } else { - // Inject the server - tube->d_func()->connection = connection; - parent->setFinished(); - } + // The tube is ready: let's inject the address into the tube itself + parent->setFinished(); } else if (state != TubeChannelStateLocalPending) { // Something happened parent->setFinishedWithError(QLatin1String("Connection refused"), @@ -158,9 +144,9 @@ PendingDBusTubeAccept::~PendingDBusTubeAccept() delete mPriv; } -QDBusConnection PendingDBusTubeAccept::connection() const +QString PendingDBusTubeAccept::address() const { - return mPriv->tube->connection(); + return mPriv->tube->address(); } @@ -209,7 +195,8 @@ IncomingDBusTubeChannelPtr IncomingDBusTubeChannel::create(const ConnectionPtr & IncomingDBusTubeChannel::IncomingDBusTubeChannel(const ConnectionPtr &connection, const QString &objectPath, const QVariantMap &immutableProperties) - : DBusTubeChannel(connection, objectPath, immutableProperties, *new IncomingDBusTubeChannelPrivate(this)) + : DBusTubeChannel(connection, objectPath, immutableProperties), + mPriv(new Private(this)) { } @@ -218,9 +205,9 @@ IncomingDBusTubeChannel::IncomingDBusTubeChannel(const ConnectionPtr &connection */ IncomingDBusTubeChannel::~IncomingDBusTubeChannel() { + delete mPriv; } - /** * \brief Offer a Unix socket over the tube * @@ -264,10 +251,8 @@ PendingDBusTubeAccept* IncomingDBusTubeChannel::acceptTube( QLatin1String("Channel busy"), IncomingDBusTubeChannelPtr(this)); } - Q_D(IncomingDBusTubeChannel); - // Let's offer the tube - if (!d->accessControls.contains(accessControl)) { + if (!accessControls().contains(accessControl)) { warning() << "You requested an access control " "not supported by this channel"; return new PendingDBusTubeAccept(QLatin1String(TP_QT_ERROR_NOT_IMPLEMENTED), @@ -284,20 +269,17 @@ PendingDBusTubeAccept* IncomingDBusTubeChannel::acceptTube( return op; } -QDBusConnection IncomingDBusTubeChannel::connection() const +QString IncomingDBusTubeChannel::address() const { if (state() != TubeChannelStateOpen) { - warning() << "IncomingDBusTubeChannel::connection() can be called only if " + warning() << "IncomingDBusTubeChannel::address() can be called only if " "the tube has already been opened"; - return QDBusConnection(QLatin1String("none")); + return QString(); } - Q_D(const IncomingDBusTubeChannel); - - return d->connection; + return mPriv->address; } - } #include "TelepathyQt/_gen/incoming-dbus-tube-channel.moc.hpp" diff --git a/TelepathyQt/incoming-dbus-tube-channel.h b/TelepathyQt/incoming-dbus-tube-channel.h index ea6ea7fa..0920ae2e 100644 --- a/TelepathyQt/incoming-dbus-tube-channel.h +++ b/TelepathyQt/incoming-dbus-tube-channel.h @@ -41,7 +41,7 @@ class TP_QT_EXPORT PendingDBusTubeAccept : public PendingOperation public: virtual ~PendingDBusTubeAccept(); - QDBusConnection connection() const; + QString address() const; private: PendingDBusTubeAccept(PendingString *string, const IncomingDBusTubeChannelPtr &object); @@ -64,9 +64,6 @@ class TP_QT_EXPORT IncomingDBusTubeChannel : public DBusTubeChannel { Q_OBJECT Q_DISABLE_COPY(IncomingDBusTubeChannel) - Q_DECLARE_PRIVATE(IncomingDBusTubeChannel) - - friend class PendingDBusTubeAcceptPrivate; public: static IncomingDBusTubeChannelPtr create(const ConnectionPtr &connection, @@ -76,12 +73,18 @@ public: PendingDBusTubeAccept *acceptTube(bool requireCredentials = false); - QDBusConnection connection() const; + QString address() const; protected: IncomingDBusTubeChannel(const ConnectionPtr &connection, const QString &objectPath, const QVariantMap &immutableProperties); +private: + struct Private; + friend class PendingDBusTubeAcceptPrivate; + friend struct Private; + Private *mPriv; + }; } diff --git a/TelepathyQt/outgoing-dbus-tube-channel.cpp b/TelepathyQt/outgoing-dbus-tube-channel.cpp index 04c5cf8a..df46652b 100644 --- a/TelepathyQt/outgoing-dbus-tube-channel.cpp +++ b/TelepathyQt/outgoing-dbus-tube-channel.cpp @@ -19,7 +19,6 @@ */ #include <TelepathyQt/OutgoingDBusTubeChannel> -#include "TelepathyQt/dbus-tube-channel-internal.h" #include <TelepathyQt/Connection> #include <TelepathyQt/ContactManager> @@ -31,23 +30,23 @@ namespace Tp { -class TP_QT_NO_EXPORT OutgoingDBusTubeChannelPrivate : public DBusTubeChannelPrivate +struct TP_QT_NO_EXPORT OutgoingDBusTubeChannel::Private { - Q_DECLARE_PUBLIC(OutgoingDBusTubeChannel) -public: - OutgoingDBusTubeChannelPrivate(OutgoingDBusTubeChannel* parent); - virtual ~OutgoingDBusTubeChannelPrivate(); + Private(OutgoingDBusTubeChannel* parent); + virtual ~Private(); - QDBusServer *server; + // Public object + OutgoingDBusTubeChannel *parent; + + QString address; }; -OutgoingDBusTubeChannelPrivate::OutgoingDBusTubeChannelPrivate(OutgoingDBusTubeChannel* parent) - : DBusTubeChannelPrivate(parent) - , server(0) +OutgoingDBusTubeChannel::Private::Private(OutgoingDBusTubeChannel* parent) + : parent(parent) { } -OutgoingDBusTubeChannelPrivate::~OutgoingDBusTubeChannelPrivate() +OutgoingDBusTubeChannel::Private::~Private() { } @@ -89,7 +88,7 @@ void PendingDBusTubeOfferPrivate::onOfferFinished(PendingOperation* op) // Now get the address and set it PendingString *ps = qobject_cast< PendingString* >(op); - tube->d_func()->address = ps->result(); + tube->mPriv->address = ps->result(); // It might have been already opened - check if (tube->state() == TubeChannelStateOpen) { @@ -105,18 +104,8 @@ void PendingDBusTubeOfferPrivate::onStateChanged(TubeChannelState state) { debug() << "Tube state changed to " << state; if (state == TubeChannelStateOpen) { - // The tube is ready: let's create the QDBusServer - QDBusServer *server = new QDBusServer(tube->d_func()->address, tube.data()); - if (!server->isConnected()) { - // Something went wrong - warning() << "Could not create a QDBusServer"; - parent->setFinishedWithError(QLatin1String("Connection refused"), - QLatin1String("Could not create a valid QDBusServer from the tube")); - } else { - // Inject the server - tube->d_func()->server = server; - parent->setFinished(); - } + // The tube is ready: let's finish the operation + parent->setFinished(); } else if (state != TubeChannelStateRemotePending) { // Something happened parent->setFinishedWithError(QLatin1String("Connection refused"), @@ -156,9 +145,9 @@ PendingDBusTubeOffer::~PendingDBusTubeOffer() delete mPriv; } -QDBusServer* PendingDBusTubeOffer::server() +QString PendingDBusTubeOffer::address() const { - return mPriv->tube->server(); + return mPriv->tube->address(); } @@ -207,7 +196,8 @@ OutgoingDBusTubeChannelPtr OutgoingDBusTubeChannel::create(const ConnectionPtr & OutgoingDBusTubeChannel::OutgoingDBusTubeChannel(const ConnectionPtr &connection, const QString &objectPath, const QVariantMap &immutableProperties) - : DBusTubeChannel(connection, objectPath, immutableProperties, *new OutgoingDBusTubeChannelPrivate(this)) + : DBusTubeChannel(connection, objectPath, immutableProperties), + mPriv(new Private(this)) { } @@ -263,10 +253,8 @@ PendingDBusTubeOffer* OutgoingDBusTubeChannel::offerTube( QLatin1String("Channel busy"), OutgoingDBusTubeChannelPtr(this)); } - Q_D(OutgoingDBusTubeChannel); - // Let's offer the tube - if (!d->accessControls.contains(accessControl)) { + if (!accessControls().contains(accessControl)) { warning() << "You requested an access control " "not supported by this channel"; return new PendingDBusTubeOffer(QLatin1String(TP_QT_ERROR_NOT_IMPLEMENTED), @@ -284,17 +272,15 @@ PendingDBusTubeOffer* OutgoingDBusTubeChannel::offerTube( return op; } -QDBusServer* OutgoingDBusTubeChannel::server() +QString OutgoingDBusTubeChannel::address() const { if (state() != TubeChannelStateOpen) { - warning() << "OutgoingDBusTubeChannel::server() can be called only if " + warning() << "OutgoingDBusTubeChannel::address() can be called only if " "the tube has already been opened"; - return 0; + return QString(); } - Q_D(OutgoingDBusTubeChannel); - - return d->server; + return mPriv->address; } } diff --git a/TelepathyQt/outgoing-dbus-tube-channel.h b/TelepathyQt/outgoing-dbus-tube-channel.h index adf0f37d..dcb10d2e 100644 --- a/TelepathyQt/outgoing-dbus-tube-channel.h +++ b/TelepathyQt/outgoing-dbus-tube-channel.h @@ -42,7 +42,7 @@ class TP_QT_EXPORT PendingDBusTubeOffer : public PendingOperation public: virtual ~PendingDBusTubeOffer(); - QDBusServer *server(); + QString address() const; private: PendingDBusTubeOffer(PendingString *string, const OutgoingDBusTubeChannelPtr &object); @@ -64,9 +64,6 @@ class TP_QT_EXPORT OutgoingDBusTubeChannel : public Tp::DBusTubeChannel { Q_OBJECT Q_DISABLE_COPY(OutgoingDBusTubeChannel) - Q_DECLARE_PRIVATE(OutgoingDBusTubeChannel) - - friend struct PendingDBusTubeOfferPrivate; public: static OutgoingDBusTubeChannelPtr create(const ConnectionPtr &connection, @@ -76,12 +73,17 @@ public: PendingDBusTubeOffer *offerTube(const QVariantMap ¶meters, bool requireCredentials = false); - QDBusServer *server(); + QString address() const; protected: OutgoingDBusTubeChannel(const ConnectionPtr &connection, const QString &objectPath, const QVariantMap &immutableProperties); +private: + struct Private; + friend struct PendingDBusTubeOfferPrivate; + friend struct Private; + Private *mPriv; }; } |