Commit c8973942 authored by Fabian Vogt's avatar Fabian Vogt

Quit when the DBus connection is lost

This avoids having an unreachable kio-fuse daemon around.
parent 711c7c37
......@@ -89,6 +89,12 @@ QString KIOFuseService::remoteUrl(const QString& localPath)
return remoteUrl.toString(QUrl::RemovePassword);
}
void KIOFuseService::dbusDisconnected()
{
qInfo(KIOFUSE_LOG) << "DBus disconnected - stopping.";
kiofusevfs.stop();
}
QString KIOFuseService::mountUrl(const QString& remoteUrl, const QDBusMessage& message)
{
message.setDelayedReply(true);
......@@ -124,9 +130,15 @@ QString KIOFuseService::mountUrl(const QString& remoteUrl, const QDBusMessage& m
bool KIOFuseService::registerService()
{
return QDBusConnection::sessionBus().registerObject(QStringLiteral("/org/kde/KIOFuse"), this,
if(QDBusConnection::sessionBus().registerObject(QStringLiteral("/org/kde/KIOFuse"), this,
QDBusConnection::ExportAllSlots | QDBusConnection::ExportAdaptors)
&& QDBusConnection::sessionBus().registerService(QStringLiteral("org.kde.KIOFuse"));
&& QDBusConnection::sessionBus().registerService(QStringLiteral("org.kde.KIOFuse")))
{
QDBusConnection::sessionBus().connect({}, QStringLiteral("/org/freedesktop/DBus/Local"), QStringLiteral("org.freedesktop.DBus.Local"), QStringLiteral("Disconnected"), this, SLOT(dbusDisconnected()));
return true;
}
return false;
}
bool KIOFuseService::registerServiceDaemonized()
......
......@@ -47,6 +47,10 @@ public Q_SLOTS:
/** Converts a local path into a remote URL if it is mounted within the VFS */
QString remoteUrl(const QString &localPath);
private Q_SLOTS:
/** Stops the VFS when the DBus connection is lost. */
void dbusDisconnected();
private:
/** Registers the kio-fuse process as the org.kde.KIOFuse service.
* Returns false if this fails (otherwise you can't communicate with the process), true otherwise.*/
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment