2023-02-22 01:48:49 +03:00
|
|
|
// SPDX-FileCopyrightText: Nheko Contributors
|
2022-04-14 18:02:55 +03:00
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
|
|
|
#ifndef NHEKODBUSAPI_H
|
|
|
|
#define NHEKODBUSAPI_H
|
|
|
|
|
|
|
|
#include <QDBusArgument>
|
|
|
|
#include <QIcon>
|
|
|
|
#include <QObject>
|
|
|
|
#include <QVersionNumber>
|
|
|
|
|
|
|
|
namespace nheko::dbus {
|
|
|
|
|
|
|
|
//! Registers all necessary classes with D-Bus. Call this before using any nheko D-Bus classes.
|
|
|
|
void
|
|
|
|
init();
|
|
|
|
|
|
|
|
//! The nheko D-Bus API version provided by this file. The API version number follows semantic
|
|
|
|
//! versioning as defined by https://semver.org.
|
2023-02-20 01:17:21 +03:00
|
|
|
inline const QVersionNumber dbusApiVersion{1, 0, 1};
|
2022-04-14 18:02:55 +03:00
|
|
|
|
|
|
|
//! Compare the installed Nheko API to the version that your client app targets to see if they
|
|
|
|
//! are compatible.
|
|
|
|
bool
|
|
|
|
apiVersionIsCompatible(const QVersionNumber &clientAppVersion);
|
|
|
|
|
2022-10-10 15:38:29 +03:00
|
|
|
class RoomInfoItem final : public QObject
|
2022-04-14 18:02:55 +03:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
RoomInfoItem(const QString &roomId = QString{},
|
|
|
|
const QString &alias = QString{},
|
|
|
|
const QString &title = QString{},
|
2022-10-09 01:56:02 +03:00
|
|
|
const QString &avatarUrl = QString{},
|
2022-04-14 18:02:55 +03:00
|
|
|
const int unreadNotifications = 0,
|
|
|
|
QObject *parent = nullptr);
|
|
|
|
|
|
|
|
RoomInfoItem(const RoomInfoItem &other);
|
|
|
|
|
|
|
|
const QString &roomId() const { return roomId_; }
|
|
|
|
const QString &alias() const { return alias_; }
|
|
|
|
const QString &roomName() const { return roomName_; }
|
2022-10-09 01:56:02 +03:00
|
|
|
const QString &avatarUrl() const { return avatarUrl_; }
|
2022-04-14 18:02:55 +03:00
|
|
|
int unreadNotifications() const { return unreadNotifications_; }
|
|
|
|
|
|
|
|
RoomInfoItem &operator=(const RoomInfoItem &other);
|
|
|
|
friend QDBusArgument &operator<<(QDBusArgument &arg, const nheko::dbus::RoomInfoItem &item);
|
|
|
|
friend const QDBusArgument &
|
|
|
|
operator>>(const QDBusArgument &arg, nheko::dbus::RoomInfoItem &item);
|
|
|
|
|
|
|
|
private:
|
|
|
|
QString roomId_;
|
|
|
|
QString alias_;
|
|
|
|
QString roomName_;
|
2022-10-09 01:56:02 +03:00
|
|
|
QString avatarUrl_;
|
2022-04-14 18:02:55 +03:00
|
|
|
int unreadNotifications_;
|
|
|
|
};
|
|
|
|
|
2022-04-18 19:50:15 +03:00
|
|
|
//! Get the nheko D-Bus API version.
|
|
|
|
QString
|
|
|
|
apiVersion();
|
|
|
|
//! Get the nheko version.
|
|
|
|
QString
|
|
|
|
nhekoVersion();
|
|
|
|
//! Call this function to get a list of all joined rooms.
|
|
|
|
QVector<RoomInfoItem>
|
|
|
|
rooms();
|
2022-10-09 01:56:02 +03:00
|
|
|
//! Fetch an image using a matrix URI
|
|
|
|
QImage
|
|
|
|
image(const QString &uri);
|
2022-04-18 19:50:15 +03:00
|
|
|
//! Activates a currently joined room.
|
|
|
|
void
|
|
|
|
activateRoom(const QString &alias);
|
|
|
|
//! Joins a room. It is your responsibility to ask for confirmation (if desired).
|
|
|
|
void
|
|
|
|
joinRoom(const QString &alias);
|
|
|
|
//! Starts or activates a direct chat. It is your responsibility to ask for confirmation (if
|
|
|
|
//! desired).
|
|
|
|
void
|
|
|
|
directChat(const QString &userId);
|
2023-03-31 02:59:56 +03:00
|
|
|
//! Get the user's status message.
|
|
|
|
QString
|
|
|
|
statusMessage();
|
2022-11-05 20:13:18 +03:00
|
|
|
//! Sets the user's status message (if supported by the homeserver).
|
|
|
|
void
|
|
|
|
setStatusMessage(const QString &message);
|
2022-04-18 19:50:15 +03:00
|
|
|
|
2022-04-14 18:02:55 +03:00
|
|
|
QDBusArgument &
|
|
|
|
operator<<(QDBusArgument &arg, const RoomInfoItem &item);
|
|
|
|
const QDBusArgument &
|
|
|
|
operator>>(const QDBusArgument &arg, RoomInfoItem &item);
|
|
|
|
} // nheko::dbus
|
|
|
|
|
|
|
|
QDBusArgument &
|
|
|
|
operator<<(QDBusArgument &arg, const QImage &image);
|
|
|
|
const QDBusArgument &
|
|
|
|
operator>>(const QDBusArgument &arg, QImage &);
|
|
|
|
|
2022-04-14 18:33:28 +03:00
|
|
|
#define NHEKO_DBUS_SERVICE_NAME "im.nheko.Nheko"
|
2022-04-14 18:02:55 +03:00
|
|
|
|
|
|
|
#endif // NHEKODBUSAPI_H
|