From de3cdd590f4b8646a7b541c35a3412c383753553 Mon Sep 17 00:00:00 2001 From: Loren Burkholder Date: Sat, 5 Nov 2022 13:13:18 -0400 Subject: [PATCH] Add status message to D-Bus API --- src/dbus/NhekoDBusApi.cpp | 9 +++++++++ src/dbus/NhekoDBusApi.h | 3 +++ src/dbus/NhekoDBusBackend.cpp | 6 ++++++ src/dbus/NhekoDBusBackend.h | 2 ++ 4 files changed, 20 insertions(+) diff --git a/src/dbus/NhekoDBusApi.cpp b/src/dbus/NhekoDBusApi.cpp index 2367c27b..a58812ef 100644 --- a/src/dbus/NhekoDBusApi.cpp +++ b/src/dbus/NhekoDBusApi.cpp @@ -152,6 +152,15 @@ directChat(const QString &userId) interface.isValid()) interface.call(QDBus::NoBlock, QStringLiteral("directChat"), userId); } + +void +setStatusMessage(const QString &message) +{ + if (QDBusInterface interface{QStringLiteral(NHEKO_DBUS_SERVICE_NAME), QStringLiteral("/")}; + interface.isValid()) + interface.call(QDBus::NoBlock, QStringLiteral("setStatusMessage"), message); +} + } // nheko::dbus /** diff --git a/src/dbus/NhekoDBusApi.h b/src/dbus/NhekoDBusApi.h index 3995404a..20316b64 100644 --- a/src/dbus/NhekoDBusApi.h +++ b/src/dbus/NhekoDBusApi.h @@ -80,6 +80,9 @@ joinRoom(const QString &alias); //! desired). void directChat(const QString &userId); +//! Sets the user's status message (if supported by the homeserver). +void +setStatusMessage(const QString &message); QDBusArgument & operator<<(QDBusArgument &arg, const RoomInfoItem &item); diff --git a/src/dbus/NhekoDBusBackend.cpp b/src/dbus/NhekoDBusBackend.cpp index 56fdfe8d..a7fa2d74 100644 --- a/src/dbus/NhekoDBusBackend.cpp +++ b/src/dbus/NhekoDBusBackend.cpp @@ -100,6 +100,12 @@ NhekoDBusBackend::directChat(const QString &userId) const ChatPage::instance()->startChat(userId); } +void +NhekoDBusBackend::setStatusMessage(const QString &message) +{ + ChatPage::instance()->setStatus(message); +} + void NhekoDBusBackend::bringWindowToTop() const { diff --git a/src/dbus/NhekoDBusBackend.h b/src/dbus/NhekoDBusBackend.h index 6fb9dd72..83562da2 100644 --- a/src/dbus/NhekoDBusBackend.h +++ b/src/dbus/NhekoDBusBackend.h @@ -37,6 +37,8 @@ public slots: //! Starts or activates a direct chat. It is your responsibility to ask for confirmation (if //! desired). Q_SCRIPTABLE void directChat(const QString &userId) const; + //! Sets the user's status message. + Q_SCRIPTABLE void setStatusMessage(const QString &message); private: void bringWindowToTop() const;