telepathy-qt: Added BaseChannelSecurableInterface.

David Edmundson davidedmundson at kemper.freedesktop.org
Sun Aug 17 10:55:03 PDT 2014


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

Author: Alexandr Akulich <akulichalexander at gmail.com>
Date:   Tue Aug  5 21:32:02 2014 +0600

Added BaseChannelSecurableInterface.

---

 TelepathyQt/base-channel-internal.h |   17 ++++++
 TelepathyQt/base-channel.cpp        |   99 +++++++++++++++++++++++++++++++++++
 TelepathyQt/base-channel.h          |   40 ++++++++++++++
 TelepathyQt/service-types.h         |    2 +
 4 files changed, 158 insertions(+)

diff --git a/TelepathyQt/base-channel-internal.h b/TelepathyQt/base-channel-internal.h
index 5187375..653969d 100644
--- a/TelepathyQt/base-channel-internal.h
+++ b/TelepathyQt/base-channel-internal.h
@@ -240,6 +240,23 @@ private:
     BaseChannelSASLAuthenticationInterface *mInterface;
 };
 
+class TP_QT_NO_EXPORT BaseChannelSecurableInterface::Adaptee : public QObject
+{
+    Q_OBJECT
+    Q_PROPERTY(bool encrypted READ encrypted)
+    Q_PROPERTY(bool verified READ verified)
+
+public:
+    Adaptee(BaseChannelSecurableInterface *interface);
+    ~Adaptee();
+
+    bool encrypted() const;
+    bool verified() const;
+
+private:
+    BaseChannelSecurableInterface *mInterface;
+};
+
 class TP_QT_NO_EXPORT BaseChannelGroupInterface::Adaptee : public QObject
 {
     Q_OBJECT
diff --git a/TelepathyQt/base-channel.cpp b/TelepathyQt/base-channel.cpp
index b84b409..972bfa1 100644
--- a/TelepathyQt/base-channel.cpp
+++ b/TelepathyQt/base-channel.cpp
@@ -1357,6 +1357,105 @@ void BaseChannelSASLAuthenticationInterface::newChallenge(const QByteArray &chal
     QMetaObject::invokeMethod(mPriv->adaptee, "newChallenge", Q_ARG(QByteArray, challengeData)); //Can simply use emit in Qt5
 }
 
+// Chan.I.Securable
+struct TP_QT_NO_EXPORT BaseChannelSecurableInterface::Private {
+    Private(BaseChannelSecurableInterface *parent)
+        : encrypted(false),
+          verified(false),
+          adaptee(new BaseChannelSecurableInterface::Adaptee(parent))
+    {
+    }
+
+    bool encrypted;
+    bool verified;
+    BaseChannelSecurableInterface::Adaptee *adaptee;
+};
+
+BaseChannelSecurableInterface::Adaptee::Adaptee(BaseChannelSecurableInterface *interface)
+    : QObject(interface),
+      mInterface(interface)
+{
+}
+
+BaseChannelSecurableInterface::Adaptee::~Adaptee()
+{
+}
+
+bool BaseChannelSecurableInterface::Adaptee::encrypted() const
+{
+    return mInterface->encrypted();
+}
+
+bool BaseChannelSecurableInterface::Adaptee::verified() const
+{
+    return mInterface->verified();
+}
+
+/**
+ * \class BaseChannelSecurableInterface
+ * \ingroup servicecm
+ * \headerfile TelepathyQt/base-channel.h <TelepathyQt/BaseChannel>
+ *
+ * \brief Base class for implementations of Channel.Interface.Securable
+ */
+
+/**
+ * Class constructor.
+ */
+BaseChannelSecurableInterface::BaseChannelSecurableInterface()
+    : AbstractChannelInterface(TP_QT_IFACE_CHANNEL_INTERFACE_SECURABLE),
+      mPriv(new Private(this))
+{
+}
+
+/**
+ * Class destructor.
+ */
+BaseChannelSecurableInterface::~BaseChannelSecurableInterface()
+{
+    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 BaseChannelSecurableInterface::immutableProperties() const
+{
+    QVariantMap map;
+    return map;
+}
+
+bool BaseChannelSecurableInterface::encrypted() const
+{
+    return mPriv->encrypted;
+}
+
+void BaseChannelSecurableInterface::setEncrypted(bool encrypted)
+{
+    mPriv->encrypted = encrypted;
+}
+
+bool BaseChannelSecurableInterface::verified() const
+{
+    return mPriv->verified;
+}
+
+void BaseChannelSecurableInterface::setVerified(bool verified)
+{
+    mPriv->verified = verified;
+}
+
+void BaseChannelSecurableInterface::createAdaptor()
+{
+    (void) new Service::ChannelInterfaceSecurableAdaptor(dbusObject()->dbusConnection(),
+            mPriv->adaptee, dbusObject());
+}
+
 //Chan.I.Group
 BaseChannelGroupInterface::Adaptee::Adaptee(BaseChannelGroupInterface *interface)
     : QObject(interface),
diff --git a/TelepathyQt/base-channel.h b/TelepathyQt/base-channel.h
index 1d00cae..261b1d1 100644
--- a/TelepathyQt/base-channel.h
+++ b/TelepathyQt/base-channel.h
@@ -390,6 +390,46 @@ private:
     Private *mPriv;
 };
 
+class TP_QT_EXPORT BaseChannelSecurableInterface : public AbstractChannelInterface
+{
+    Q_OBJECT
+    Q_DISABLE_COPY(BaseChannelSecurableInterface)
+
+public:
+    static BaseChannelSecurableInterfacePtr create()
+    {
+        return BaseChannelSecurableInterfacePtr(new BaseChannelSecurableInterface());
+    }
+    template<typename BaseChannelSecurableInterfaceSubclass>
+    static SharedPtr<BaseChannelSecurableInterfaceSubclass> create()
+    {
+        return SharedPtr<BaseChannelSecurableInterfaceSubclass>(
+                new BaseChannelSecurableInterfaceSubclass());
+    }
+
+    virtual ~BaseChannelSecurableInterface();
+
+    QVariantMap immutableProperties() const;
+
+    bool encrypted() const;
+    void setEncrypted(bool encrypted);
+
+    bool verified() const;
+    void setVerified(bool verified);
+
+protected:
+    BaseChannelSecurableInterface();
+
+private:
+    void createAdaptor();
+
+    class Adaptee;
+    friend class Adaptee;
+    struct Private;
+    friend struct Private;
+    Private *mPriv;
+};
+
 class TP_QT_EXPORT BaseChannelGroupInterface : public AbstractChannelInterface
 {
     Q_OBJECT
diff --git a/TelepathyQt/service-types.h b/TelepathyQt/service-types.h
index 199eb7c..fda50e1 100644
--- a/TelepathyQt/service-types.h
+++ b/TelepathyQt/service-types.h
@@ -54,6 +54,7 @@ class BaseChannelMessagesInterface;
 class BaseChannelServerAuthenticationType;
 class BaseChannelSASLAuthenticationInterface;
 class BaseChannelCaptchaAuthenticationInterface;
+class BaseChannelSecurableInterface;
 class BaseChannelGroupInterface;
 class DBusService;
 
@@ -81,6 +82,7 @@ typedef SharedPtr<BaseChannelMessagesInterface> BaseChannelMessagesInterfacePtr;
 typedef SharedPtr<BaseChannelServerAuthenticationType> BaseChannelServerAuthenticationTypePtr;
 typedef SharedPtr<BaseChannelSASLAuthenticationInterface> BaseChannelSASLAuthenticationInterfacePtr;
 typedef SharedPtr<BaseChannelCaptchaAuthenticationInterface> BaseChannelCaptchaAuthenticationInterfacePtr;
+typedef SharedPtr<BaseChannelSecurableInterface> BaseChannelSecurableInterfacePtr;
 typedef SharedPtr<BaseChannelGroupInterface> BaseChannelGroupInterfacePtr;
 typedef SharedPtr<DBusService> DBusServicePtr;
 



More information about the telepathy-commits mailing list