From b54aa3a731733709ef376bb8851e936641bc4517 Mon Sep 17 00:00:00 2001 From: Lukas Tinkl Date: Wed, 27 Jun 2012 18:11:24 +0200 Subject: [PATCH] respin the udisks2 backend patch - Resolves #835107 - Unable to eject optical media using "Device notifier" --- kdelibs-udisks2-backend.patch | 94 +++++++++++++++++++++++------------ kdelibs.spec | 10 ++-- 2 files changed, 68 insertions(+), 36 deletions(-) diff --git a/kdelibs-udisks2-backend.patch b/kdelibs-udisks2-backend.patch index 6254efc..7489a93 100644 --- a/kdelibs-udisks2-backend.patch +++ b/kdelibs-udisks2-backend.patch @@ -207,7 +207,7 @@ index 0000000..25a1dc0 +#endif // SOLID_BACKENDS_UDISKS2_H diff --git a/tier1/solid/src/solid/backends/udisks2/udisksblock.cpp b/tier1/solid/src/solid/backends/udisks2/udisksblock.cpp new file mode 100644 -index 0000000..c27b1c4 +index 0000000..474f3d6 --- /dev/null +++ b/tier1/solid/src/solid/backends/udisks2/udisksblock.cpp @@ -0,0 +1,84 @@ @@ -274,7 +274,7 @@ index 0000000..c27b1c4 + } + } + -+ qDebug() << "devnum:" << m_devNum << "dev file:" << m_devFile; ++ //qDebug() << "devnum:" << m_devNum << "dev file:" << m_devFile; +} + +Block::~Block() @@ -1708,7 +1708,7 @@ index 0000000..d225f32 +#endif // SOLID_BACKENDS_UDISKS2_GENERICINTERFACE_H diff --git a/tier1/solid/src/solid/backends/udisks2/udisksmanager.cpp b/tier1/solid/src/solid/backends/udisks2/udisksmanager.cpp new file mode 100644 -index 0000000..9af8ee2 +index 0000000..0a77c16 --- /dev/null +++ b/tier1/solid/src/solid/backends/udisks2/udisksmanager.cpp @@ -0,0 +1,227 @@ @@ -1848,7 +1848,7 @@ index 0000000..9af8ee2 + + Q_FOREACH(const QDBusObjectPath &path, reply.value().keys()) { + const QString udi = path.path(); -+ qDebug() << "Adding device" << udi; ++ //qDebug() << "Adding device" << udi; + + if (udi == UD2_DBUS_PATH_MANAGER || udi == UD2_UDI_DISKS_PREFIX || udi.startsWith(UD2_DBUS_PATH_JOBS)) + continue; @@ -2374,10 +2374,10 @@ index 0000000..5b80995 +#endif // UDISKS2OPTICALDISC_H diff --git a/tier1/solid/src/solid/backends/udisks2/udisksopticaldrive.cpp b/tier1/solid/src/solid/backends/udisks2/udisksopticaldrive.cpp new file mode 100644 -index 0000000..0eb4685 +index 0000000..f4351a7 --- /dev/null +++ b/tier1/solid/src/solid/backends/udisks2/udisksopticaldrive.cpp -@@ -0,0 +1,188 @@ +@@ -0,0 +1,222 @@ +/* + Copyright 2010 Michael Zanetti + Copyright 2010-2012 Lukáš Tinkl @@ -2413,6 +2413,7 @@ index 0000000..0eb4685 +#include "udisksopticaldrive.h" +#include "udisks2.h" +#include "udisksdevice.h" ++#include "dbus/manager.h" + +using namespace Solid::Backends::UDisks2; + @@ -2437,9 +2438,42 @@ index 0000000..0eb4685 + m_ejectInProgress = true; + m_device->broadcastActionRequested("eject"); + ++ const QString path = m_device->udi(); + QDBusConnection c = QDBusConnection::systemBus(); + -+ QString path = m_device->udi(); ++ // if the device is mounted, unmount first ++ QString blockPath; ++ org::freedesktop::DBus::ObjectManager manager(UD2_DBUS_SERVICE, UD2_DBUS_PATH, c); ++ QDBusPendingReply reply = manager.GetManagedObjects(); ++ reply.waitForFinished(); ++ if (!reply.isError()) { // enum devices ++ Q_FOREACH(const QDBusObjectPath &objPath, reply.value().keys()) { ++ const QString udi = objPath.path(); ++ ++ //qDebug() << "Inspecting" << udi; ++ ++ if (udi == UD2_DBUS_PATH_MANAGER || udi == UD2_UDI_DISKS_PREFIX || udi.startsWith(UD2_DBUS_PATH_JOBS)) ++ continue; ++ ++ Device device(udi); ++ if (device.drivePath() == path && device.isMounted()) { ++ //qDebug() << "Got mounted block device:" << udi; ++ blockPath = udi; ++ break; ++ } ++ } ++ } ++ else // show error ++ { ++ qWarning() << "Failed enumerating UDisks2 objects:" << reply.error().name() << "\n" << reply.error().message(); ++ } ++ ++ if (!blockPath.isEmpty()) { ++ //qDebug() << "Calling unmount on" << blockPath; ++ QDBusMessage msg = QDBusMessage::createMethodCall(UD2_DBUS_SERVICE, blockPath, UD2_DBUS_INTERFACE_FILESYSTEM, "Unmount"); ++ msg << QVariantMap(); // options, unused now ++ c.call(msg, QDBus::BlockWithGui); ++ } + + QDBusMessage msg = QDBusMessage::createMethodCall(UD2_DBUS_SERVICE, path, UD2_DBUS_INTERFACE_DRIVE, "Eject"); + msg << QVariantMap(); @@ -2655,10 +2689,10 @@ index 0000000..4c98ef5 +#endif // UDISKS2OPTICALDRIVE_H diff --git a/tier1/solid/src/solid/backends/udisks2/udisksstorageaccess.cpp b/tier1/solid/src/solid/backends/udisks2/udisksstorageaccess.cpp new file mode 100644 -index 0000000..6301210 +index 0000000..c2af2b0 --- /dev/null +++ b/tier1/solid/src/solid/backends/udisks2/udisksstorageaccess.cpp -@@ -0,0 +1,366 @@ +@@ -0,0 +1,360 @@ +/* + Copyright 2009 Pino Toscano + Copyright 2009-2012 Lukáš Tinkl @@ -2693,9 +2727,8 @@ index 0000000..6301210 +StorageAccess::StorageAccess(Device *device) + : DeviceInterface(device), m_setupInProgress(false), m_teardownInProgress(false), m_passphraseRequested(false) +{ ++ connect(device, SIGNAL(changed()), this, SLOT(checkAccessibility())); + updateCache(); -+ QDBusConnection::systemBus().connect(UD2_DBUS_SERVICE, m_device->udi(), DBUS_INTERFACE_PROPS, "PropertiesChanged", this, -+ SLOT(slotPropertiesChanged(QString,QVariantMap,QStringList))); + + // Delay connecting to DBus signals to avoid the related time penalty + // in hot paths such as predicate matching @@ -2788,15 +2821,6 @@ index 0000000..6301210 + return unmount(); +} + -+void StorageAccess::slotPropertiesChanged(const QString &ifaceName, const QVariantMap &changedProps, const QStringList &invalidatedProps) -+{ -+ Q_UNUSED(ifaceName); -+ -+ if (changedProps.keys().contains("MountPoints") || invalidatedProps.contains("MountPoints")) { -+ checkAccessibility(); -+ } -+} -+ +void StorageAccess::updateCache() +{ + m_isAccessible = isAccessible(); @@ -2823,10 +2847,10 @@ index 0000000..6301210 + } + else // Don't broadcast setupDone unless the setup is really done. (Fix kde#271156) + { -+ checkAccessibility(); -+ + m_setupInProgress = false; + m_device->broadcastActionDone("setup"); ++ ++ checkAccessibility(); + } + } + else if (m_teardownInProgress) // FIXME @@ -2841,11 +2865,11 @@ index 0000000..6301210 + else + { + // try to "eject" (aka safely remove) from the (parent) drive, e.g. SD card from a reader -+ const QString drivePath = m_device->drivePath(); ++ QString drivePath = m_device->prop("Drive").value().path(); + if (!drivePath.isEmpty() || drivePath != "/") + { + Device drive(drivePath); -+ if (drive.prop("Ejectable").toBool() && !drive.isOpticalDrive()) // optical drives have their Eject method ++ if (drive.prop("Ejectable").toBool() && !m_device->isOpticalDisc()) // optical drives have their Eject method + { + QDBusConnection c = QDBusConnection::systemBus(); + QDBusMessage msg = QDBusMessage::createMethodCall(UD2_DBUS_SERVICE, drivePath, UD2_DBUS_INTERFACE_DRIVE, "Eject"); @@ -2854,10 +2878,10 @@ index 0000000..6301210 + } + } + -+ checkAccessibility(); -+ + m_teardownInProgress = false; + m_device->broadcastActionDone("teardown"); ++ ++ checkAccessibility(); + } + } +} @@ -2866,34 +2890,36 @@ index 0000000..6301210 +{ + if (m_setupInProgress) + { -+ checkAccessibility(); -+ + m_setupInProgress = false; + m_device->broadcastActionDone("setup", m_device->errorToSolidError(error.name()), + m_device->errorToString(error.name()) + ": " +error.message()); + ++ checkAccessibility(); + } + else if (m_teardownInProgress) + { -+ checkAccessibility(); -+ + m_teardownInProgress = false; + m_clearTextPath.clear(); + m_device->broadcastActionDone("teardown", m_device->errorToSolidError(error.name()), + m_device->errorToString(error.name()) + ": " + error.message()); ++ checkAccessibility(); + } +} + +void StorageAccess::slotSetupRequested() +{ + m_setupInProgress = true; ++ //qDebug() << "SETUP REQUESTED:" << m_device->udi(); + Q_EMIT setupRequested(m_device->udi()); +} + +void StorageAccess::slotSetupDone(int error, const QString &errorString) +{ + m_setupInProgress = false; ++ //qDebug() << "SETUP DONE:" << m_device->udi(); + Q_EMIT setupDone(static_cast(error), errorString, m_device->udi()); ++ ++ checkAccessibility(); +} + +void StorageAccess::slotTeardownRequested() @@ -2907,6 +2933,8 @@ index 0000000..6301210 + m_teardownInProgress = false; + m_clearTextPath.clear(); + Q_EMIT teardownDone(static_cast(error), errorString, m_device->udi()); ++ ++ checkAccessibility(); +} + +bool StorageAccess::mount() @@ -3027,7 +3055,7 @@ index 0000000..6301210 +} diff --git a/tier1/solid/src/solid/backends/udisks2/udisksstorageaccess.h b/tier1/solid/src/solid/backends/udisks2/udisksstorageaccess.h new file mode 100644 -index 0000000..36f2102 +index 0000000..2901067 --- /dev/null +++ b/tier1/solid/src/solid/backends/udisks2/udisksstorageaccess.h @@ -0,0 +1,104 @@ @@ -3093,7 +3121,6 @@ index 0000000..36f2102 + Q_SCRIPTABLE Q_NOREPLY void passphraseReply(const QString & passphrase); + +private Q_SLOTS: -+ void slotPropertiesChanged(const QString & ifaceName, const QVariantMap & changedProps, const QStringList & invalidatedProps); + void slotDBusReply(const QDBusMessage & reply); + void slotDBusError(const QDBusError & error); + @@ -3104,12 +3131,13 @@ index 0000000..36f2102 + void slotTeardownRequested(); + void slotTeardownDone(int error, const QString &errorString); + ++ void checkAccessibility(); ++ +private: + /// @return true if this device is luks and unlocked + bool isLuksDevice() const; + + void updateCache(); -+ void checkAccessibility(); + + bool mount(); + bool unmount(); diff --git a/kdelibs.spec b/kdelibs.spec index 37e6211..e9bcc3f 100644 --- a/kdelibs.spec +++ b/kdelibs.spec @@ -25,7 +25,7 @@ Summary: KDE Libraries Version: 4.8.95 -Release: 1%{?dist} +Release: 2%{?dist} Name: kdelibs Epoch: 6 @@ -610,13 +610,17 @@ rm -rf %{buildroot} %changelog +* Wed Jun 27 2012 Lukas Tinkl - 6:4.8.95-2 +- respin the udisks2 backend patch +- Resolves #835107 - Unable to eject optical media using "Device + notifier" + * Wed Jun 27 2012 Radek Novacek - 6:4.8.95-1 - 4.8.95 * Tue Jun 26 2012 Lukáš Tinkl - 6:4.8.90-4 - update the udisks2 backend patch -- Resolves #835107 - Unable to eject optical media using "Device - notifier" + * Wed Jun 20 2012 Rex Dieter 6:4.8.90-3 - rebuild (attica)