matrixion/src/dbus/NhekoDBusBackend.h
Loren Burkholder da6b3eb8f4
D-Bus fixes (#1048)
According to LorenDB's First Law of Software Development, once a developer has committed or merged a new feature, he will find at least one problem with the implementation.

I realized that I was constructing the room info items with some parameters out of order, which required a rather urgent fix. Furthermore, I fixed the image decoding algorithms in the QDBusArgument operator. Finally, I switched the API version parameter back to QString, since passing it as a QVersionNumber would create a problem for non-Qt API users.

On the general improvements side of things, I added some handy wrappers for D-Bus calls so that other devs that copy the NhekoDBusApi files to use for their own applications won't have to go to the effort of making the D-Bus calls themselves.
2022-04-18 16:50:15 +00:00

45 lines
1.3 KiB
C++

// SPDX-FileCopyrightText: 2022 Nheko Contributors
//
// SPDX-License-Identifier: GPL-3.0-or-later
#ifndef NHEKODBUSBACKEND_H
#define NHEKODBUSBACKEND_H
#include <QDBusMessage>
#include <QObject>
#include "NhekoDBusApi.h"
#include "config/nheko.h"
class RoomlistModel;
class NhekoDBusBackend : public QObject
{
Q_OBJECT
Q_CLASSINFO("D-Bus Interface", "im.nheko.Nheko")
public:
NhekoDBusBackend(RoomlistModel *parent);
public slots:
//! Get the nheko D-Bus API version.
Q_SCRIPTABLE QString apiVersion() const { return nheko::dbus::dbusApiVersion.toString(); }
//! Get the nheko version.
Q_SCRIPTABLE QString nhekoVersion() const { return nheko::version; }
//! Call this function to get a list of all joined rooms.
Q_SCRIPTABLE QVector<nheko::dbus::RoomInfoItem> rooms(const QDBusMessage &message);
//! Activates a currently joined room.
Q_SCRIPTABLE void activateRoom(const QString &alias) const;
//! Joins a room. It is your responsibility to ask for confirmation (if desired).
Q_SCRIPTABLE void joinRoom(const QString &alias) const;
//! Starts or activates a direct chat. It is your responsibility to ask for confirmation (if
//! desired).
Q_SCRIPTABLE void directChat(const QString &userId) const;
private:
void bringWindowToTop() const;
RoomlistModel *m_parent;
};
#endif // NHEKODBUSBACKEND_H