Allow querying your status message over dbus

Contributed by a Nheko user starting with S.
This commit is contained in:
Nicolas Werner 2023-03-31 01:59:56 +02:00
parent 164de9c21c
commit 5557b949e1
No known key found for this signature in database
GPG key ID: C8D75E610773F2D9
4 changed files with 21 additions and 0 deletions

View file

@ -152,6 +152,16 @@ directChat(const QString &userId)
interface.call(QDBus::NoBlock, QStringLiteral("directChat"), 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 void
setStatusMessage(const QString &message) setStatusMessage(const QString &message)
{ {

View file

@ -80,6 +80,9 @@ joinRoom(const QString &alias);
//! desired). //! desired).
void void
directChat(const QString &userId); directChat(const QString &userId);
//! Get the user's status message.
QString
statusMessage();
//! Sets the user's status message (if supported by the homeserver). //! Sets the user's status message (if supported by the homeserver).
void void
setStatusMessage(const QString &message); setStatusMessage(const QString &message);

View file

@ -100,6 +100,12 @@ NhekoDBusBackend::directChat(const QString &userId) const
ChatPage::instance()->startChat(userId); ChatPage::instance()->startChat(userId);
} }
QString
NhekoDBusBackend::statusMessage() const
{
return ChatPage::instance()->status();
}
void void
NhekoDBusBackend::setStatusMessage(const QString &message) NhekoDBusBackend::setStatusMessage(const QString &message)
{ {

View file

@ -37,6 +37,8 @@ public slots:
//! Starts or activates a direct chat. It is your responsibility to ask for confirmation (if //! Starts or activates a direct chat. It is your responsibility to ask for confirmation (if
//! desired). //! desired).
Q_SCRIPTABLE void directChat(const QString &userId) const; 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. //! Sets the user's status message.
Q_SCRIPTABLE void setStatusMessage(const QString &message); Q_SCRIPTABLE void setStatusMessage(const QString &message);