From ec143d6119940dd0f2534aa9b66cef2b766535db Mon Sep 17 00:00:00 2001 From: outfoxxed Date: Thu, 21 Nov 2024 19:54:07 -0800 Subject: [PATCH] dbus/properties: remove non bindable based dbus property impl --- src/dbus/properties.cpp | 25 ------------ src/dbus/properties.hpp | 90 ----------------------------------------- 2 files changed, 115 deletions(-) diff --git a/src/dbus/properties.cpp b/src/dbus/properties.cpp index 08146637..94a109c6 100644 --- a/src/dbus/properties.cpp +++ b/src/dbus/properties.cpp @@ -110,24 +110,6 @@ void asyncReadPropertyInternal( QObject::connect(call, &QDBusPendingCallWatcher::finished, &interface, responseCallback); } -void AbstractDBusProperty::update() { - if (this->group == nullptr) { - qFatal(logDbusProperties) << "Tried to update dbus property" << this->nameRef() - << "which is not attached to a group"; - } else { - this->group->requestPropertyUpdate(this); - } -} - -void AbstractDBusProperty::write() { - if (this->group == nullptr) { - qFatal(logDbusProperties) << "Tried to write dbus property" << this->nameRef() - << "which is not attached to a group"; - } else { - this->group->pushPropertyUpdate(this); - } -} - DBusPropertyGroup::DBusPropertyGroup(QVector properties, QObject* parent) : QObject(parent) , properties(std::move(properties)) {} @@ -157,11 +139,6 @@ void DBusPropertyGroup::setInterface(QDBusAbstractInterface* interface) { } } -void DBusPropertyGroup::attachProperty(AbstractDBusProperty* property) { - this->properties.append(property); - property->group = this; -} - void DBusPropertyGroup::attachProperty(DBusPropertyCore* property) { this->properties.append(property); } @@ -325,8 +302,6 @@ QString DBusPropertyGroup::propertyString(const DBusPropertyCore* property) cons return this->toString() % ':' % property->nameRef(); } -QString AbstractDBusProperty::toString() const { return this->group->propertyString(this); } - void DBusPropertyGroup::onPropertiesChanged( const QString& interfaceName, const QVariantMap& changedProperties, diff --git a/src/dbus/properties.hpp b/src/dbus/properties.hpp index 726668f6..846f70f2 100644 --- a/src/dbus/properties.hpp +++ b/src/dbus/properties.hpp @@ -104,40 +104,6 @@ private: friend class DBusPropertyGroup; }; -class AbstractDBusProperty - : public QObject - , public DBusPropertyCore { - Q_OBJECT; - -public: - explicit AbstractDBusProperty(QString name, bool required, QObject* parent = nullptr) - : QObject(parent) - , required(required) - , mName(std::move(name)) {} - - [[nodiscard]] QString name() const override { return this->mName; }; - [[nodiscard]] QStringView nameRef() const override { return this->mName; }; - [[nodiscard]] bool isRequired() const override { return this->required; }; - - [[nodiscard]] QString toString() const; - -public slots: - void update(); - void write(); - -signals: - void changed(); - -private: - bool required : 1; - bool mExists : 1 = false; - - DBusPropertyGroup* group = nullptr; - QString mName; - - friend class DBusPropertyGroup; -}; - // Default implementation with no transformation template struct DBusDataTransform { @@ -265,7 +231,6 @@ public: explicit DBusPropertyGroup(QObject* parent): DBusPropertyGroup({}, parent) {} void setInterface(QDBusAbstractInterface* interface); - void attachProperty(AbstractDBusProperty* property); void attachProperty(DBusPropertyCore* property); void updateAllDirect(); void updateAllViaGetAll(); @@ -297,61 +262,6 @@ private: friend class AbstractDBusProperty; }; -template -class DBusProperty: public AbstractDBusProperty { -public: - explicit DBusProperty( - QString name, - T value = T(), - bool required = true, - QObject* parent = nullptr - ) - : AbstractDBusProperty(std::move(name), required, parent) - , value(std::move(value)) {} - - explicit DBusProperty( - DBusPropertyGroup& group, - QString name, - T value = T(), - bool required = true, - QObject* parent = nullptr - ) - : DBusProperty(std::move(name), std::move(value), required, parent) { - group.attachProperty(this); - } - - [[nodiscard]] QString valueString() override { - QString str; - QDebug(&str) << this->value; - return str; - } - - [[nodiscard]] const T& get() const { return this->value; } - - void set(T value) { - this->value = std::move(value); - emit this->changed(); - } - -protected: - QDBusError store(const QVariant& variant) override { - auto result = demarshallVariant(variant); - - if (result.isValid()) { - this->set(std::move(result.value)); - } - - return result.error; - } - - QVariant serialize() override { return QVariant::fromValue(this->value); } - -private: - T value; - - friend class DBusPropertyCore; -}; - } // namespace qs::dbus // NOLINTBEGIN