telepathy-qt: Added BaseConnectionContactCapabilitiesInterface.

Alexandr Akulich kaffeine at kemper.freedesktop.org
Sat Apr 23 08:33:21 UTC 2016


Module: telepathy-qt
Branch: master
Commit: 0757bb0fa8da4c6f97b906be02a27bad35546fc5
URL:    http://cgit.freedesktop.org/telepathy/telepathy-qt/commit/?id=0757bb0fa8da4c6f97b906be02a27bad35546fc5

Author: Alexandr Akulich <akulichalexander at gmail.com>
Date:   Sun May 24 23:56:34 2015 +0500

Added BaseConnectionContactCapabilitiesInterface.

---

 TelepathyQt/base-connection-internal.h |  21 ++++++
 TelepathyQt/base-connection.cpp        | 127 +++++++++++++++++++++++++++++++++
 TelepathyQt/base-connection.h          |  44 ++++++++++++
 TelepathyQt/service-types.h            |   2 +
 4 files changed, 194 insertions(+)

diff --git a/TelepathyQt/base-connection-internal.h b/TelepathyQt/base-connection-internal.h
index 525e4ae..6b97237 100644
--- a/TelepathyQt/base-connection-internal.h
+++ b/TelepathyQt/base-connection-internal.h
@@ -320,4 +320,25 @@ private:
     BaseConnectionAvatarsInterface *mInterface;
 };
 
+class TP_QT_NO_EXPORT BaseConnectionContactCapabilitiesInterface::Adaptee : public QObject
+{
+    Q_OBJECT
+
+public:
+    Adaptee(BaseConnectionContactCapabilitiesInterface *interface);
+    ~Adaptee();
+
+private Q_SLOTS:
+    void updateCapabilities(const Tp::HandlerCapabilitiesList &handlerCapabilities,
+            const Tp::Service::ConnectionInterfaceContactCapabilitiesAdaptor::UpdateCapabilitiesContextPtr &context);
+    void getContactCapabilities(const Tp::UIntList &handles,
+            const Tp::Service::ConnectionInterfaceContactCapabilitiesAdaptor::GetContactCapabilitiesContextPtr &context);
+
+Q_SIGNALS:
+    void contactCapabilitiesChanged(const Tp::ContactCapabilitiesMap &caps);
+
+private:
+    BaseConnectionContactCapabilitiesInterface *mInterface;
+};
+
 }
diff --git a/TelepathyQt/base-connection.cpp b/TelepathyQt/base-connection.cpp
index dd90237..7377f65 100644
--- a/TelepathyQt/base-connection.cpp
+++ b/TelepathyQt/base-connection.cpp
@@ -2395,4 +2395,131 @@ void BaseConnectionAvatarsInterface::avatarRetrieved(uint contact, const QString
     QMetaObject::invokeMethod(mPriv->adaptee, "avatarRetrieved", Q_ARG(uint, contact), Q_ARG(QString, token), Q_ARG(QByteArray, avatar), Q_ARG(QString, type)); //Can simply use emit in Qt5
 }
 
+// Conn.I.ContactCapabilities
+// The BaseConnectionContactCapabilitiesInterface code is fully or partially generated by the TelepathyQt-Generator.
+struct TP_QT_NO_EXPORT BaseConnectionContactCapabilitiesInterface::Private {
+    Private(BaseConnectionContactCapabilitiesInterface *parent)
+        : adaptee(new BaseConnectionContactCapabilitiesInterface::Adaptee(parent))
+    {
+    }
+
+    UpdateCapabilitiesCallback updateCapabilitiesCB;
+    GetContactCapabilitiesCallback getContactCapabilitiesCB;
+    BaseConnectionContactCapabilitiesInterface::Adaptee *adaptee;
+};
+
+BaseConnectionContactCapabilitiesInterface::Adaptee::Adaptee(BaseConnectionContactCapabilitiesInterface *interface)
+    : QObject(interface),
+      mInterface(interface)
+{
+}
+
+BaseConnectionContactCapabilitiesInterface::Adaptee::~Adaptee()
+{
+}
+
+void BaseConnectionContactCapabilitiesInterface::Adaptee::updateCapabilities(const Tp::HandlerCapabilitiesList &handlerCapabilities,
+        const Tp::Service::ConnectionInterfaceContactCapabilitiesAdaptor::UpdateCapabilitiesContextPtr &context)
+{
+    debug() << "BaseConnectionContactCapabilitiesInterface::Adaptee::updateCapabilities";
+    DBusError error;
+    mInterface->updateCapabilities(handlerCapabilities, &error);
+    if (error.isValid()) {
+        context->setFinishedWithError(error.name(), error.message());
+        return;
+    }
+    context->setFinished();
+}
+
+void BaseConnectionContactCapabilitiesInterface::Adaptee::getContactCapabilities(const Tp::UIntList &handles,
+        const Tp::Service::ConnectionInterfaceContactCapabilitiesAdaptor::GetContactCapabilitiesContextPtr &context)
+{
+    debug() << "BaseConnectionContactCapabilitiesInterface::Adaptee::getContactCapabilities";
+    DBusError error;
+    Tp::ContactCapabilitiesMap contactCapabilities = mInterface->getContactCapabilities(handles, &error);
+    if (error.isValid()) {
+        context->setFinishedWithError(error.name(), error.message());
+        return;
+    }
+    context->setFinished(contactCapabilities);
+}
+
+/**
+ * \class BaseConnectionContactCapabilitiesInterface
+ * \ingroup serviceconn
+ * \headerfile TelepathyQt/base-connection.h <TelepathyQt/BaseConnection>
+ *
+ * \brief Base class for implementations of Connection.Interface.ContactCapabilities
+ */
+
+/**
+ * Class constructor.
+ */
+BaseConnectionContactCapabilitiesInterface::BaseConnectionContactCapabilitiesInterface()
+    : AbstractConnectionInterface(TP_QT_IFACE_CONNECTION_INTERFACE_CONTACT_CAPABILITIES),
+      mPriv(new Private(this))
+{
+}
+
+/**
+ * Class destructor.
+ */
+BaseConnectionContactCapabilitiesInterface::~BaseConnectionContactCapabilitiesInterface()
+{
+    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 BaseConnectionContactCapabilitiesInterface::immutableProperties() const
+{
+    QVariantMap map;
+    return map;
+}
+
+void BaseConnectionContactCapabilitiesInterface::createAdaptor()
+{
+    (void) new Tp::Service::ConnectionInterfaceContactCapabilitiesAdaptor(dbusObject()->dbusConnection(),
+            mPriv->adaptee, dbusObject());
+}
+
+void BaseConnectionContactCapabilitiesInterface::setUpdateCapabilitiesCallback(const UpdateCapabilitiesCallback &cb)
+{
+    mPriv->updateCapabilitiesCB = cb;
+}
+
+void BaseConnectionContactCapabilitiesInterface::updateCapabilities(const Tp::HandlerCapabilitiesList &handlerCapabilities, DBusError *error)
+{
+    if (!mPriv->updateCapabilitiesCB.isValid()) {
+        error->set(TP_QT_ERROR_NOT_IMPLEMENTED, QLatin1String("Not implemented"));
+        return;
+    }
+    return mPriv->updateCapabilitiesCB(handlerCapabilities, error);
+}
+
+void BaseConnectionContactCapabilitiesInterface::setGetContactCapabilitiesCallback(const GetContactCapabilitiesCallback &cb)
+{
+    mPriv->getContactCapabilitiesCB = cb;
+}
+
+Tp::ContactCapabilitiesMap BaseConnectionContactCapabilitiesInterface::getContactCapabilities(const Tp::UIntList &handles, DBusError *error)
+{
+    if (!mPriv->getContactCapabilitiesCB.isValid()) {
+        error->set(TP_QT_ERROR_NOT_IMPLEMENTED, QLatin1String("Not implemented"));
+        return Tp::ContactCapabilitiesMap();
+    }
+    return mPriv->getContactCapabilitiesCB(handles, error);
+}
+
+void BaseConnectionContactCapabilitiesInterface::contactCapabilitiesChanged(const Tp::ContactCapabilitiesMap &caps)
+{
+    QMetaObject::invokeMethod(mPriv->adaptee, "contactCapabilitiesChanged", Q_ARG(Tp::ContactCapabilitiesMap, caps)); //Can simply use emit in Qt5
+}
+
 }
diff --git a/TelepathyQt/base-connection.h b/TelepathyQt/base-connection.h
index bed8b68..7cf98b8 100644
--- a/TelepathyQt/base-connection.h
+++ b/TelepathyQt/base-connection.h
@@ -574,6 +574,50 @@ private:
     Private *mPriv;
 };
 
+class TP_QT_EXPORT BaseConnectionContactCapabilitiesInterface : public AbstractConnectionInterface
+{
+    Q_OBJECT
+    Q_DISABLE_COPY(BaseConnectionContactCapabilitiesInterface)
+
+public:
+    static BaseConnectionContactCapabilitiesInterfacePtr create()
+    {
+        return BaseConnectionContactCapabilitiesInterfacePtr(new BaseConnectionContactCapabilitiesInterface());
+    }
+    template<typename BaseConnectionContactCapabilitiesInterfaceSubclass>
+    static SharedPtr<BaseConnectionContactCapabilitiesInterfaceSubclass> create()
+    {
+        return SharedPtr<BaseConnectionContactCapabilitiesInterfaceSubclass>(
+                new BaseConnectionContactCapabilitiesInterfaceSubclass());
+    }
+
+    virtual ~BaseConnectionContactCapabilitiesInterface();
+
+    QVariantMap immutableProperties() const;
+
+    typedef Callback2<void, const Tp::HandlerCapabilitiesList &, DBusError*> UpdateCapabilitiesCallback;
+    void setUpdateCapabilitiesCallback(const UpdateCapabilitiesCallback &cb);
+    void updateCapabilities(const Tp::HandlerCapabilitiesList &handlerCapabilities, DBusError *error);
+
+    typedef Callback2<Tp::ContactCapabilitiesMap, const Tp::UIntList &, DBusError*> GetContactCapabilitiesCallback;
+    void setGetContactCapabilitiesCallback(const GetContactCapabilitiesCallback &cb);
+    Tp::ContactCapabilitiesMap getContactCapabilities(const Tp::UIntList &handles, DBusError *error);
+
+    void contactCapabilitiesChanged(const Tp::ContactCapabilitiesMap &caps);
+
+protected:
+    BaseConnectionContactCapabilitiesInterface();
+
+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 6247d4c..c63202c 100644
--- a/TelepathyQt/service-types.h
+++ b/TelepathyQt/service-types.h
@@ -48,6 +48,7 @@ class BaseConnectionContactInfoInterface;
 class BaseConnectionAddressingInterface;
 class BaseConnectionAliasingInterface;
 class BaseConnectionAvatarsInterface;
+class BaseConnectionContactCapabilitiesInterface;
 class BaseConnectionManager;
 class BaseProtocol;
 class BaseProtocolAddressingInterface;
@@ -91,6 +92,7 @@ typedef SharedPtr<BaseConnectionContactInfoInterface> BaseConnectionContactInfoI
 typedef SharedPtr<BaseConnectionAddressingInterface> BaseConnectionAddressingInterfacePtr;
 typedef SharedPtr<BaseConnectionAliasingInterface> BaseConnectionAliasingInterfacePtr;
 typedef SharedPtr<BaseConnectionAvatarsInterface> BaseConnectionAvatarsInterfacePtr;
+typedef SharedPtr<BaseConnectionContactCapabilitiesInterface> BaseConnectionContactCapabilitiesInterfacePtr;
 typedef SharedPtr<BaseConnectionManager> BaseConnectionManagerPtr;
 typedef SharedPtr<BaseProtocol> BaseProtocolPtr;
 typedef SharedPtr<BaseProtocolAddressingInterface> BaseProtocolAddressingInterfacePtr;



More information about the telepathy-commits mailing list