Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:aualin:kde
kdebase3
udisks2-unmount.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File udisks2-unmount.patch of Package kdebase3
From 1ed5b7be04c8290f8b1b30295ffcb997afdc740f Mon Sep 17 00:00:00 2001 From: Serghei Amelian <serghei.amelian@gmail.com> Date: Mon, 4 Jun 2012 23:55:01 +0300 Subject: [PATCH] [mediamanger/udisks2] unmount the filesystem if the media is removed --- kioslave/media/mediamanager/udisks2backend.cpp | 72 ++++++++++++++++-------- 1 file changed, 48 insertions(+), 24 deletions(-) diff --git a/kioslave/media/mediamanager/udisks2backend.cpp b/kioslave/media/mediamanager/udisks2backend.cpp index b66bea4..bb82f24 100644 --- a/kioslave/media/mediamanager/udisks2backend.cpp +++ b/kioslave/media/mediamanager/udisks2backend.cpp @@ -66,6 +66,9 @@ class Object : public QDBusProxy { Object(ObjectManager *objectManager, const QDBusObjectPath &objectPath, const QDBusConnection &dbusConnection); ~Object(); + QString mount(); + QString unmount(bool force); + bool isEmpty() const { return m_interfaces.isEmpty(); } void addInterfaces(const QDBusDataMap<QString> &interfaces); @@ -249,6 +252,47 @@ QDBusObjectPath Property::toObjectPath() const } +QString Object::mount() +{ + QMap<QString, QDBusVariant> options; + + QValueList<QDBusData> params; + params << QDBusData::fromStringKeyMap(QDBusDataMap<QString>(options)); + + QDBusError error; + QDBusData response; + + if(!callMethod("org.freedesktop.UDisks2.Filesystem", "Mount", params, response, error)) + return i18n("Unable to mount \"%1\".\nReason: %2").arg(m_device).arg(error.message()); + + return QString::null; +} + + +QString Object::unmount(bool force) +{ + QMap<QString, QDBusVariant> options; + + if(force) { + QDBusVariant force; + force.value = QDBusData::fromBool(true); + force.signature = force.value.buildDBusSignature(); + options["force"] = force; + } + + QValueList<QDBusData> params; + params << QDBusData::fromStringKeyMap(QDBusDataMap<QString>(options)); + + QDBusError error; + QDBusData response; + + if(!callMethod("org.freedesktop.UDisks2.Filesystem", "Unmount", params, response, error)) + return i18n("Unable to unmount \"%1\".\nReason: %2").arg(m_device).arg(error.message()); + + return QString::null; +} + + void Object::addInterfaces(const QDBusDataMap<QString> &interfaces) { for(QDBusDataMap<QString>::const_iterator it = interfaces.begin(); it != interfaces.end(); ++it) { @@ -423,6 +467,8 @@ bool Object::checkMediaAvailability() // media is not available anymore else { m_objectManager->m_mediaList.removeMedium(path(), true); + if(m_mounted) + unmount(true); } m_mediaAvailable = mediaAvailable; @@ -651,18 +697,7 @@ QString UDisks2Backend::mount(const QString &name) if(!obj) return i18n("No such udisks2 object in cache: %1").arg(name); - QMap<QString, QDBusVariant> options; - - QValueList<QDBusData> params; - params << QDBusData::fromStringKeyMap(QDBusDataMap<QString>(options)); - - QDBusError error; - QDBusData response; - - if(!obj->callMethod("org.freedesktop.UDisks2.Filesystem", "Mount", params, response, error)) - return i18n("Unable to mount medium \"%1\".\nReason: %2").arg(medium->label()).arg(error.message()); - - return QString::null; + return obj->mount(); } @@ -676,16 +711,5 @@ QString UDisks2Backend::unmount(const QString &name) if(!obj) return i18n("No such udisks2 object in cache: %1").arg(name); - QMap<QString, QDBusVariant> options; - - QValueList<QDBusData> params; - params << QDBusData::fromStringKeyMap(QDBusDataMap<QString>(options)); - - QDBusError error; - QDBusData response; - - if(!obj->callMethod("org.freedesktop.UDisks2.Filesystem", "Unmount", params, response, error)) - return i18n("Unable to unmount medium \"%1\".\nReason: %2").arg(medium->label()).arg(error.message()); - - return QString::null; + return obj->unmount(false); } -- 1.7.10
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor