diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -56,6 +56,10 @@ qt5_add_dbus_interface(elisaLib_SOURCES ${BALOO_DBUS_INTERFACES_DIR}/org.kde.baloo.scheduler.xml baloo/scheduler) + + qt5_add_dbus_adaptor(elisaLib_SOURCES + ${BALOO_DBUS_INTERFACES_DIR}/org.kde.BalooWatcherApplication.xml + baloo/localbaloofilelisting.h LocalBalooFileListing) endif() endif() diff --git a/src/baloo/localbaloofilelisting.cpp b/src/baloo/localbaloofilelisting.cpp --- a/src/baloo/localbaloofilelisting.cpp +++ b/src/baloo/localbaloofilelisting.cpp @@ -27,6 +27,8 @@ #include "baloo/scheduler.h" #include "baloo/fileindexer.h" +#include "baloowatcherapplicationadaptor.h" + #include #include #include @@ -69,6 +71,8 @@ QAtomicInt mStopRequest = 0; + BalooWatcherApplicationAdaptor *mDbusAdaptor = nullptr; + bool mIsRegistered = false; bool mIsRegistering = false; @@ -83,6 +87,10 @@ auto sessionBus = QDBusConnection::sessionBus(); + d->mDbusAdaptor = new BalooWatcherApplicationAdaptor(this); + + sessionBus.registerObject(QStringLiteral("/org/kde/BalooWatcherApplication"), d->mDbusAdaptor, QDBusConnection::ExportAllContents); + connect(&d->mServiceWatcher, &QDBusServiceWatcher::serviceRegistered, this, &LocalBalooFileListing::serviceRegistered); connect(&d->mServiceWatcher, &QDBusServiceWatcher::serviceOwnerChanged, @@ -190,6 +198,22 @@ if (pendingCallWatcher->isFinished()) { registeredToBaloo(pendingCallWatcher); } + + QDBusMessage registerBalooWatcher = QDBusMessage::createMethodCall(QStringLiteral("org.kde.baloo"), + QStringLiteral("/"), + QStringLiteral("org.kde.baloo.main"), + QStringLiteral("registerBalooWatcher")); + + registerBalooWatcher.setArguments({QStringLiteral("org.mpris.MediaPlayer2.elisa/org/kde/BalooWatcherApplication")}); + + auto pendingCall = sessionBus.asyncCall(registerBalooWatcher); + qDebug() << "LocalBalooFileListing::registerToBaloo" << "call registerBalooWatcher"; + auto pendingCallWatcher2 = new QDBusPendingCallWatcher(pendingCall); + + connect(pendingCallWatcher2, &QDBusPendingCallWatcher::finished, this, &LocalBalooFileListing::registeredToBaloo); + if (pendingCallWatcher2->isFinished()) { + registeredToBaloo(pendingCallWatcher2); + } } void LocalBalooFileListing::renamedFiles(const QString &from, const QString &to, const QStringList &listFiles)