telepathy-qt: Added BaseConnectionClientTypesInterface.

Alexandr Akulich kaffeine at kemper.freedesktop.org
Fri May 6 15:26:59 UTC 2016


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

Author: Alexandr Akulich <akulichalexander at gmail.com>
Date:   Thu Apr 28 20:11:07 2016 +0500

Added BaseConnectionClientTypesInterface.

Current design doesn't allow to delay DBus answers, so probably there
is a big problem with RequestClientTypes(), which is expected to "If
necessary, make a request to the server for up-to-date information,
and wait for a reply."

---

 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 6b97237..4cc4500 100644
--- a/TelepathyQt/base-connection-internal.h
+++ b/TelepathyQt/base-connection-internal.h
@@ -320,6 +320,27 @@ private:
     BaseConnectionAvatarsInterface *mInterface;
 };
 
+class TP_QT_NO_EXPORT BaseConnectionClientTypesInterface::Adaptee : public QObject
+{
+    Q_OBJECT
+
+public:
+    Adaptee(BaseConnectionClientTypesInterface *interface);
+    ~Adaptee();
+
+private Q_SLOTS:
+    void getClientTypes(const Tp::UIntList &contacts,
+            const Tp::Service::ConnectionInterfaceClientTypesAdaptor::GetClientTypesContextPtr &context);
+    void requestClientTypes(uint contact,
+            const Tp::Service::ConnectionInterfaceClientTypesAdaptor::RequestClientTypesContextPtr &context);
+
+Q_SIGNALS:
+    void clientTypesUpdated(uint contact, const QStringList &clientTypes);
+
+private:
+    BaseConnectionClientTypesInterface *mInterface;
+};
+
 class TP_QT_NO_EXPORT BaseConnectionContactCapabilitiesInterface::Adaptee : public QObject
 {
     Q_OBJECT
diff --git a/TelepathyQt/base-connection.cpp b/TelepathyQt/base-connection.cpp
index 7377f65..b9999fa 100644
--- a/TelepathyQt/base-connection.cpp
+++ b/TelepathyQt/base-connection.cpp
@@ -2395,6 +2395,133 @@ 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.ClientTypes
+// The BaseConnectionClientTypesInterface code is fully or partially generated by the TelepathyQt-Generator.
+struct TP_QT_NO_EXPORT BaseConnectionClientTypesInterface::Private {
+    Private(BaseConnectionClientTypesInterface *parent)
+        : adaptee(new BaseConnectionClientTypesInterface::Adaptee(parent))
+    {
+    }
+
+    GetClientTypesCallback getClientTypesCB;
+    RequestClientTypesCallback requestClientTypesCB;
+    BaseConnectionClientTypesInterface::Adaptee *adaptee;
+};
+
+BaseConnectionClientTypesInterface::Adaptee::Adaptee(BaseConnectionClientTypesInterface *interface)
+    : QObject(interface),
+      mInterface(interface)
+{
+}
+
+BaseConnectionClientTypesInterface::Adaptee::~Adaptee()
+{
+}
+
+void BaseConnectionClientTypesInterface::Adaptee::getClientTypes(const Tp::UIntList &contacts,
+        const Tp::Service::ConnectionInterfaceClientTypesAdaptor::GetClientTypesContextPtr &context)
+{
+    debug() << "BaseConnectionClientTypesInterface::Adaptee::getClientTypes";
+    DBusError error;
+    Tp::ContactClientTypes clientTypes = mInterface->getClientTypes(contacts, &error);
+    if (error.isValid()) {
+        context->setFinishedWithError(error.name(), error.message());
+        return;
+    }
+    context->setFinished(clientTypes);
+}
+
+void BaseConnectionClientTypesInterface::Adaptee::requestClientTypes(uint contact,
+        const Tp::Service::ConnectionInterfaceClientTypesAdaptor::RequestClientTypesContextPtr &context)
+{
+    debug() << "BaseConnectionClientTypesInterface::Adaptee::requestClientTypes";
+    DBusError error;
+    QStringList clientTypes = mInterface->requestClientTypes(contact, &error);
+    if (error.isValid()) {
+        context->setFinishedWithError(error.name(), error.message());
+        return;
+    }
+    context->setFinished(clientTypes);
+}
+
+/**
+ * \class BaseConnectionClientTypesInterface
+ * \ingroup serviceconn
+ * \headerfile TelepathyQt/base-connection.h <TelepathyQt/BaseConnection>
+ *
+ * \brief Base class for implementations of Connection.Interface.ClientTypes
+ */
+
+/**
+ * Class constructor.
+ */
+BaseConnectionClientTypesInterface::BaseConnectionClientTypesInterface()
+    : AbstractConnectionInterface(TP_QT_IFACE_CONNECTION_INTERFACE_CLIENT_TYPES),
+      mPriv(new Private(this))
+{
+}
+
+/**
+ * Class destructor.
+ */
+BaseConnectionClientTypesInterface::~BaseConnectionClientTypesInterface()
+{
+    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 BaseConnectionClientTypesInterface::immutableProperties() const
+{
+    QVariantMap map;
+    return map;
+}
+
+void BaseConnectionClientTypesInterface::createAdaptor()
+{
+    (void) new Tp::Service::ConnectionInterfaceClientTypesAdaptor(dbusObject()->dbusConnection(),
+            mPriv->adaptee, dbusObject());
+}
+
+void BaseConnectionClientTypesInterface::setGetClientTypesCallback(const GetClientTypesCallback &cb)
+{
+    mPriv->getClientTypesCB = cb;
+}
+
+Tp::ContactClientTypes BaseConnectionClientTypesInterface::getClientTypes(const Tp::UIntList &contacts, DBusError *error)
+{
+    if (!mPriv->getClientTypesCB.isValid()) {
+        error->set(TP_QT_ERROR_NOT_IMPLEMENTED, QLatin1String("Not implemented"));
+        return Tp::ContactClientTypes();
+    }
+    return mPriv->getClientTypesCB(contacts, error);
+}
+
+void BaseConnectionClientTypesInterface::setRequestClientTypesCallback(const RequestClientTypesCallback &cb)
+{
+    mPriv->requestClientTypesCB = cb;
+}
+
+QStringList BaseConnectionClientTypesInterface::requestClientTypes(uint contact, DBusError *error)
+{
+    if (!mPriv->requestClientTypesCB.isValid()) {
+        error->set(TP_QT_ERROR_NOT_IMPLEMENTED, QLatin1String("Not implemented"));
+        return QStringList();
+    }
+    return mPriv->requestClientTypesCB(contact, error);
+}
+
+void BaseConnectionClientTypesInterface::clientTypesUpdated(uint contact, const QStringList &clientTypes)
+{
+    QMetaObject::invokeMethod(mPriv->adaptee, "clientTypesUpdated", Q_ARG(uint, contact), Q_ARG(QStringList, clientTypes)); //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 {
diff --git a/TelepathyQt/base-connection.h b/TelepathyQt/base-connection.h
index 7cf98b8..1d2d124 100644
--- a/TelepathyQt/base-connection.h
+++ b/TelepathyQt/base-connection.h
@@ -574,6 +574,50 @@ private:
     Private *mPriv;
 };
 
+class TP_QT_EXPORT BaseConnectionClientTypesInterface : public AbstractConnectionInterface
+{
+    Q_OBJECT
+    Q_DISABLE_COPY(BaseConnectionClientTypesInterface)
+
+public:
+    static BaseConnectionClientTypesInterfacePtr create()
+    {
+        return BaseConnectionClientTypesInterfacePtr(new BaseConnectionClientTypesInterface());
+    }
+    template<typename BaseConnectionClientTypesInterfaceSubclass>
+    static SharedPtr<BaseConnectionClientTypesInterfaceSubclass> create()
+    {
+        return SharedPtr<BaseConnectionClientTypesInterfaceSubclass>(
+                new BaseConnectionClientTypesInterfaceSubclass());
+    }
+
+    virtual ~BaseConnectionClientTypesInterface();
+
+    QVariantMap immutableProperties() const;
+
+    typedef Callback2<Tp::ContactClientTypes, const Tp::UIntList &, DBusError*> GetClientTypesCallback;
+    void setGetClientTypesCallback(const GetClientTypesCallback &cb);
+    Tp::ContactClientTypes getClientTypes(const Tp::UIntList &contacts, DBusError *error);
+
+    typedef Callback2<QStringList, uint, DBusError*> RequestClientTypesCallback;
+    void setRequestClientTypesCallback(const RequestClientTypesCallback &cb);
+    QStringList requestClientTypes(uint contact, DBusError *error);
+
+    void clientTypesUpdated(uint contact, const QStringList &clientTypes);
+
+protected:
+    BaseConnectionClientTypesInterface();
+
+private:
+    void createAdaptor();
+
+    class Adaptee;
+    friend class Adaptee;
+    struct Private;
+    friend struct Private;
+    Private *mPriv;
+};
+
 class TP_QT_EXPORT BaseConnectionContactCapabilitiesInterface : public AbstractConnectionInterface
 {
     Q_OBJECT
diff --git a/TelepathyQt/service-types.h b/TelepathyQt/service-types.h
index 96d0a29..b962793 100644
--- a/TelepathyQt/service-types.h
+++ b/TelepathyQt/service-types.h
@@ -48,6 +48,7 @@ class BaseConnectionContactInfoInterface;
 class BaseConnectionAddressingInterface;
 class BaseConnectionAliasingInterface;
 class BaseConnectionAvatarsInterface;
+class BaseConnectionClientTypesInterface;
 class BaseConnectionContactCapabilitiesInterface;
 class BaseConnectionManager;
 class BaseProtocol;
@@ -93,6 +94,7 @@ typedef SharedPtr<BaseConnectionContactInfoInterface> BaseConnectionContactInfoI
 typedef SharedPtr<BaseConnectionAddressingInterface> BaseConnectionAddressingInterfacePtr;
 typedef SharedPtr<BaseConnectionAliasingInterface> BaseConnectionAliasingInterfacePtr;
 typedef SharedPtr<BaseConnectionAvatarsInterface> BaseConnectionAvatarsInterfacePtr;
+typedef SharedPtr<BaseConnectionClientTypesInterface> BaseConnectionClientTypesInterfacePtr;
 typedef SharedPtr<BaseConnectionContactCapabilitiesInterface> BaseConnectionContactCapabilitiesInterfacePtr;
 typedef SharedPtr<BaseConnectionManager> BaseConnectionManagerPtr;
 typedef SharedPtr<BaseProtocol> BaseProtocolPtr;



More information about the telepathy-commits mailing list