diff options
author | Matthias Gehre <M.Gehre@gmx.de> | 2013-03-25 15:30:32 -0500 |
---|---|---|
committer | David Edmundson <davidedmundson@kde.org> | 2014-06-14 13:51:53 +0200 |
commit | a4b4c922aeb12af563440d913c48d0e0e6a044f9 (patch) | |
tree | ee40a56bddf8fb3d633268509277e3c8b9e77018 | |
parent | 90fbae19f732d25ecfd83c442a1c65a17d01d0e6 (diff) |
Implement BaseConnection and AbstractConnectionInterface
-rw-r--r-- | TelepathyQt/base-connection-internal.h | 50 | ||||
-rw-r--r-- | TelepathyQt/base-connection.cpp | 414 | ||||
-rw-r--r-- | TelepathyQt/base-connection.h | 80 | ||||
-rw-r--r-- | TelepathyQt/service-types.h | 2 |
4 files changed, 515 insertions, 31 deletions
diff --git a/TelepathyQt/base-connection-internal.h b/TelepathyQt/base-connection-internal.h index 39539df1..c0975189 100644 --- a/TelepathyQt/base-connection-internal.h +++ b/TelepathyQt/base-connection-internal.h @@ -25,6 +25,7 @@ #include <TelepathyQt/Global> #include <TelepathyQt/MethodInvocationContext> #include <TelepathyQt/Types> +#include "TelepathyQt/debug-internal.h" namespace Tp { @@ -33,13 +34,62 @@ class TP_QT_NO_EXPORT BaseConnection::Adaptee : public QObject { Q_OBJECT + Q_PROPERTY(QStringList interfaces READ interfaces) + Q_PROPERTY(uint selfHandle READ selfHandle) + Q_PROPERTY(uint status READ status) + Q_PROPERTY(bool hasImmortalHandles READ hasImmortalHandles) public: Adaptee(const QDBusConnection &dbusConnection, BaseConnection *cm); ~Adaptee(); + QStringList interfaces() const; + uint status() const { + return mConnection->status(); + } + uint selfHandle() const; + bool hasImmortalHandles() const { + return true; + } + +private Q_SLOTS: + void getSelfHandle(const Tp::Service::ConnectionAdaptor::GetSelfHandleContextPtr &context); + void getStatus(const Tp::Service::ConnectionAdaptor::GetStatusContextPtr &context); + void connect(const Tp::Service::ConnectionAdaptor::ConnectContextPtr &context); + void getInterfaces(const Tp::Service::ConnectionAdaptor::GetInterfacesContextPtr &context) { + context->setFinished(interfaces()); + } + + void getProtocol(const Tp::Service::ConnectionAdaptor::GetProtocolContextPtr &context) { + context->setFinished(QLatin1String("whosthere")); + } + + void holdHandles(uint handleType, const Tp::UIntList &handles, const Tp::Service::ConnectionAdaptor::HoldHandlesContextPtr &context) { + context->setFinished(); + } + + void inspectHandles(uint handleType, const Tp::UIntList &handles, const Tp::Service::ConnectionAdaptor::InspectHandlesContextPtr &context); + + void listChannels(const Tp::Service::ConnectionAdaptor::ListChannelsContextPtr &context) { + context->setFinished(mConnection->channelsInfo()); + } + + void disconnect(const Tp::Service::ConnectionAdaptor::DisconnectContextPtr &context); + + //void releaseHandles(uint handleType, const Tp::UIntList &handles, const Tp::Service::ConnectionAdaptor::ReleaseHandlesContextPtr &context); + void requestChannel(const QString &type, uint handleType, uint handle, bool suppressHandler, const Tp::Service::ConnectionAdaptor::RequestChannelContextPtr &context); + void requestHandles(uint handleType, const QStringList &identifiers, const Tp::Service::ConnectionAdaptor::RequestHandlesContextPtr &context); + //void addClientInterest(const QStringList &tokens, const Tp::Service::ConnectionAdaptor::AddClientInterestContextPtr &context); + //void removeClientInterest(const QStringList &tokens, const Tp::Service::ConnectionAdaptor::RemoveClientInterestContextPtr &context); + public: BaseConnection *mConnection; Service::ConnectionAdaptor *mAdaptor; + +Q_SIGNALS: + void selfHandleChanged(uint selfHandle); + void newChannel(const QDBusObjectPath &objectPath, const QString &channelType, uint handleType, uint handle, bool suppressHandler); + void connectionError(const QString &error, const QVariantMap &details); + void statusChanged(uint status, uint reason); }; } diff --git a/TelepathyQt/base-connection.cpp b/TelepathyQt/base-connection.cpp index 3897f079..b5cbd52f 100644 --- a/TelepathyQt/base-connection.cpp +++ b/TelepathyQt/base-connection.cpp @@ -28,18 +28,19 @@ #include "TelepathyQt/debug-internal.h" +#include <TelepathyQt/BaseChannel> +#include <TelepathyQt/ChannelInterface> #include <TelepathyQt/Constants> #include <TelepathyQt/DBusObject> #include <TelepathyQt/Utils> - +#include <TelepathyQt/AbstractProtocolInterface> #include <QString> #include <QVariantMap> namespace Tp { -struct TP_QT_NO_EXPORT BaseConnection::Private -{ +struct TP_QT_NO_EXPORT BaseConnection::Private { Private(BaseConnection *parent, const QDBusConnection &dbusConnection, const QString &cmName, const QString &protocolName, const QVariantMap ¶meters) @@ -47,20 +48,28 @@ struct TP_QT_NO_EXPORT BaseConnection::Private cmName(cmName), protocolName(protocolName), parameters(parameters), - adaptee(new BaseConnection::Adaptee(dbusConnection, parent)) - { + status(Tp::ConnectionStatusDisconnected), + selfHandle(0), + adaptee(new BaseConnection::Adaptee(dbusConnection, parent)) { } BaseConnection *parent; QString cmName; QString protocolName; QVariantMap parameters; - + uint status; + QHash<QString, AbstractConnectionInterfacePtr> interfaces; + QSet<BaseChannelPtr> channels; + CreateChannelCallback createChannelCB; + RequestHandlesCallback requestHandlesCB; + ConnectCallback connectCB; + InspectHandlesCallback inspectHandlesCB; + uint selfHandle; BaseConnection::Adaptee *adaptee; }; BaseConnection::Adaptee::Adaptee(const QDBusConnection &dbusConnection, - BaseConnection *connection) + BaseConnection *connection) : QObject(connection), mConnection(connection) { @@ -71,6 +80,102 @@ BaseConnection::Adaptee::~Adaptee() { } +void BaseConnection::Adaptee::disconnect(const Tp::Service::ConnectionAdaptor::DisconnectContextPtr &context) +{ + debug() << "BaseConnection::Adaptee::disconnect"; + /* This will remove the connection from the connection manager + * and destroy this object. */ + emit mConnection->disconnected(); + context->setFinished(); +} + +void BaseConnection::Adaptee::getSelfHandle(const Tp::Service::ConnectionAdaptor::GetSelfHandleContextPtr &context) +{ + context->setFinished(mConnection->mPriv->selfHandle); +} + +uint BaseConnection::Adaptee::selfHandle() const +{ + return mConnection->mPriv->selfHandle; +} + +void BaseConnection::Adaptee::getStatus(const Tp::Service::ConnectionAdaptor::GetStatusContextPtr &context) +{ + context->setFinished(mConnection->status()); +} + +void BaseConnection::Adaptee::connect(const Tp::Service::ConnectionAdaptor::ConnectContextPtr &context) +{ + if (!mConnection->mPriv->connectCB.isValid()) { + context->setFinishedWithError(TP_QT_ERROR_NOT_IMPLEMENTED, QLatin1String("Not implemented")); + return; + } + DBusError error; + mConnection->mPriv->connectCB(&error); + if (error.isValid()) { + context->setFinishedWithError(error.name(), error.message()); + return; + } + context->setFinished(); +} + +void BaseConnection::Adaptee::inspectHandles(uint handleType, + const Tp::UIntList &handles, + const Tp::Service::ConnectionAdaptor::InspectHandlesContextPtr &context) +{ + if (!mConnection->mPriv->inspectHandlesCB.isValid()) { + context->setFinishedWithError(TP_QT_ERROR_NOT_IMPLEMENTED, QLatin1String("Not implemented")); + return; + } + DBusError error; + QStringList ret = mConnection->mPriv->inspectHandlesCB(handleType, handles, &error); + if (error.isValid()) { + context->setFinishedWithError(error.name(), error.message()); + return; + } + context->setFinished(ret); +} +QStringList BaseConnection::Adaptee::interfaces() const +{ + QStringList ret; + foreach(const AbstractConnectionInterfacePtr & iface, mConnection->interfaces()) { + ret << iface->interfaceName(); + } + return ret; +} + +void BaseConnection::Adaptee::requestChannel(const QString &type, uint handleType, uint handle, bool suppressHandler, + const Tp::Service::ConnectionAdaptor::RequestChannelContextPtr &context) +{ + debug() << "BaseConnection::Adaptee::requestChannel (deprecated)"; + DBusError error; + bool yours; + BaseChannelPtr channel = mConnection->ensureChannel(type, + handleType, + handle, + yours, + selfHandle(), + suppressHandler, + &error); + if (error.isValid() || !channel) { + context->setFinishedWithError(error.name(), error.message()); + return; + } + context->setFinished(QDBusObjectPath(channel->objectPath())); +} + +void BaseConnection::Adaptee::requestHandles(uint handleType, const QStringList &identifiers, + const Tp::Service::ConnectionAdaptor::RequestHandlesContextPtr &context) +{ + DBusError error; + Tp::UIntList handles = mConnection->requestHandles(handleType, identifiers, &error); + if (error.isValid()) { + context->setFinishedWithError(error.name(), error.message()); + return; + } + context->setFinished(handles); +} + /** * \class BaseConnection * \ingroup serviceconn @@ -88,8 +193,8 @@ BaseConnection::Adaptee::~Adaptee() * \param parameters The parameters of this connection. */ BaseConnection::BaseConnection(const QDBusConnection &dbusConnection, - const QString &cmName, const QString &protocolName, - const QVariantMap ¶meters) + const QString &cmName, const QString &protocolName, + const QVariantMap ¶meters) : DBusService(dbusConnection), mPriv(new Private(this, dbusConnection, cmName, protocolName, parameters)) { @@ -157,6 +262,235 @@ QString BaseConnection::uniqueName() const return QString(QLatin1String("_%1")).arg((quintptr) this, 0, 16); } +uint BaseConnection::status() const +{ + debug() << "BaseConnection::status = " << mPriv->status << " " << this; + return mPriv->status; +} + +void BaseConnection::setStatus(uint newStatus, uint reason) +{ + debug() << "BaseConnection::setStatus " << newStatus << " " << reason << " " << this; + bool changed = (newStatus != mPriv->status); + mPriv->status = newStatus; + if (changed) + emit mPriv->adaptee->statusChanged(newStatus, reason); +} + +void BaseConnection::setCreateChannelCallback(const CreateChannelCallback &cb) +{ + mPriv->createChannelCB = cb; +} + +Tp::BaseChannelPtr BaseConnection::createChannel(const QString &channelType, + uint targetHandleType, + uint targetHandle, + uint initiatorHandle, + bool suppressHandler, + DBusError *error) +{ + if (!mPriv->createChannelCB.isValid()) { + error->set(TP_QT_ERROR_NOT_IMPLEMENTED, QLatin1String("Not implemented")); + return BaseChannelPtr(); + } + if (!mPriv->inspectHandlesCB.isValid()) { + error->set(TP_QT_ERROR_NOT_IMPLEMENTED, QLatin1String("Not implemented")); + return BaseChannelPtr(); + } + + BaseChannelPtr channel = mPriv->createChannelCB(channelType, targetHandleType, targetHandle, error); + if (error->isValid()) + return BaseChannelPtr(); + + QString targetID; + if (targetHandle != 0) { + QStringList list = mPriv->inspectHandlesCB(targetHandleType, UIntList() << targetHandle, error); + if (error->isValid()) { + debug() << "BaseConnection::createChannel: could not resolve handle " << targetHandle; + return BaseChannelPtr(); + } else { + debug() << "BaseConnection::createChannel: found targetID " << *list.begin(); + targetID = *list.begin(); + } + } + QString initiatorID; + if (initiatorHandle != 0) { + QStringList list = mPriv->inspectHandlesCB(HandleTypeContact, UIntList() << initiatorHandle, error); + if (error->isValid()) { + debug() << "BaseConnection::createChannel: could not resolve handle " << initiatorHandle; + return BaseChannelPtr(); + } else { + debug() << "BaseConnection::createChannel: found initiatorID " << *list.begin(); + initiatorID = *list.begin(); + } + } + channel->setInitiatorHandle(initiatorHandle); + channel->setInitiatorID(initiatorID); + channel->setTargetID(targetID); + channel->setRequested(initiatorHandle == mPriv->selfHandle); + + channel->registerObject(error); + if (error->isValid()) + return BaseChannelPtr(); + + mPriv->channels.insert(channel); + + BaseConnectionRequestsInterfacePtr reqIface = + BaseConnectionRequestsInterfacePtr::dynamicCast(interface(TP_QT_IFACE_CONNECTION_INTERFACE_REQUESTS)); + + if (!reqIface.isNull()) + //emit after return + QMetaObject::invokeMethod(reqIface.data(), "newChannels", + Qt::QueuedConnection, + Q_ARG(Tp::ChannelDetailsList, ChannelDetailsList() << channel->details())); + + + //emit after return + QMetaObject::invokeMethod(mPriv->adaptee, "newChannel", + Qt::QueuedConnection, + Q_ARG(QDBusObjectPath, QDBusObjectPath(channel->objectPath())), + Q_ARG(QString, channel->channelType()), + Q_ARG(uint, channel->targetHandleType()), + Q_ARG(uint, channel->targetHandle()), + Q_ARG(bool, suppressHandler)); + + QObject::connect(channel.data(), + SIGNAL(closed()), + SLOT(removeChannel())); + + return channel; +} + +void BaseConnection::setRequestHandlesCallback(const RequestHandlesCallback &cb) +{ + mPriv->requestHandlesCB = cb; +} + +UIntList BaseConnection::requestHandles(uint handleType, const QStringList &identifiers, DBusError* error) +{ + if (!mPriv->requestHandlesCB.isValid()) { + error->set(TP_QT_ERROR_NOT_IMPLEMENTED, QLatin1String("Not implemented")); + return UIntList(); + } + return mPriv->requestHandlesCB(handleType, identifiers, error); +} + +Tp::ChannelInfoList BaseConnection::channelsInfo() +{ + qDebug() << "BaseConnection::channelsInfo:"; + Tp::ChannelInfoList list; + foreach(const BaseChannelPtr & c, mPriv->channels) { + Tp::ChannelInfo info; + info.channel = QDBusObjectPath(c->objectPath()); + info.channelType = c->channelType(); + info.handle = c->targetHandle(); + info.handleType = c->targetHandleType(); + qDebug() << "BaseConnection::channelsInfo " << info.channel.path(); + list << info; + } + return list; +} + +Tp::ChannelDetailsList BaseConnection::channelsDetails() +{ + Tp::ChannelDetailsList list; + foreach(const BaseChannelPtr & c, mPriv->channels) + list << c->details(); + return list; +} + +BaseChannelPtr BaseConnection::ensureChannel(const QString &channelType, uint targetHandleType, + uint targetHandle, bool &yours, uint initiatorHandle, + bool suppressHandler, + DBusError* error) +{ + foreach(BaseChannelPtr channel, mPriv->channels) { + if (channel->channelType() == channelType + && channel->targetHandleType() == targetHandleType + && channel->targetHandle() == targetHandle) { + yours = false; + return channel; + } + } + yours = true; + return createChannel(channelType, targetHandleType, targetHandle, initiatorHandle, suppressHandler, error); +} + +void BaseConnection::removeChannel() +{ + BaseChannelPtr channel = BaseChannelPtr( + qobject_cast<BaseChannel*>(sender())); + Q_ASSERT(channel); + Q_ASSERT(mPriv->channels.contains(channel)); + mPriv->channels.remove(channel); +} + +/** + * Return a list of interfaces that have been plugged into this Protocol + * D-Bus object with plugInterface(). + * + * This property is immutable and cannot change after this Protocol + * object has been registered on the bus with registerObject(). + * + * \return A list containing all the Protocol interface implementation objects. + * \sa plugInterface(), interface() + */ +QList<AbstractConnectionInterfacePtr> BaseConnection::interfaces() const +{ + return mPriv->interfaces.values(); +} + +/** + * Return a pointer to the interface with the given name. + * + * \param interfaceName The D-Bus name of the interface, + * ex. TP_QT_IFACE_CONNECTION_INTERFACE_ADDRESSING. + * \return A pointer to the AbstractConnectionInterface object that implements + * the D-Bus interface with the given name, or a null pointer if such an interface + * has not been plugged into this object. + * \sa plugInterface(), interfaces() + */ +AbstractConnectionInterfacePtr BaseConnection::interface(const QString &interfaceName) const +{ + return mPriv->interfaces.value(interfaceName); +} + +/** + * Plug a new interface into this Connection D-Bus object. + * + * This property is immutable and cannot change after this Protocol + * object has been registered on the bus with registerObject(). + * + * \param interface An AbstractConnectionInterface instance that implements + * the interface that is to be plugged. + * \return \c true on success or \c false otherwise + * \sa interfaces(), interface() + */ +bool BaseConnection::plugInterface(const AbstractConnectionInterfacePtr &interface) +{ + if (isRegistered()) { + warning() << "Unable to plug protocol interface " << interface->interfaceName() << + "- protocol already registered"; + return false; + } + + if (interface->isRegistered()) { + warning() << "Unable to plug protocol interface" << interface->interfaceName() << + "- interface already registered"; + return false; + } + + if (mPriv->interfaces.contains(interface->interfaceName())) { + warning() << "Unable to plug protocol interface" << interface->interfaceName() << + "- another interface with same name already plugged"; + return false; + } + + debug() << "Interface" << interface->interfaceName() << "plugged"; + mPriv->interfaces.insert(interface->interfaceName(), interface); + return true; +} + /** * Register this connection object on the bus. * @@ -175,10 +509,10 @@ bool BaseConnection::registerObject(DBusError *error) return true; } - if (checkValidProtocolName(mPriv->protocolName)) { + if (!checkValidProtocolName(mPriv->protocolName)) { if (error) { error->set(TP_QT_ERROR_INVALID_ARGUMENT, - mPriv->protocolName + QLatin1String("is not a valid protocol name")); + mPriv->protocolName + QLatin1String("is not a valid protocol name")); } debug() << "Unable to register connection - invalid protocol name"; return false; @@ -187,11 +521,22 @@ bool BaseConnection::registerObject(DBusError *error) QString escapedProtocolName = mPriv->protocolName; escapedProtocolName.replace(QLatin1Char('-'), QLatin1Char('_')); QString name = uniqueName(); - QString busName = QString(QLatin1String("%1.%2.%3.%4")) - .arg(TP_QT_CONNECTION_BUS_NAME_BASE, mPriv->cmName, escapedProtocolName, name); - QString objectPath = QString(QLatin1String("%1/%2/%3/%4")) - .arg(TP_QT_CONNECTION_OBJECT_PATH_BASE, mPriv->cmName, escapedProtocolName, name); + debug() << "cmName: " << mPriv->cmName << " escapedProtocolName: " << escapedProtocolName << " name:" << name; + QString busName = QString(QLatin1String("%1%2.%3.%4")) + .arg(TP_QT_CONNECTION_BUS_NAME_BASE, mPriv->cmName, escapedProtocolName, name); + QString objectPath = QString(QLatin1String("%1%2/%3/%4")) + .arg(TP_QT_CONNECTION_OBJECT_PATH_BASE, mPriv->cmName, escapedProtocolName, name); + debug() << "busName: " << busName << " objectName: " << objectPath; DBusError _error; + + debug() << "Connection: registering interfaces at " << dbusObject(); + foreach(const AbstractConnectionInterfacePtr & iface, mPriv->interfaces) { + if (!iface->registerInterface(dbusObject())) { + // lets not fail if an optional interface fails registering, lets warn only + warning() << "Unable to register interface" << iface->interfaceName(); + } + } + bool ret = registerObject(busName, objectPath, &_error); if (!ret && error) { error->set(_error.name(), _error.message()); @@ -203,15 +548,52 @@ bool BaseConnection::registerObject(DBusError *error) * Reimplemented from DBusService. */ bool BaseConnection::registerObject(const QString &busName, - const QString &objectPath, DBusError *error) + const QString &objectPath, DBusError *error) { return DBusService::registerObject(busName, objectPath, error); } +void BaseConnection::setSelfHandle(uint selfHandle) +{ + mPriv->selfHandle = selfHandle; +} + +uint BaseConnection::selfHandle() const +{ + return mPriv->selfHandle; +} + +void BaseConnection::setConnectCallback(const ConnectCallback &cb) +{ + mPriv->connectCB = cb; +} + +void BaseConnection::setInspectHandlesCallback(const InspectHandlesCallback &cb) +{ + mPriv->inspectHandlesCB = cb; +} + /** * \fn void BaseConnection::disconnected() * * Emitted when this connection has been disconnected. */ +/** + * \class AbstractConnectionInterface + * \ingroup servicecm + * \headerfile TelepathyQt/base-connection.h <TelepathyQt/BaseConnection> + * + * \brief Base class for all the Connection object interface implementations. + */ + +AbstractConnectionInterface::AbstractConnectionInterface(const QString &interfaceName) + : AbstractDBusServiceInterface(interfaceName) +{ +} + +AbstractConnectionInterface::~AbstractConnectionInterface() +{ +} + } diff --git a/TelepathyQt/base-connection.h b/TelepathyQt/base-connection.h index 8f4235e5..193f9196 100644 --- a/TelepathyQt/base-connection.h +++ b/TelepathyQt/base-connection.h @@ -30,6 +30,7 @@ #include <TelepathyQt/DBusService> #include <TelepathyQt/Global> #include <TelepathyQt/Types> +#include <TelepathyQt/Callbacks> #include <QDBusConnection> @@ -45,30 +46,26 @@ class TP_QT_EXPORT BaseConnection : public DBusService public: static BaseConnectionPtr create(const QString &cmName, const QString &protocolName, - const QVariantMap ¶meters) - { + const QVariantMap ¶meters) { return BaseConnectionPtr(new BaseConnection( - QDBusConnection::sessionBus(), cmName, protocolName, parameters)); + QDBusConnection::sessionBus(), cmName, protocolName, parameters)); } template<typename BaseConnectionSubclass> static SharedPtr<BaseConnectionSubclass> create(const QString &cmName, - const QString &protocolName, const QVariantMap ¶meters) - { + const QString &protocolName, const QVariantMap ¶meters) { return SharedPtr<BaseConnectionSubclass>(new BaseConnectionSubclass( QDBusConnection::sessionBus(), cmName, protocolName, parameters)); } static BaseConnectionPtr create(const QDBusConnection &dbusConnection, - const QString &cmName, const QString &protocolName, - const QVariantMap ¶meters) - { + const QString &cmName, const QString &protocolName, + const QVariantMap ¶meters) { return BaseConnectionPtr(new BaseConnection( - dbusConnection, cmName, protocolName, parameters)); + dbusConnection, cmName, protocolName, parameters)); } template<typename BaseConnectionSubclass> static SharedPtr<BaseConnectionSubclass> create(const QDBusConnection &dbusConnection, const QString &cmName, const QString &protocolName, - const QVariantMap ¶meters) - { + const QVariantMap ¶meters) { return SharedPtr<BaseConnectionSubclass>(new BaseConnectionSubclass( dbusConnection, cmName, protocolName, parameters)); } @@ -78,22 +75,58 @@ public: QString cmName() const; QString protocolName() const; QVariantMap parameters() const; - + uint status() const; QVariantMap immutableProperties() const; + void setStatus(uint newStatus, uint reason); + + typedef Callback4<BaseChannelPtr, const QString&, uint, uint, DBusError*> CreateChannelCallback; + void setCreateChannelCallback(const CreateChannelCallback &cb); + Tp::BaseChannelPtr createChannel(const QString &channelType, uint targetHandleType, uint targetHandle, uint initiatorHandle, bool suppressHandler, DBusError *error); + + typedef Callback3<UIntList, uint, const QStringList&, DBusError*> RequestHandlesCallback; + void setRequestHandlesCallback(const RequestHandlesCallback &cb); + UIntList requestHandles(uint handleType, const QStringList &identifiers, DBusError* error); + + //typedef Callback3<uint, const QString&, const QString&, DBusError*> SetPresenceCallback; + //void setSetPresenceCallback(const SetPresenceCallback &cb); + + void setSelfHandle(uint selfHandle); + uint selfHandle() const; + + typedef Callback1<void, DBusError*> ConnectCallback; + void setConnectCallback(const ConnectCallback &cb); + + typedef Callback3<QStringList, uint, const Tp::UIntList&, DBusError*> InspectHandlesCallback; + void setInspectHandlesCallback(const InspectHandlesCallback &cb); + + Tp::ChannelInfoList channelsInfo(); + Tp::ChannelDetailsList channelsDetails(); + + BaseChannelPtr ensureChannel(const QString &channelType, uint targetHandleType, + uint targetHandle, bool &yours, uint initiatorHandle, bool suppressHandler, DBusError *error); + void addChannel(BaseChannelPtr channel); + + QList<AbstractConnectionInterfacePtr> interfaces() const; + AbstractConnectionInterfacePtr interface(const QString &interfaceName) const; + bool plugInterface(const AbstractConnectionInterfacePtr &interface); + virtual QString uniqueName() const; bool registerObject(DBusError *error = NULL); Q_SIGNALS: void disconnected(); +private Q_SLOTS: + TP_QT_NO_EXPORT void removeChannel(); + protected: BaseConnection(const QDBusConnection &dbusConnection, - const QString &cmName, const QString &protocolName, - const QVariantMap ¶meters); + const QString &cmName, const QString &protocolName, + const QVariantMap ¶meters); virtual bool registerObject(const QString &busName, const QString &objectPath, - DBusError *error); + DBusError *error); private: class Adaptee; @@ -103,6 +136,23 @@ private: Private *mPriv; }; +class TP_QT_EXPORT AbstractConnectionInterface : public AbstractDBusServiceInterface +{ + Q_OBJECT + Q_DISABLE_COPY(AbstractConnectionInterface) + +public: + AbstractConnectionInterface(const QString &interfaceName); + virtual ~AbstractConnectionInterface(); + +private: + friend class BaseConnection; + + class Private; + friend class Private; + Private *mPriv; +}; + } #endif diff --git a/TelepathyQt/service-types.h b/TelepathyQt/service-types.h index cdb8e052..1578a0b5 100644 --- a/TelepathyQt/service-types.h +++ b/TelepathyQt/service-types.h @@ -33,6 +33,7 @@ namespace Tp { class AbstractProtocolInterface; +class AbstractConnectionInterface; class AbstractChannelInterface; class BaseConnection; class BaseConnectionManager; @@ -46,6 +47,7 @@ class DBusService; #ifndef DOXYGEN_SHOULD_SKIP_THIS typedef SharedPtr<AbstractProtocolInterface> AbstractProtocolInterfacePtr; +typedef SharedPtr<AbstractConnectionInterface> AbstractConnectionInterfacePtr; typedef SharedPtr<AbstractChannelInterface> AbstractChannelInterfacePtr; typedef SharedPtr<BaseConnection> BaseConnectionPtr; typedef SharedPtr<BaseConnectionManager> BaseConnectionManagerPtr; |