summary refs log tree commit diff
path: root/src/timeline
diff options
context:
space:
mode:
authorLoren Burkholder <55629213+LorenDB@users.noreply.github.com>2022-04-14 11:02:55 -0400
committerGitHub <noreply@github.com>2022-04-14 15:02:55 +0000
commit686ebfdbecbcacdbdba6c6289f22479c2fe5133e (patch)
treeef4124f0ad74d78612555160bfd556a8e98d068b /src/timeline
parentTranslated using Weblate (Finnish) (diff)
downloadnheko-686ebfdbecbcacdbdba6c6289f22479c2fe5133e.tar.xz
Add D-Bus API (#916)
This adds functionality for viewing joined rooms and activating rooms.
Diffstat (limited to 'src/timeline')
-rw-r--r--src/timeline/RoomlistModel.cpp13
-rw-r--r--src/timeline/RoomlistModel.h9
2 files changed, 22 insertions, 0 deletions
diff --git a/src/timeline/RoomlistModel.cpp b/src/timeline/RoomlistModel.cpp

index 31e5a33d..ea4f6fa8 100644 --- a/src/timeline/RoomlistModel.cpp +++ b/src/timeline/RoomlistModel.cpp
@@ -15,6 +15,10 @@ #include "TimelineViewManager.h" #include "UserSettingsPage.h" +#ifdef NHEKO_DBUS_SYS +#include <QDBusConnection> +#endif + RoomlistModel::RoomlistModel(TimelineViewManager *parent) : QAbstractListModel(parent) , manager(parent) @@ -604,6 +608,15 @@ RoomlistModel::initializeRooms() nhlog::db()->info("Restored {} rooms from cache", rowCount()); endResetModel(); + +#ifdef NHEKO_DBUS_SYS + if (MainWindow::instance()->dbusAvailable()) { + dbusInterface_ = new NhekoDBusBackend{this}; + if (!QDBusConnection::sessionBus().registerObject( + "/", dbusInterface_, QDBusConnection::ExportScriptableSlots)) + nhlog::ui()->warn("Failed to register rooms with D-Bus"); + } +#endif } void diff --git a/src/timeline/RoomlistModel.h b/src/timeline/RoomlistModel.h
index 73ccd929..9546d434 100644 --- a/src/timeline/RoomlistModel.h +++ b/src/timeline/RoomlistModel.h
@@ -17,6 +17,10 @@ #include "TimelineModel.h" +#ifdef NHEKO_DBUS_SYS +#include "dbus/NhekoDBusBackend.h" +#endif + class TimelineViewManager; class RoomPreview @@ -138,6 +142,11 @@ private: std::map<QString, std::vector<QString>> directChatToUser; +#ifdef NHEKO_DBUS_SYS + NhekoDBusBackend *dbusInterface_; + friend class NhekoDBusBackend; +#endif + friend class FilteredRoomlistModel; };