Debian Codegraph @

src/dbus/NhekoDBusApi.h

raw symbols SCIP
1 // SPDX-FileCopyrightText: Nheko Contributors
2 //
3 // SPDX-License-Identifier: GPL-3.0-or-later
4
5 #pragma once
6
7 #include <QDBusArgument>
8 #include <QIcon>
9 #include <QObject>
10 #include <QVersionNumber>
11
12 namespace nheko::dbus {
13
14 //! Registers all necessary classes with D-Bus. Call this before using any nheko D-Bus classes.
15 void
16 init();
17
18 //! The nheko D-Bus API version provided by this file. The API version number follows semantic
19 //! versioning as defined by https://semver.org.
20 inline const QVersionNumber dbusApiVersion{1, 0, 1};
21
22 //! Compare the installed Nheko API to the version that your client app targets to see if they
23 //! are compatible.
24 bool
25 apiVersionIsCompatible(const QVersionNumber &clientAppVersion);
26
27 class RoomInfoItem final : public QObject
28 {
29 Q_OBJECT
30
31 public:
32 RoomInfoItem(const QString &roomId = QString{},
33 const QString &alias = QString{},
34 const QString &title = QString{},
35 const QString &avatarUrl = QString{},
36 const int unreadNotifications = 0,
37 QObject *parent = nullptr);
38
39 RoomInfoItem(const RoomInfoItem &other);
40
41 const QString &roomId() const { return roomId_; }
42 const QString &alias() const { return alias_; }
43 const QString &roomName() const { return roomName_; }
44 const QString &avatarUrl() const { return avatarUrl_; }
45 int unreadNotifications() const { return unreadNotifications_; }
46
47 RoomInfoItem &operator=(const RoomInfoItem &other);
48 friend QDBusArgument &operator<<(QDBusArgument &arg, const nheko::dbus::RoomInfoItem &item);
49 friend const QDBusArgument &
50 operator>>(const QDBusArgument &arg, nheko::dbus::RoomInfoItem &item);
51
52 private:
53 QString roomId_;
54 QString alias_;
55 QString roomName_;
56 QString avatarUrl_;
57 int unreadNotifications_;
58 };
59
60 //! Get the nheko D-Bus API version.
61 QString
62 apiVersion();
63 //! Get the nheko version.
64 QString
65 nhekoVersion();
66 //! Call this function to get a list of all joined rooms.
67 QVector<RoomInfoItem>
68 rooms();
69 //! Fetch an image using a matrix URI
70 QImage
71 image(const QString &uri);
72 //! Activates a currently joined room.
73 void
74 activateRoom(const QString &alias);
75 //! Joins a room. It is your responsibility to ask for confirmation (if desired).
76 void
77 joinRoom(const QString &alias);
78 //! Starts or activates a direct chat. It is your responsibility to ask for confirmation (if
79 //! desired).
80 void
81 directChat(const QString &userId);
82 //! Get the user's status message.
83 QString
84 statusMessage();
85 //! Sets the user's status message (if supported by the homeserver).
86 void
87 setStatusMessage(const QString &message);
88
89 QDBusArgument &
90 operator<<(QDBusArgument &arg, const RoomInfoItem &item);
91 const QDBusArgument &
92 operator>>(const QDBusArgument &arg, RoomInfoItem &item);
93 } // nheko::dbus
94
95 QDBusArgument &
96 operator<<(QDBusArgument &arg, const QImage &image);
97 const QDBusArgument &
98 operator>>(const QDBusArgument &arg, QImage &);
99
100 #define NHEKO_DBUS_SERVICE_NAME "im.nheko.Nheko"