telepathy-qt: Add BaseConnectionAddressingInterface
David Edmundson
davidedmundson at kemper.freedesktop.org
Sat Jun 14 04:57:36 PDT 2014
Module: telepathy-qt
Branch: master
Commit: 5dd4aba91e38fa3c3d4000136ce75ee3a2cfec74
URL: http://cgit.freedesktop.org/telepathy/telepathy-qt/commit/?id=5dd4aba91e38fa3c3d4000136ce75ee3a2cfec74
Author: Matthias Gehre <M.Gehre at gmx.de>
Date: Sat Mar 9 13:32:43 2013 -0600
Add BaseConnectionAddressingInterface
---
TelepathyQt/base-connection-internal.h | 19 +++++
TelepathyQt/base-connection.cpp | 120 ++++++++++++++++++++++++++++++++
TelepathyQt/base-connection.h | 42 +++++++++++
TelepathyQt/service-types.h | 2 +
4 files changed, 183 insertions(+)
diff --git a/TelepathyQt/base-connection-internal.h b/TelepathyQt/base-connection-internal.h
index 09254aa..a667f87 100644
--- a/TelepathyQt/base-connection-internal.h
+++ b/TelepathyQt/base-connection-internal.h
@@ -192,4 +192,23 @@ Q_SIGNALS:
public:
BaseConnectionContactListInterface *mInterface;
};
+
+class TP_QT_NO_EXPORT BaseConnectionAddressingInterface::Adaptee : public QObject
+{
+ Q_OBJECT
+
+public:
+ Adaptee(BaseConnectionAddressingInterface *interface);
+ ~Adaptee();
+
+
+private Q_SLOTS:
+ void getContactsByVCardField(const QString &field, const QStringList &addresses, const QStringList &interfaces, const Tp::Service::ConnectionInterfaceAddressingAdaptor::GetContactsByVCardFieldContextPtr &context);
+ void getContactsByURI(const QStringList &URIs, const QStringList &interfaces, const Tp::Service::ConnectionInterfaceAddressingAdaptor::GetContactsByURIContextPtr &context);
+Q_SIGNALS:
+
+public:
+ BaseConnectionAddressingInterface *mInterface;
+};
+
}
diff --git a/TelepathyQt/base-connection.cpp b/TelepathyQt/base-connection.cpp
index f7909b0..e95ccf0 100644
--- a/TelepathyQt/base-connection.cpp
+++ b/TelepathyQt/base-connection.cpp
@@ -1223,4 +1223,124 @@ void BaseConnectionContactListInterface::Adaptee::requestSubscription(const Tp::
context->setFinished();
}
+// Conn.I.Addressing
+BaseConnectionAddressingInterface::Adaptee::Adaptee(BaseConnectionAddressingInterface *interface)
+ : QObject(interface),
+ mInterface(interface)
+{
+}
+
+BaseConnectionAddressingInterface::Adaptee::~Adaptee()
+{
+}
+
+struct TP_QT_NO_EXPORT BaseConnectionAddressingInterface::Private {
+ Private(BaseConnectionAddressingInterface *parent)
+ : adaptee(new BaseConnectionAddressingInterface::Adaptee(parent)) {
+ }
+ GetContactsByVCardFieldCallback getContactsByVCardFieldCB;
+ GetContactsByURICallback getContactsByURICB;
+ BaseConnectionAddressingInterface::Adaptee *adaptee;
+};
+
+/**
+ * \class BaseProtocolPresenceInterface
+ * \ingroup servicecm
+ * \headerfile TelepathyQt/base-protocol.h <TelepathyQt/BaseProtocolPresenceInterface>
+ *
+ * \brief Base class for implementations of Protocol.Interface.Presence
+ */
+
+/**
+ * Class constructor.
+ */
+BaseConnectionAddressingInterface::BaseConnectionAddressingInterface()
+ : AbstractConnectionInterface(TP_QT_IFACE_CONNECTION_INTERFACE_ADDRESSING),
+ mPriv(new Private(this))
+{
+}
+
+/**
+ * Class destructor.
+ */
+BaseConnectionAddressingInterface::~BaseConnectionAddressingInterface()
+{
+ delete mPriv;
+}
+
+/**
+ * Return the immutable properties of this<interface.
+ *
+ * Immutable properties cannot change after the interface has been registered
+ * on a service on the bus with registerInterface().
+ *
+ * \return The immutable properties of this interface.
+ */
+QVariantMap BaseConnectionAddressingInterface::immutableProperties() const
+{
+ QVariantMap map;
+ return map;
+}
+
+void BaseConnectionAddressingInterface::createAdaptor()
+{
+ (void) new Service::ConnectionInterfaceAddressingAdaptor(dbusObject()->dbusConnection(),
+ mPriv->adaptee, dbusObject());
+}
+
+void BaseConnectionAddressingInterface::setGetContactsByVCardFieldCallback(const GetContactsByVCardFieldCallback &cb)
+{
+ mPriv->getContactsByVCardFieldCB = cb;
+}
+
+void BaseConnectionAddressingInterface::setGetContactsByURICallback(const GetContactsByURICallback &cb)
+{
+ mPriv->getContactsByURICB = cb;
+}
+
+void BaseConnectionAddressingInterface::Adaptee::getContactsByVCardField(const QString &field,
+ const QStringList &addresses,
+ const QStringList &interfaces,
+ const Tp::Service::ConnectionInterfaceAddressingAdaptor::GetContactsByVCardFieldContextPtr &context)
+{
+ if (!mInterface->mPriv->getContactsByVCardFieldCB.isValid()) {
+ context->setFinishedWithError(TP_QT_ERROR_NOT_IMPLEMENTED, QLatin1String("Not implemented"));
+ return;
+ }
+ Tp::AddressingNormalizationMap addressingNormalizationMap;
+ Tp::ContactAttributesMap contactAttributesMap;
+
+ DBusError error;
+ mInterface->mPriv->getContactsByVCardFieldCB(field, addresses, interfaces,
+ addressingNormalizationMap, contactAttributesMap,
+ &error);
+ if (error.isValid()) {
+ context->setFinishedWithError(error.name(), error.message());
+ return;
+ }
+ context->setFinished(addressingNormalizationMap, contactAttributesMap);
+}
+
+void BaseConnectionAddressingInterface::Adaptee::getContactsByURI(const QStringList &URIs,
+ const QStringList &interfaces,
+ const Tp::Service::ConnectionInterfaceAddressingAdaptor::GetContactsByURIContextPtr &context)
+{
+ if (!mInterface->mPriv->getContactsByURICB.isValid()) {
+ context->setFinishedWithError(TP_QT_ERROR_NOT_IMPLEMENTED, QLatin1String("Not implemented"));
+ return;
+ }
+ Tp::AddressingNormalizationMap addressingNormalizationMap;
+ Tp::ContactAttributesMap contactAttributesMap;
+
+ DBusError error;
+ mInterface->mPriv->getContactsByURICB(URIs, interfaces,
+ addressingNormalizationMap, contactAttributesMap,
+ &error);
+ if (error.isValid()) {
+ context->setFinishedWithError(error.name(), error.message());
+ return;
+ }
+ context->setFinished(addressingNormalizationMap, contactAttributesMap);
+}
+
}
diff --git a/TelepathyQt/base-connection.h b/TelepathyQt/base-connection.h
index 1eadc16..3667cd0 100644
--- a/TelepathyQt/base-connection.h
+++ b/TelepathyQt/base-connection.h
@@ -317,6 +317,48 @@ private:
friend struct Private;
Private *mPriv;
};
+
+class TP_QT_EXPORT BaseConnectionAddressingInterface : public AbstractConnectionInterface
+{
+ Q_OBJECT
+ Q_DISABLE_COPY(BaseConnectionAddressingInterface)
+
+public:
+ static BaseConnectionAddressingInterfacePtr create() {
+ return BaseConnectionAddressingInterfacePtr(new BaseConnectionAddressingInterface());
+ }
+ template<typename BaseConnectionAddressingInterfaceSubclass>
+ static SharedPtr<BaseConnectionAddressingInterfaceSubclass> create() {
+ return SharedPtr<BaseConnectionAddressingInterfaceSubclass>(
+ new BaseConnectionAddressingInterfaceSubclass());
+ }
+
+ virtual ~BaseConnectionAddressingInterface();
+
+ QVariantMap immutableProperties() const;
+
+
+
+ typedef Callback6 < void, const QString&, const QStringList&, const QStringList&,
+ Tp::AddressingNormalizationMap&, Tp::ContactAttributesMap&, DBusError* > GetContactsByVCardFieldCallback;
+ void setGetContactsByVCardFieldCallback(const GetContactsByVCardFieldCallback &cb);
+
+ typedef Callback5 < void, const QStringList&, const QStringList&,
+ Tp::AddressingNormalizationMap&, Tp::ContactAttributesMap&, DBusError* > GetContactsByURICallback;
+ void setGetContactsByURICallback(const GetContactsByURICallback &cb);
+
+protected:
+ BaseConnectionAddressingInterface();
+
+private:
+ void createAdaptor();
+
+ class Adaptee;
+ friend class Adaptee;
+ struct Private;
+ friend struct Private;
+ Private *mPriv;
+};
}
#endif
diff --git a/TelepathyQt/service-types.h b/TelepathyQt/service-types.h
index 4a21156..80cb170 100644
--- a/TelepathyQt/service-types.h
+++ b/TelepathyQt/service-types.h
@@ -40,6 +40,7 @@ class BaseConnectionRequestsInterface;
class BaseConnectionContactsInterface;
class BaseConnectionSimplePresenceInterface;
class BaseConnectionContactListInterface;
+class BaseConnectionAddressingInterface;
class BaseConnectionManager;
class BaseProtocol;
class BaseProtocolAddressingInterface;
@@ -60,6 +61,7 @@ typedef SharedPtr<BaseConnectionRequestsInterface> BaseConnectionRequestsInterfa
typedef SharedPtr<BaseConnectionContactsInterface> BaseConnectionContactsInterfacePtr;
typedef SharedPtr<BaseConnectionSimplePresenceInterface> BaseConnectionSimplePresenceInterfacePtr;
typedef SharedPtr<BaseConnectionContactListInterface> BaseConnectionContactListInterfacePtr;
+typedef SharedPtr<BaseConnectionAddressingInterface> BaseConnectionAddressingInterfacePtr;
typedef SharedPtr<BaseConnectionManager> BaseConnectionManagerPtr;
typedef SharedPtr<BaseProtocol> BaseProtocolPtr;
typedef SharedPtr<BaseProtocolAddressingInterface> BaseProtocolAddressingInterfacePtr;
More information about the telepathy-commits
mailing list