forked from quickshell/quickshell
all: mask various useless dbus errors
This commit is contained in:
parent
6572a7f61d
commit
ecc4a1249d
6 changed files with 106 additions and 61 deletions
|
@ -312,8 +312,8 @@ void DBusMenu::prepareToShow(qint32 item, qint32 depth) {
|
|||
auto responseCallback = [this, item, depth](QDBusPendingCallWatcher* call) {
|
||||
const QDBusPendingReply<bool> reply = *call;
|
||||
if (reply.isError()) {
|
||||
qCWarning(logDbusMenu) << "Error in AboutToShow, but showing anyway for menu" << item << "of"
|
||||
<< this << reply.error();
|
||||
qCDebug(logDbusMenu) << "Error in AboutToShow, but showing anyway for menu" << item << "of"
|
||||
<< this << reply.error();
|
||||
}
|
||||
|
||||
this->updateLayout(item, depth);
|
||||
|
|
|
@ -246,8 +246,13 @@ void DBusPropertyGroup::requestPropertyUpdate(DBusPropertyCore* property) {
|
|||
const QDBusPendingReply<QDBusVariant> reply = *call;
|
||||
|
||||
if (reply.isError()) {
|
||||
qCWarning(logDbusProperties).noquote() << "Error updating property" << propStr;
|
||||
qCWarning(logDbusProperties) << reply.error();
|
||||
if (!property->isRequired() && reply.error().type() == QDBusError::InvalidArgs) {
|
||||
qCDebug(logDbusProperties) << "Error updating non-required property" << propStr;
|
||||
qCDebug(logDbusProperties) << reply.error();
|
||||
} else {
|
||||
qCWarning(logDbusProperties).noquote() << "Error updating property" << propStr;
|
||||
qCWarning(logDbusProperties) << reply.error();
|
||||
}
|
||||
} else {
|
||||
this->tryUpdateProperty(property, reply.value().variant());
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include <qcontainerfwd.h>
|
||||
#include <qdatetime.h>
|
||||
#include <qdbusconnection.h>
|
||||
#include <qdbuserror.h>
|
||||
#include <qdbusextratypes.h>
|
||||
#include <qlist.h>
|
||||
#include <qlogging.h>
|
||||
|
@ -101,41 +102,10 @@ MprisPlayer::MprisPlayer(const QString& address, QObject* parent): QObject(paren
|
|||
|
||||
this->bLengthSupported.setBinding([this]() { return this->bInternalLength != -1; });
|
||||
|
||||
this->bPlaybackState.setBinding([this]() {
|
||||
const auto& status = this->bpPlaybackStatus.value();
|
||||
|
||||
if (status == "Playing") {
|
||||
return MprisPlaybackState::Playing;
|
||||
} else if (status == "Paused") {
|
||||
this->pausedTime = QDateTime::currentDateTimeUtc();
|
||||
return MprisPlaybackState::Paused;
|
||||
} else if (status == "Stopped") {
|
||||
return MprisPlaybackState::Stopped;
|
||||
} else {
|
||||
qWarning() << "Received unexpected PlaybackStatus for" << this << status;
|
||||
return MprisPlaybackState::Stopped;
|
||||
}
|
||||
});
|
||||
|
||||
this->bIsPlaying.setBinding([this]() {
|
||||
return this->bPlaybackState == MprisPlaybackState::Playing;
|
||||
});
|
||||
|
||||
this->bLoopState.setBinding([this]() {
|
||||
const auto& status = this->bpLoopStatus.value();
|
||||
|
||||
if (status == "None") {
|
||||
return MprisLoopState::None;
|
||||
} else if (status == "Track") {
|
||||
return MprisLoopState::Track;
|
||||
} else if (status == "Playlist") {
|
||||
return MprisLoopState::Playlist;
|
||||
} else {
|
||||
qWarning() << "Received unexpected LoopStatus for" << this << status;
|
||||
return MprisLoopState::None;
|
||||
}
|
||||
});
|
||||
|
||||
// clang-format off
|
||||
QObject::connect(this->player, &DBusMprisPlayer::Seeked, this, &MprisPlayer::onSeek);
|
||||
QObject::connect(&this->playerProperties, &DBusPropertyGroup::getAllFinished, this, &MprisPlayer::onGetAllFinished);
|
||||
|
@ -432,18 +402,11 @@ void MprisPlayer::setLoopState(MprisLoopState::Enum loopState) {
|
|||
}
|
||||
|
||||
if (loopState == this->bLoopState) return;
|
||||
|
||||
QString loopStatusStr;
|
||||
switch (loopState) {
|
||||
case MprisLoopState::None: loopStatusStr = "None"; break;
|
||||
case MprisLoopState::Track: loopStatusStr = "Track"; break;
|
||||
case MprisLoopState::Playlist: loopStatusStr = "Playlist"; break;
|
||||
default:
|
||||
if (loopState < MprisLoopState::None || loopState > MprisLoopState::Playlist) {
|
||||
qWarning() << "Cannot set loopState of" << this << "to unknown value" << loopState;
|
||||
return;
|
||||
}
|
||||
|
||||
this->bpLoopStatus = loopStatusStr;
|
||||
this->bLoopState = loopState;
|
||||
this->pLoopStatus.write();
|
||||
}
|
||||
|
||||
|
@ -496,3 +459,47 @@ void MprisPlayer::onGetAllFinished() {
|
|||
}
|
||||
|
||||
} // namespace qs::service::mpris
|
||||
|
||||
namespace qs::dbus {
|
||||
|
||||
using namespace qs::service::mpris;
|
||||
|
||||
DBusResult<MprisPlaybackState::Enum>
|
||||
DBusDataTransform<MprisPlaybackState::Enum>::fromWire(const QString& wire) {
|
||||
if (wire == "Playing") return MprisPlaybackState::Playing;
|
||||
if (wire == "Paused") return MprisPlaybackState::Paused;
|
||||
if (wire == "Stopped") return MprisPlaybackState::Stopped;
|
||||
return QDBusError(QDBusError::InvalidArgs, QString("Invalid MprisPlaybackState: %1").arg(wire));
|
||||
}
|
||||
|
||||
QString DBusDataTransform<MprisPlaybackState::Enum>::toWire(MprisPlaybackState::Enum data) {
|
||||
switch (data) {
|
||||
case MprisPlaybackState::Playing: return "Playing";
|
||||
case MprisPlaybackState::Paused: return "Paused";
|
||||
case MprisPlaybackState::Stopped: return "Stopped";
|
||||
default:
|
||||
qFatal() << "Tried to convert an invalid MprisPlaybackState to String";
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
|
||||
DBusResult<MprisLoopState::Enum>
|
||||
DBusDataTransform<MprisLoopState::Enum>::fromWire(const QString& wire) {
|
||||
if (wire == "None") return MprisLoopState::None;
|
||||
if (wire == "Track") return MprisLoopState::Track;
|
||||
if (wire == "Playlist") return MprisLoopState::Playlist;
|
||||
return QDBusError(QDBusError::InvalidArgs, QString("Invalid MprisLoopState: %1").arg(wire));
|
||||
}
|
||||
|
||||
QString DBusDataTransform<MprisLoopState::Enum>::toWire(MprisLoopState::Enum data) {
|
||||
switch (data) {
|
||||
case MprisLoopState::None: return "None";
|
||||
case MprisLoopState::Track: return "Track";
|
||||
case MprisLoopState::Playlist: return "Playlist";
|
||||
default:
|
||||
qFatal() << "Tried to convert an invalid MprisLoopState to String";
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace qs::dbus
|
||||
|
|
|
@ -51,6 +51,30 @@ public:
|
|||
Q_INVOKABLE static QString toString(qs::service::mpris::MprisLoopState::Enum status);
|
||||
};
|
||||
|
||||
}; // namespace qs::service::mpris
|
||||
|
||||
namespace qs::dbus {
|
||||
|
||||
template <>
|
||||
struct DBusDataTransform<qs::service::mpris::MprisPlaybackState::Enum> {
|
||||
using Wire = QString;
|
||||
using Data = qs::service::mpris::MprisPlaybackState::Enum;
|
||||
static DBusResult<Data> fromWire(const QString& wire);
|
||||
static QString toWire(Data data);
|
||||
};
|
||||
|
||||
template <>
|
||||
struct DBusDataTransform<qs::service::mpris::MprisLoopState::Enum> {
|
||||
using Wire = QString;
|
||||
using Data = qs::service::mpris::MprisLoopState::Enum;
|
||||
static DBusResult<Data> fromWire(const QString& wire);
|
||||
static QString toWire(Data data);
|
||||
};
|
||||
|
||||
}; // namespace qs::dbus
|
||||
|
||||
namespace qs::service::mpris {
|
||||
|
||||
///! A media player exposed over MPRIS.
|
||||
/// A media player exposed over MPRIS.
|
||||
///
|
||||
|
@ -404,13 +428,13 @@ private:
|
|||
|
||||
QS_DBUS_BINDABLE_PROPERTY_GROUP(MprisPlayer, appProperties);
|
||||
QS_DBUS_PROPERTY_BINDING(MprisPlayer, pIdentity, bIdentity, appProperties, "Identity");
|
||||
QS_DBUS_PROPERTY_BINDING(MprisPlayer, pDesktopEntry, bDesktopEntry, appProperties, "DesktopEntry");
|
||||
QS_DBUS_PROPERTY_BINDING(MprisPlayer, pCanQuit, bCanQuit, appProperties, "CanQuit");
|
||||
QS_DBUS_PROPERTY_BINDING(MprisPlayer, pCanRaise, bCanRaise, appProperties, "CanRaise");
|
||||
QS_DBUS_PROPERTY_BINDING(MprisPlayer, pDesktopEntry, bDesktopEntry, appProperties, "DesktopEntry", false);
|
||||
QS_DBUS_PROPERTY_BINDING(MprisPlayer, pCanQuit, bCanQuit, appProperties, "CanQuit", false);
|
||||
QS_DBUS_PROPERTY_BINDING(MprisPlayer, pCanRaise, bCanRaise, appProperties, "CanRaise", false);
|
||||
QS_DBUS_PROPERTY_BINDING(MprisPlayer, pFullscreen, bFullscreen, appProperties, "Fullscreen", false);
|
||||
QS_DBUS_PROPERTY_BINDING(MprisPlayer, pCanSetFullscreen, bCanSetFullscreen, appProperties, "CanSetFullscreen", false);
|
||||
QS_DBUS_PROPERTY_BINDING(MprisPlayer, pSupportedUriSchemes, bSupportedUriSchemes, appProperties, "SupportedUriSchemes");
|
||||
QS_DBUS_PROPERTY_BINDING(MprisPlayer, pSupportedMimeTypes, bSupportedMimeTypes, appProperties, "SupportedMimeTypes");
|
||||
QS_DBUS_PROPERTY_BINDING(MprisPlayer, pSupportedUriSchemes, bSupportedUriSchemes, appProperties, "SupportedUriSchemes", false);
|
||||
QS_DBUS_PROPERTY_BINDING(MprisPlayer, pSupportedMimeTypes, bSupportedMimeTypes, appProperties, "SupportedMimeTypes", false);
|
||||
|
||||
Q_OBJECT_BINDABLE_PROPERTY(MprisPlayer, bool, bpCanPlay);
|
||||
Q_OBJECT_BINDABLE_PROPERTY(MprisPlayer, bool, bpCanPause);
|
||||
|
@ -420,8 +444,6 @@ private:
|
|||
Q_OBJECT_BINDABLE_PROPERTY(MprisPlayer, QVariantMap, bpMetadata);
|
||||
QS_BINDING_SUBSCRIBE_METHOD(MprisPlayer, bpMetadata, onMetadataChanged, onValueChanged);
|
||||
Q_OBJECT_BINDABLE_PROPERTY_WITH_ARGS(MprisPlayer, qlonglong, bpPosition, -1, &MprisPlayer::positionChanged);
|
||||
Q_OBJECT_BINDABLE_PROPERTY(MprisPlayer, QString, bpPlaybackStatus);
|
||||
Q_OBJECT_BINDABLE_PROPERTY(MprisPlayer, QString, bpLoopStatus);
|
||||
|
||||
Q_OBJECT_BINDABLE_PROPERTY(MprisPlayer, bool, bCanControl, &MprisPlayer::canControlChanged);
|
||||
Q_OBJECT_BINDABLE_PROPERTY(MprisPlayer, bool, bCanPlay, &MprisPlayer::canPlayChanged);
|
||||
|
@ -460,8 +482,8 @@ private:
|
|||
QS_DBUS_PROPERTY_BINDING(MprisPlayer, qlonglong, pPosition, bpPosition, onPositionUpdated, playerProperties, "Position", false);
|
||||
QS_DBUS_PROPERTY_BINDING(MprisPlayer, pVolume, bVolume, playerProperties, "Volume", false);
|
||||
QS_DBUS_PROPERTY_BINDING(MprisPlayer, pMetadata, bpMetadata, playerProperties, "Metadata");
|
||||
QS_DBUS_PROPERTY_BINDING(MprisPlayer, void, pPlaybackStatus, bpPlaybackStatus, onPlaybackStatusUpdated, playerProperties, "PlaybackStatus", true);
|
||||
QS_DBUS_PROPERTY_BINDING(MprisPlayer, pLoopStatus, bpLoopStatus, playerProperties, "LoopStatus", false);
|
||||
QS_DBUS_PROPERTY_BINDING(MprisPlayer, void, pPlaybackStatus, bPlaybackState, onPlaybackStatusUpdated, playerProperties, "PlaybackStatus", true);
|
||||
QS_DBUS_PROPERTY_BINDING(MprisPlayer, pLoopStatus, bLoopState, playerProperties, "LoopStatus", false);
|
||||
QS_DBUS_PROPERTY_BINDING(MprisPlayer, pRate, bRate, playerProperties, "Rate", false);
|
||||
QS_DBUS_PROPERTY_BINDING(MprisPlayer, pMinRate, bMinRate, playerProperties, "MinimumRate", false);
|
||||
QS_DBUS_PROPERTY_BINDING(MprisPlayer, pMaxRate, bMaxRate, playerProperties, "MaximumRate", false);
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
namespace qs::service::notifications {
|
||||
|
||||
// NOLINTNEXTLINE(misc-use-internal-linkage)
|
||||
QS_LOGGING_CATEGORY(logNotifications, "quickshell.service.notifications");
|
||||
QS_LOGGING_CATEGORY(logNotifications, "quickshell.service.notifications", QtWarningMsg);
|
||||
|
||||
NotificationServer::NotificationServer() {
|
||||
qDBusRegisterMetaType<DBusNotificationImage>();
|
||||
|
|
|
@ -222,9 +222,14 @@ void StatusNotifierItem::activate() {
|
|||
const QDBusPendingReply<> reply = *call;
|
||||
|
||||
if (reply.isError()) {
|
||||
qCWarning(logStatusNotifierItem).noquote()
|
||||
<< "Error calling Activate method of StatusNotifierItem" << this->properties.toString();
|
||||
qCWarning(logStatusNotifierItem) << reply.error();
|
||||
if (reply.error().type() == QDBusError::UnknownMethod) {
|
||||
qCDebug(logStatusNotifierItem) << "Tried to call Activate method of StatusNotifierItem"
|
||||
<< this->properties.toString() << "but it does not exist.";
|
||||
} else {
|
||||
qCWarning(logStatusNotifierItem).noquote()
|
||||
<< "Error calling Activate method of StatusNotifierItem" << this->properties.toString();
|
||||
qCWarning(logStatusNotifierItem) << reply.error();
|
||||
}
|
||||
}
|
||||
|
||||
delete call;
|
||||
|
@ -241,10 +246,16 @@ void StatusNotifierItem::secondaryActivate() {
|
|||
const QDBusPendingReply<> reply = *call;
|
||||
|
||||
if (reply.isError()) {
|
||||
qCWarning(logStatusNotifierItem).noquote()
|
||||
<< "Error calling SecondaryActivate method of StatusNotifierItem"
|
||||
<< this->properties.toString();
|
||||
qCWarning(logStatusNotifierItem) << reply.error();
|
||||
if (reply.error().type() == QDBusError::UnknownMethod) {
|
||||
qCDebug(logStatusNotifierItem)
|
||||
<< "Tried to call SecondaryActivate method of StatusNotifierItem"
|
||||
<< this->properties.toString() << "but it does not exist.";
|
||||
} else {
|
||||
qCWarning(logStatusNotifierItem).noquote()
|
||||
<< "Error calling SecondaryActivate method of StatusNotifierItem"
|
||||
<< this->properties.toString();
|
||||
qCWarning(logStatusNotifierItem) << reply.error();
|
||||
}
|
||||
}
|
||||
|
||||
delete call;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue