summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--TelepathyQt/CMakeLists.txt4
-rw-r--r--TelepathyQt/DBusTubeChannel13
-rw-r--r--TelepathyQt/account.cpp149
-rw-r--r--TelepathyQt/account.h22
-rw-r--r--TelepathyQt/dbus-tube-channel-internal.h62
-rw-r--r--TelepathyQt/dbus-tube-channel.cpp366
-rw-r--r--TelepathyQt/dbus-tube-channel.h85
-rw-r--r--TelepathyQt/types.h2
8 files changed, 703 insertions, 0 deletions
diff --git a/TelepathyQt/CMakeLists.txt b/TelepathyQt/CMakeLists.txt
index 3107e228..71a1bc99 100644
--- a/TelepathyQt/CMakeLists.txt
+++ b/TelepathyQt/CMakeLists.txt
@@ -55,6 +55,7 @@ set(telepathy_qt_SRCS
dbus-proxy.cpp
dbus-proxy-factory.cpp
dbus-proxy-factory-internal.h
+ dbus-tube-channel.cpp
debug.cpp
debug-receiver.cpp
debug-internal.h
@@ -315,6 +316,8 @@ set(telepathy_qt_HEADERS
dbus-proxy.h
DBusProxyFactory
dbus-proxy-factory.h
+ DBusTubeChannel
+ dbus-tube-channel.h
Debug
debug.h
DebugReceiver
@@ -545,6 +548,7 @@ set(telepathy_qt_MOC_SRCS
dbus-proxy-factory.h
dbus-proxy-factory-internal.h
debug-receiver.h
+ dbus-tube-channel.h
fake-handler-manager-internal.h
file-transfer-channel.h
fixed-feature-factory.h
diff --git a/TelepathyQt/DBusTubeChannel b/TelepathyQt/DBusTubeChannel
new file mode 100644
index 00000000..de7eac86
--- /dev/null
+++ b/TelepathyQt/DBusTubeChannel
@@ -0,0 +1,13 @@
+#ifndef _TelepathyQt_DBusTubeChannel_HEADER_GUARD_
+#define _TelepathyQt_DBusTubeChannel_HEADER_GUARD_
+
+#ifndef IN_TP_QT_HEADER
+#define IN_TP_QT_HEADER
+#endif
+
+#include <TelepathyQt/dbus-tube-channel.h>
+
+#undef IN_TELEPATHY_QT4_HEADER
+
+#endif
+// vim:set ft=cpp:
diff --git a/TelepathyQt/account.cpp b/TelepathyQt/account.cpp
index 1bcd40a9..3e921101 100644
--- a/TelepathyQt/account.cpp
+++ b/TelepathyQt/account.cpp
@@ -390,6 +390,34 @@ QVariantMap streamTubeRequest(const Tp::ContactPtr &contact, const QString &serv
return request;
}
+QVariantMap dBusTubeCommonRequest(const QString &serviceName)
+{
+ QVariantMap request;
+ request.insert(TP_QT_IFACE_CHANNEL + QLatin1String(".ChannelType"),
+ TP_QT_IFACE_CHANNEL_TYPE_DBUS_TUBE);
+ request.insert(TP_QT_IFACE_CHANNEL + QLatin1String(".TargetHandleType"),
+ (uint) Tp::HandleTypeContact);
+ request.insert(TP_QT_IFACE_CHANNEL_TYPE_DBUS_TUBE + QLatin1String(".ServiceName"),
+ serviceName);
+ return request;
+}
+
+QVariantMap dBusTubeRequest(const QString &contactIdentifier, const QString &serviceName)
+{
+ QVariantMap request = dBusTubeCommonRequest(serviceName);
+ request.insert(TP_QT_IFACE_CHANNEL + QLatin1String(".TargetID"),
+ contactIdentifier);
+ return request;
+}
+
+QVariantMap dBusTubeRequest(const Tp::ContactPtr &contact, const QString &serviceName)
+{
+ QVariantMap request = dBusTubeCommonRequest(serviceName);
+ request.insert(TP_QT_IFACE_CHANNEL + QLatin1String(".TargetHandle"),
+ contact ? contact->handle().at(0) : (uint) 0);
+ return request;
+}
+
QVariantMap conferenceCommonRequest(const QString &channelType, Tp::HandleType targetHandleType,
const QList<Tp::ChannelPtr> &channels)
{
@@ -2796,6 +2824,75 @@ PendingChannelRequest *Account::createStreamTube(
}
/**
+ * Start a request to create a DBus tube channel with the given
+ * contact \a contactIdentifier.
+ *
+ * \param contactIdentifier The contact identifier of the contact to open a DBus tube with.
+ * \param serviceName the service name that will be used over the
+ * tube. It should be a well-known D-Bus service name, of the form
+ * \c com.example.ServiceName
+ * \param userActionTime The time at which user action occurred, or QDateTime()
+ * if this channel request is for some reason not
+ * involving user action.
+ * \param preferredHandler Either the well-known bus name (starting with
+ * org.freedesktop.Telepathy.Client.) of the preferred
+ * handler for this channel, or an empty string to
+ * indicate that any handler would be acceptable.
+ * \param hints Arbitrary metadata which will be relayed to the handler if supported,
+ * as indicated by supportsRequestHints().
+ * \return A PendingChannelRequest which will emit PendingChannelRequest::finished
+ * when the call has finished.
+ * \sa ensureChannel(), createChannel()
+ */
+PendingChannelRequest* Account::createDBusTube(
+ const QString& contactIdentifier,
+ const QString& serviceName,
+ const QDateTime& userActionTime,
+ const QString& preferredHandler,
+ const ChannelRequestHints &hints)
+{
+ QVariantMap request = dBusTubeRequest(contactIdentifier, serviceName);
+
+ return new PendingChannelRequest(AccountPtr(this), request, userActionTime,
+ preferredHandler, true, hints);
+}
+
+
+/**
+ * Start a request to create a DBus tube channel with the given
+ * contact \a contact.
+ *
+ * \param contact The contact to open a DBus tube with.
+ * \param serviceName the service name that will be used over the
+ * tube. It should be a well-known D-Bus service name, of the form
+ * \c com.example.ServiceName
+ * \param userActionTime The time at which user action occurred, or QDateTime()
+ * if this channel request is for some reason not
+ * involving user action.
+ * \param preferredHandler Either the well-known bus name (starting with
+ * org.freedesktop.Telepathy.Client.) of the preferred
+ * handler for this channel, or an empty string to
+ * indicate that any handler would be acceptable.
+ * \param hints Arbitrary metadata which will be relayed to the handler if supported,
+ * as indicated by supportsRequestHints().
+ * \return A PendingChannelRequest which will emit PendingChannelRequest::finished
+ * when the call has finished.
+ * \sa ensureChannel(), createChannel()
+ */
+PendingChannelRequest* Account::createDBusTube(
+ const Tp::ContactPtr& contact,
+ const QString& serviceName,
+ const QDateTime& userActionTime,
+ const QString& preferredHandler,
+ const ChannelRequestHints &hints)
+{
+ QVariantMap request = dBusTubeRequest(contact, serviceName);
+
+ return new PendingChannelRequest(AccountPtr(this), request, userActionTime,
+ preferredHandler, true, hints);
+}
+
+/**
* Start a request to create a conference media call with the given
* channels \a channels.
*
@@ -3561,6 +3658,58 @@ PendingChannel *Account::createAndHandleStreamTube(
}
/**
+ * Start a request to create a DBus tube channel with the given
+ * contact identifier \a contactIdentifier.
+ * This initially just creates a PendingChannel object,
+ * which can be used to track the success or failure of the request.
+ *
+ * \param contactIdentifier The identifier of the contact to open a DBus tube with.
+ * \param serviceName The DBus tube service name.
+ * \param userActionTime The time at which user action occurred, or QDateTime()
+ * if this channel request is for some reason not
+ * involving user action.
+ * \return A PendingChannel which will emit PendingChannel::finished
+ * successfully, when the Channel is available for handling using
+ * PendingChannel::channel(), or with an error if one has been encountered.
+ * \sa ensureAndHandleChannel(), createAndHandleChannel()
+ */
+PendingChannel *Account::createAndHandleDBusTube(
+ const QString &contactIdentifier,
+ const QString &serviceName,
+ const QDateTime &userActionTime)
+{
+ QVariantMap request = dBusTubeRequest(contactIdentifier, serviceName);
+
+ return createAndHandleChannel(request, userActionTime);
+}
+
+/**
+ * Start a request to create a DBus tube channel with the given
+ * contact \a contact.
+ * This initially just creates a PendingChannel object,
+ * which can be used to track the success or failure of the request.
+ *
+ * \param contact The contact to open a DBus tube with.
+ * \param service The DBus tube service name.
+ * \param userActionTime The time at which user action occurred, or QDateTime()
+ * if this channel request is for some reason not
+ * involving user action.
+ * \return A PendingChannel which will emit PendingChannel::finished
+ * successfully, when the Channel is available for handling using
+ * PendingChannel::channel(), or with an error if one has been encountered.
+ * \sa ensureAndHandleChannel(), createAndHandleChannel()
+ */
+PendingChannel *Account::createAndHandleDBusTube(
+ const ContactPtr &contact,
+ const QString &serviceName,
+ const QDateTime &userActionTime)
+{
+ QVariantMap request = dBusTubeRequest(contact, serviceName);
+
+ return createAndHandleChannel(request, userActionTime);
+}
+
+/**
* Start a request to create a conference text chat with the given
* channels \a channels.
* This initially just creates a PendingChannel object,
diff --git a/TelepathyQt/account.h b/TelepathyQt/account.h
index 17ae730d..c01c4a03 100644
--- a/TelepathyQt/account.h
+++ b/TelepathyQt/account.h
@@ -318,6 +318,19 @@ public:
const QString &preferredHandler = QString(),
const ChannelRequestHints &hints = ChannelRequestHints());
+ PendingChannelRequest *createDBusTube(
+ const QString &contactIdentifier,
+ const QString &serviceName,
+ const QDateTime &userActionTime = QDateTime::currentDateTime(),
+ const QString &preferredHandler = QString(),
+ const ChannelRequestHints &hints = ChannelRequestHints());
+ PendingChannelRequest *createDBusTube(
+ const ContactPtr &contact,
+ const QString &serviceName,
+ const QDateTime &userActionTime = QDateTime::currentDateTime(),
+ const QString &preferredHandler = QString(),
+ const ChannelRequestHints &hints = ChannelRequestHints());
+
PendingChannelRequest *createConferenceStreamedMediaCall(
const QList<ChannelPtr> &channels,
const QStringList &initialInviteeContactsIdentifiers = QStringList(),
@@ -445,6 +458,15 @@ public:
const QString &service,
const QDateTime &userActionTime = QDateTime::currentDateTime());
+ PendingChannel *createAndHandleDBusTube(
+ const QString &contactIdentifier,
+ const QString &serviceName,
+ const QDateTime &userActionTime = QDateTime::currentDateTime());
+ PendingChannel *createAndHandleDBusTube(
+ const ContactPtr &contact,
+ const QString &serviceName,
+ const QDateTime &userActionTime = QDateTime::currentDateTime());
+
PendingChannel *createAndHandleConferenceTextChat(
const QList<ChannelPtr> &channels,
const QList<ContactPtr> &initialInviteeContacts = QList<ContactPtr>(),
diff --git a/TelepathyQt/dbus-tube-channel-internal.h b/TelepathyQt/dbus-tube-channel-internal.h
new file mode 100644
index 00000000..57b8fc8d
--- /dev/null
+++ b/TelepathyQt/dbus-tube-channel-internal.h
@@ -0,0 +1,62 @@
+/*
+ * 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 __k__gotDBusTubeProperties(QDBusPendingCallWatcher *watcher);
+ void __k__onDBusNamesChanged(const Tp::DBusTubeParticipants &added, const Tp::UIntList &removed);
+
+};
+
+}
+
+#endif
diff --git a/TelepathyQt/dbus-tube-channel.cpp b/TelepathyQt/dbus-tube-channel.cpp
new file mode 100644
index 00000000..d9828448
--- /dev/null
+++ b/TelepathyQt/dbus-tube-channel.cpp
@@ -0,0 +1,366 @@
+/*
+ * 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
+ */
+
+#include "TelepathyQt/dbus-tube-channel-internal.h"
+
+#include <TelepathyQt/Connection>
+#include <TelepathyQt/ContactManager>
+
+#include "TelepathyQt/debug-internal.h"
+
+namespace Tp
+{
+
+DBusTubeChannelPrivate::DBusTubeChannelPrivate(DBusTubeChannel *parent)
+ : q_ptr(parent)
+{
+}
+
+DBusTubeChannelPrivate::~DBusTubeChannelPrivate()
+{
+}
+
+void DBusTubeChannelPrivate::init()
+{
+ Q_Q(DBusTubeChannel);
+ // Initialize readinessHelper + introspectables here
+ readinessHelper = q->readinessHelper();
+
+ ReadinessHelper::Introspectables introspectables;
+
+ ReadinessHelper::Introspectable introspectableDBusTube(
+ QSet<uint>() << 0, // makesSenseForStatuses
+ Features() << TubeChannel::FeatureCore, // dependsOnFeatures (core)
+ QStringList(), // dependsOnInterfaces
+ (ReadinessHelper::IntrospectFunc) &DBusTubeChannelPrivate::introspectDBusTube,
+ this);
+ introspectables[DBusTubeChannel::FeatureDBusTube] = introspectableDBusTube;
+
+ ReadinessHelper::Introspectable introspectableBusNamesMonitoring(
+ QSet<uint>() << 0, // makesSenseForStatuses
+ Features() << DBusTubeChannel::FeatureDBusTube, // dependsOnFeatures (core)
+ QStringList(), // dependsOnInterfaces
+ (ReadinessHelper::IntrospectFunc) &DBusTubeChannelPrivate::introspectBusNamesMonitoring,
+ this);
+ introspectables[DBusTubeChannel::FeatureBusNamesMonitoring] = introspectableBusNamesMonitoring;
+
+ readinessHelper->addIntrospectables(introspectables);
+}
+
+void DBusTubeChannelPrivate::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)
+{
+ Q_Q(DBusTubeChannel);
+
+ busNames.clear();
+ for (DBusTubeParticipants::const_iterator i = participants.constBegin();
+ i != participants.constEnd();
+ ++i) {
+ busNames.insert(q->connection()->contactManager()->lookupContactByHandle(i.key()),
+ i.value());
+ }
+}
+
+
+void DBusTubeChannelPrivate::__k__gotDBusTubeProperties(QDBusPendingCallWatcher* watcher)
+{
+ QDBusPendingReply<QVariantMap> reply = *watcher;
+
+ if (!reply.isError()) {
+ QVariantMap props = reply.value();
+ extractProperties(props);
+ debug() << "Got reply to Properties::GetAll(DBusTubeChannel)";
+ readinessHelper->setIntrospectCompleted(DBusTubeChannel::FeatureDBusTube, true);
+ } else {
+ warning().nospace() << "Properties::GetAll(DBusTubeChannel) failed "
+ "with " << reply.error().name() << ": " << reply.error().message();
+ readinessHelper->setIntrospectCompleted(DBusTubeChannel::FeatureDBusTube, false,
+ reply.error());
+ }
+}
+
+void DBusTubeChannelPrivate::__k__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());
+ realAdded.insert(contact, i.value());
+ // Add it to our hash as well
+ busNames.insert(contact, i.value());
+ }
+
+ foreach (uint handle, removed) {
+ ContactPtr contact = q->connection()->contactManager()->lookupContactByHandle(handle);
+ realRemoved << contact;
+ // Remove it from our hash as well
+ busNames.remove(contact);
+ }
+
+ // Emit the "real" signal
+ emit q->busNamesChanged(realAdded, realRemoved);
+}
+
+void DBusTubeChannelPrivate::introspectBusNamesMonitoring(
+ DBusTubeChannelPrivate* self)
+{
+ DBusTubeChannel *parent = self->q_func();
+
+ Client::ChannelTypeDBusTubeInterface *dbusTubeInterface =
+ parent->interface<Client::ChannelTypeDBusTubeInterface>();
+
+ // It must be present
+ Q_ASSERT(dbusTubeInterface);
+
+ // It makes sense only if this is a room, if that's not the case just spit a warning
+ if (parent->targetHandleType() == static_cast<uint>(Tp::HandleTypeRoom)) {
+ parent->connect(dbusTubeInterface, SIGNAL(DBusNamesChanged(Tp::DBusTubeParticipants,Tp::UIntList)),
+ parent, SLOT(__k__onDBusNamesChanged(Tp::DBusTubeParticipants,Tp::UIntList)));
+ } else {
+ warning() << "FeatureBusNamesMonitoring does not make sense in a P2P context";
+ }
+
+ self->readinessHelper->setIntrospectCompleted(DBusTubeChannel::FeatureBusNamesMonitoring, true);
+}
+
+void DBusTubeChannelPrivate::introspectDBusTube(
+ DBusTubeChannelPrivate* self)
+{
+ DBusTubeChannel *parent = self->q_func();
+
+ debug() << "Introspect dbus tube properties";
+
+ Client::DBus::PropertiesInterface *properties =
+ parent->interface<Client::DBus::PropertiesInterface>();
+
+ QDBusPendingCallWatcher *watcher =
+ new QDBusPendingCallWatcher(
+ properties->GetAll(
+ QLatin1String(TP_QT_IFACE_CHANNEL_TYPE_DBUS_TUBE)),
+ parent);
+ parent->connect(watcher,
+ SIGNAL(finished(QDBusPendingCallWatcher *)),
+ parent,
+ SLOT(__k__gotDBusTubeProperties(QDBusPendingCallWatcher *)));
+}
+
+/**
+ * \class DBusTubeChannel
+ * \headerfile TelepathyQt/stream-tube-channel.h <TelepathyQt/DBusTubeChannel>
+ *
+ * \brief A class representing a Stream Tube
+ *
+ * \c DBusTubeChannel is an high level wrapper for managing Telepathy interface
+ * org.freedesktop.Telepathy.Channel.Type.DBusTubeChannel.
+ * It provides a transport for reliable and ordered data transfer, similar to SOCK_STREAM sockets.
+ *
+ * For more details, please refer to Telepathy spec.
+ */
+
+// Features declaration and documentation
+/**
+ * Feature representing the core that needs to become ready to make the
+ * DBusTubeChannel object usable.
+ *
+ * Note that this feature must be enabled in order to use most
+ * DBusTubeChannel methods.
+ * See specific methods documentation for more details.
+ */
+const Feature DBusTubeChannel::FeatureDBusTube =
+Feature(QLatin1String(DBusTubeChannel::staticMetaObject.className()), 0);
+/**
+ * Feature used in order to monitor connections to this tube.
+ * Please note that this feature makes sense only in Group tubes.
+ *
+ * %busNamesChanged will be emitted when the participants of this tube change
+ */
+const Feature DBusTubeChannel::FeatureBusNamesMonitoring =
+Feature(QLatin1String(DBusTubeChannel::staticMetaObject.className()), 1);
+
+// Signals documentation
+/**
+ * \fn void DBusTubeChannel::busNamesChanged(const QHash< ContactPtr, QString > &added, const QList< ContactPtr >
+&removed)
+ *
+ * Emitted when the participants of this tube change
+ *
+ * \param added An hash containing the contacts who joined this tube, with their respective bus name.
+ * \param removed A list containing the contacts who left this tube.
+ */
+
+/**
+ * Create a new DBusTubeChannel channel.
+ *
+ * \param connection Connection owning this channel, and specifying the
+ * service.
+ * \param objectPath The object path of this channel.
+ * \param immutableProperties The immutable properties of this channel.
+ * \return A DBusTubeChannelPtr object pointing to the newly created
+ * DBusTubeChannel object.
+ */
+DBusTubeChannelPtr DBusTubeChannel::create(const ConnectionPtr &connection,
+ const QString &objectPath, const QVariantMap &immutableProperties)
+{
+ return DBusTubeChannelPtr(new DBusTubeChannel(connection, objectPath,
+ immutableProperties));
+}
+
+/**
+ * Construct a new DBusTubeChannel object.
+ *
+ * \param connection Connection owning this channel, and specifying the
+ * service.
+ * \param objectPath The object path of this channel.
+ * \param immutableProperties The immutable properties of this channel.
+ */
+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)
+{
+ // Initialize
+ Q_D(DBusTubeChannel);
+ d->init();
+}
+
+
+/**
+ * Class destructor.
+ */
+DBusTubeChannel::~DBusTubeChannel()
+{
+ delete d_ptr;
+}
+
+/**
+ * \returns the service name that will be used over the tube
+ */
+QString DBusTubeChannel::serviceName() const
+{
+ if (!isReady(FeatureDBusTube)) {
+ warning() << "DBusTubeChannel::service() used with "
+ "FeatureDBusTube not ready";
+ return QString();
+ }
+
+ Q_D(const DBusTubeChannel);
+
+ return d->serviceName;
+}
+
+
+/**
+ * \returns Whether this Stream tube supports offering or accepting it as an Unix socket and requiring
+ * credentials for connecting to it.
+ *
+ * \see IncomingDBusTubeChannel::acceptTubeAsUnixSocket
+ * \see OutgoingDBusTubeChannel::offerTubeAsUnixSocket
+ * \see supportsUnixSockets
+ */
+bool DBusTubeChannel::supportsCredentials() const
+{
+ if (!isReady(FeatureDBusTube)) {
+ warning() << "DBusTubeChannel::supportsCredentials() used with "
+ "FeatureDBusTube not ready";
+ return false;
+ }
+
+ Q_D(const DBusTubeChannel);
+
+ return d->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
+ * OutgoingDBusTubeChannel have more convenient methods for accessing the resulting connection.
+ *
+ * \returns The address of the private bus opened by this tube
+ */
+QString DBusTubeChannel::address() const
+{
+ if (state() != TubeChannelStateOpen) {
+ warning() << "DBusTubeChannel::address() can be called only if "
+ "the tube has already been opened";
+ return QString();
+ }
+
+ Q_D(const DBusTubeChannel);
+
+ return d->address;
+}
+
+
+/**
+ * This function returns all the known active connections since FeatureConnectionMonitoring has
+ * been enabled. For this method to return all known connections, you need to make
+ * FeatureConnectionMonitoring ready before accepting or offering the tube.
+ *
+ * \returns A list of active connection ids known to this tube
+ */
+QHash< ContactPtr, QString > DBusTubeChannel::busNames() const
+{
+ if (!isReady(FeatureBusNamesMonitoring)) {
+ warning() << "DBusTubeChannel::busNames() used with "
+ "FeatureBusNamesMonitoring not ready";
+ return QHash< ContactPtr, QString >();
+ }
+
+ Q_D(const DBusTubeChannel);
+
+ return d->busNames;
+}
+
+}
+
+#include "TelepathyQt/_gen/dbus-tube-channel.moc.hpp"
diff --git a/TelepathyQt/dbus-tube-channel.h b/TelepathyQt/dbus-tube-channel.h
new file mode 100644
index 00000000..e98f0285
--- /dev/null
+++ b/TelepathyQt/dbus-tube-channel.h
@@ -0,0 +1,85 @@
+/*
+ * 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_h_HEADER_GUARD_
+#define _TelepathyQt_dbus_tube_channel_h_HEADER_GUARD_
+
+#ifndef IN_TP_QT_HEADER
+#error IN_TP_QT_HEADER
+#endif
+
+#include <TelepathyQt/TubeChannel>
+
+
+namespace Tp
+{
+
+class DBusTubeChannelPrivate;
+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 __k__gotDBusTubeProperties(QDBusPendingCallWatcher*))
+ Q_PRIVATE_SLOT(d_func(), void __k__onDBusNamesChanged(Tp::DBusTubeParticipants,Tp::UIntList))
+
+public:
+ static const Feature FeatureDBusTube;
+ static const Feature FeatureBusNamesMonitoring;
+
+ static DBusTubeChannelPtr create(const ConnectionPtr &connection,
+ const QString &objectPath, const QVariantMap &immutableProperties);
+
+ virtual ~DBusTubeChannel();
+
+ QString serviceName() const;
+
+ bool supportsCredentials() const;
+
+ QHash< Tp::ContactPtr, QString > busNames() const;
+
+ QString address() 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:
+ struct Private;
+ friend struct Private;
+ Private *mPriv;
+
+};
+
+} // Tp
+
+#endif
diff --git a/TelepathyQt/types.h b/TelepathyQt/types.h
index 4d9b3459..eb74a6f6 100644
--- a/TelepathyQt/types.h
+++ b/TelepathyQt/types.h
@@ -77,6 +77,7 @@ class ContactMessenger;
class ContactSearchChannel;
class DBusProxy;
class DebugReceiver;
+class DBusTubeChannel;
class FileTransferChannel;
class IncomingFileTransferChannel;
class IncomingStreamTubeChannel;
@@ -141,6 +142,7 @@ typedef SharedPtr<ContactManager> ContactManagerPtr;
typedef SharedPtr<ContactMessenger> ContactMessengerPtr;
typedef SharedPtr<ContactSearchChannel> ContactSearchChannelPtr;
typedef SharedPtr<DBusProxy> DBusProxyPtr;
+typedef SharedPtr<DBusTubeChannel> DBusTubeChannelPtr;
typedef SharedPtr<DebugReceiver> DebugReceiverPtr;
typedef SharedPtr<FileTransferChannel> FileTransferChannelPtr;
typedef SharedPtr<IncomingFileTransferChannel> IncomingFileTransferChannelPtr;