dbus/properties: dbus/dbusutil -> dbus/properties

This commit is contained in:
outfoxxed 2024-04-29 18:37:57 -07:00
parent 74d1bb9bc2
commit aa9f8cd001
Signed by: outfoxxed
GPG key ID: 4C88A185FB89301E
7 changed files with 33 additions and 29 deletions

View file

@ -8,7 +8,7 @@ qt_add_dbus_interface(DBUS_INTERFACES
) )
qt_add_library(quickshell-dbus STATIC qt_add_library(quickshell-dbus STATIC
dbusutil.cpp properties.cpp
${DBUS_INTERFACES} ${DBUS_INTERFACES}
) )

View file

@ -1,4 +1,4 @@
#include "dbusutil.hpp" #include "properties.hpp"
#include <algorithm> #include <algorithm>
#include <utility> #include <utility>
@ -22,7 +22,7 @@
#include "dbus_properties.h" #include "dbus_properties.h"
Q_LOGGING_CATEGORY(logDbus, "quickshell.dbus", QtWarningMsg); Q_LOGGING_CATEGORY(logDbusProperties, "quickshell.dbus.properties", QtWarningMsg);
namespace qs::dbus { namespace qs::dbus {
@ -114,27 +114,28 @@ void asyncReadPropertyInternal(
void AbstractDBusProperty::tryUpdate(const QVariant& variant) { void AbstractDBusProperty::tryUpdate(const QVariant& variant) {
auto error = this->read(variant); auto error = this->read(variant);
if (error.isValid()) { if (error.isValid()) {
qCWarning(logDbus).noquote() << "Error demarshalling property update for" << this->toString(); qCWarning(logDbusProperties).noquote()
qCWarning(logDbus) << error; << "Error demarshalling property update for" << this->toString();
qCWarning(logDbusProperties) << error;
} else { } else {
qCDebug(logDbus).noquote() << "Updated property" << this->toString() << "to" qCDebug(logDbusProperties).noquote()
<< this->valueString(); << "Updated property" << this->toString() << "to" << this->valueString();
} }
} }
void AbstractDBusProperty::update() { void AbstractDBusProperty::update() {
if (this->group == nullptr) { if (this->group == nullptr) {
qFatal(logDbus) << "Tried to update dbus property" << this->name qFatal(logDbusProperties) << "Tried to update dbus property" << this->name
<< "which is not attached to a group"; << "which is not attached to a group";
} else { } else {
const QString propStr = this->toString(); const QString propStr = this->toString();
if (this->group->interface == nullptr) { if (this->group->interface == nullptr) {
qFatal(logDbus).noquote() << "Tried to update property" << propStr qFatal(logDbusProperties).noquote()
<< "of a disconnected interface"; << "Tried to update property" << propStr << "of a disconnected interface";
} }
qCDebug(logDbus).noquote() << "Updating property" << propStr; qCDebug(logDbusProperties).noquote() << "Updating property" << propStr;
auto pendingCall = auto pendingCall =
this->group->propertyInterface->Get(this->group->interface->interface(), this->name); this->group->propertyInterface->Get(this->group->interface->interface(), this->name);
@ -145,8 +146,8 @@ void AbstractDBusProperty::update() {
const QDBusPendingReply<QDBusVariant> reply = *call; const QDBusPendingReply<QDBusVariant> reply = *call;
if (reply.isError()) { if (reply.isError()) {
qCWarning(logDbus).noquote() << "Error updating property" << propStr; qCWarning(logDbusProperties).noquote() << "Error updating property" << propStr;
qCWarning(logDbus) << reply.error(); qCWarning(logDbusProperties) << reply.error();
} else { } else {
this->tryUpdate(reply.value().variant()); this->tryUpdate(reply.value().variant());
} }
@ -198,8 +199,8 @@ void DBusPropertyGroup::attachProperty(AbstractDBusProperty* property) {
} }
void DBusPropertyGroup::updateAllDirect() { void DBusPropertyGroup::updateAllDirect() {
qCDebug(logDbus).noquote() << "Updating all properties of" << this->toString() qCDebug(logDbusProperties).noquote()
<< "via individual queries"; << "Updating all properties of" << this->toString() << "via individual queries";
if (this->interface == nullptr) { if (this->interface == nullptr) {
qFatal() << "Attempted to update properties of disconnected property group"; qFatal() << "Attempted to update properties of disconnected property group";
@ -211,7 +212,8 @@ void DBusPropertyGroup::updateAllDirect() {
} }
void DBusPropertyGroup::updateAllViaGetAll() { void DBusPropertyGroup::updateAllViaGetAll() {
qCDebug(logDbus).noquote() << "Updating all properties of" << this->toString() << "via GetAll"; qCDebug(logDbusProperties).noquote()
<< "Updating all properties of" << this->toString() << "via GetAll";
if (this->interface == nullptr) { if (this->interface == nullptr) {
qFatal() << "Attempted to update properties of disconnected property group"; qFatal() << "Attempted to update properties of disconnected property group";
@ -224,11 +226,12 @@ void DBusPropertyGroup::updateAllViaGetAll() {
const QDBusPendingReply<QVariantMap> reply = *call; const QDBusPendingReply<QVariantMap> reply = *call;
if (reply.isError()) { if (reply.isError()) {
qCWarning(logDbus).noquote() qCWarning(logDbusProperties).noquote()
<< "Error updating properties of" << this->toString() << "via GetAll"; << "Error updating properties of" << this->toString() << "via GetAll";
qCWarning(logDbus) << reply.error(); qCWarning(logDbusProperties) << reply.error();
} else { } else {
qCDebug(logDbus).noquote() << "Received GetAll property set for" << this->toString(); qCDebug(logDbusProperties).noquote()
<< "Received GetAll property set for" << this->toString();
this->updatePropertySet(reply.value()); this->updatePropertySet(reply.value());
} }
@ -248,7 +251,7 @@ void DBusPropertyGroup::updatePropertySet(const QVariantMap& properties) {
); );
if (prop == this->properties.end()) { if (prop == this->properties.end()) {
qCDebug(logDbus) << "Ignoring untracked property update" << name << "for" << this; qCDebug(logDbusProperties) << "Ignoring untracked property update" << name << "for" << this;
} else { } else {
(*prop)->tryUpdate(value); (*prop)->tryUpdate(value);
} }
@ -270,8 +273,8 @@ void DBusPropertyGroup::onPropertiesChanged(
const QStringList& invalidatedProperties const QStringList& invalidatedProperties
) { ) {
if (interfaceName != this->interface->interface()) return; if (interfaceName != this->interface->interface()) return;
qCDebug(logDbus).noquote() << "Received property change set and invalidations for" qCDebug(logDbusProperties).noquote()
<< this->toString(); << "Received property change set and invalidations for" << this->toString();
for (const auto& name: invalidatedProperties) { for (const auto& name: invalidatedProperties) {
auto prop = std::find_if( auto prop = std::find_if(
@ -281,7 +284,8 @@ void DBusPropertyGroup::onPropertiesChanged(
); );
if (prop == this->properties.end()) { if (prop == this->properties.end()) {
qCDebug(logDbus) << "Ignoring untracked property invalidation" << name << "for" << this; qCDebug(logDbusProperties) << "Ignoring untracked property invalidation" << name << "for"
<< this;
} else { } else {
(*prop)->update(); (*prop)->update();
} }

View file

@ -19,7 +19,7 @@
class DBusPropertiesInterface; class DBusPropertiesInterface;
Q_DECLARE_LOGGING_CATEGORY(logDbus); Q_DECLARE_LOGGING_CATEGORY(logDbusProperties);
namespace qs::dbus { namespace qs::dbus {

View file

@ -11,7 +11,7 @@
#include <qtmetamacros.h> #include <qtmetamacros.h>
#include <unistd.h> #include <unistd.h>
#include "../../dbus/dbusutil.hpp" #include "../../dbus/properties.hpp"
#include "dbus_watcher_interface.h" #include "dbus_watcher_interface.h"
#include "item.hpp" #include "item.hpp"
#include "watcher.hpp" #include "watcher.hpp"

View file

@ -17,7 +17,7 @@
#include <qtmetamacros.h> #include <qtmetamacros.h>
#include "../../core/iconimageprovider.hpp" #include "../../core/iconimageprovider.hpp"
#include "../../dbus/dbusutil.hpp" #include "../../dbus/properties.hpp"
#include "dbus_item.h" #include "dbus_item.h"
#include "dbus_item_types.hpp" #include "dbus_item_types.hpp"
#include "host.hpp" #include "host.hpp"

View file

@ -9,7 +9,7 @@
#include <qtmetamacros.h> #include <qtmetamacros.h>
#include <qtypes.h> #include <qtypes.h>
#include "../../dbus/dbusutil.hpp" #include "../../dbus/properties.hpp"
#include "dbus_item.h" #include "dbus_item.h"
#include "dbus_item_types.hpp" #include "dbus_item_types.hpp"

View file

@ -9,7 +9,7 @@
#include <qtmetamacros.h> #include <qtmetamacros.h>
#include <qtypes.h> #include <qtypes.h>
#include "../../dbus/dbusutil.hpp" #include "../../dbus/properties.hpp"
#include "host.hpp" #include "host.hpp"
#include "item.hpp" #include "item.hpp"