summary refs log tree commit diff
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2023-03-31 01:59:56 +0200
committerNicolas Werner <nicolas.werner@hotmail.de>2023-03-31 01:59:56 +0200
commit5557b949e1a96b0482efb713292fcd9e9694f499 (patch)
tree39e3e60e808e1c57e296fb556a177fe418bc6958
parentAllow for # in fragments because some clients send matrix.to links like that (diff)
downloadnheko-5557b949e1a96b0482efb713292fcd9e9694f499.tar.xz
Allow querying your status message over dbus
Contributed by a Nheko user starting with S.
-rw-r--r--src/dbus/NhekoDBusApi.cpp10
-rw-r--r--src/dbus/NhekoDBusApi.h3
-rw-r--r--src/dbus/NhekoDBusBackend.cpp6
-rw-r--r--src/dbus/NhekoDBusBackend.h2
4 files changed, 21 insertions, 0 deletions
diff --git a/src/dbus/NhekoDBusApi.cpp b/src/dbus/NhekoDBusApi.cpp
index a669238c..a613b610 100644
--- a/src/dbus/NhekoDBusApi.cpp
+++ b/src/dbus/NhekoDBusApi.cpp
@@ -152,6 +152,16 @@ directChat(const QString &userId)
         interface.call(QDBus::NoBlock, QStringLiteral("directChat"), userId);
 }
 
+QString
+statusMessage()
+{
+    if (QDBusInterface interface{QStringLiteral(NHEKO_DBUS_SERVICE_NAME), QStringLiteral("/")};
+        interface.isValid())
+        return QDBusReply<QString>{interface.call(QStringLiteral("statusMessage"))}.value();
+    else
+        return {};
+}
+
 void
 setStatusMessage(const QString &message)
 {
diff --git a/src/dbus/NhekoDBusApi.h b/src/dbus/NhekoDBusApi.h
index 78bd9fbb..5a34f0b7 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);
+//! Get the user's status message.
+QString
+statusMessage();
 //! Sets the user's status message (if supported by the homeserver).
 void
 setStatusMessage(const QString &message);
diff --git a/src/dbus/NhekoDBusBackend.cpp b/src/dbus/NhekoDBusBackend.cpp
index 46ba7ab1..9690cdfa 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);
 }
 
+QString
+NhekoDBusBackend::statusMessage() const
+{
+    return ChatPage::instance()->status();
+}
+
 void
 NhekoDBusBackend::setStatusMessage(const QString &message)
 {
diff --git a/src/dbus/NhekoDBusBackend.h b/src/dbus/NhekoDBusBackend.h
index e07e09f0..e1b5fabb 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;
+    //! Gets the user's status message.
+    Q_SCRIPTABLE QString statusMessage() const;
     //! Sets the user's status message.
     Q_SCRIPTABLE void setStatusMessage(const QString &message);