sync the udisks2 backend patch

This commit is contained in:
Lukas Tinkl 2012-06-29 15:38:23 +02:00
parent a09ae4edc1
commit ed3f432ac5
2 changed files with 67 additions and 29 deletions

View File

@ -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 <mzanetti@kde.org>
+ Copyright 2010-2012 Lukáš Tinkl <ltinkl@redhat.com>
@ -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<DBUSManagerStruct> 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..146c227
index 0000000..c2af2b0
--- /dev/null
+++ b/tier1/solid/src/solid/backends/udisks2/udisksstorageaccess.cpp
@@ -0,0 +1,359 @@
@@ -0,0 +1,360 @@
+/*
+ Copyright 2009 Pino Toscano <pino@kde.org>
+ Copyright 2009-2012 Lukáš Tinkl <ltinkl@redhat.com>
@ -2693,9 +2727,8 @@ index 0000000..146c227
+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..146c227
+ 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")) {
+ Q_EMIT accessibilityChanged(isAccessible(), isLuksDevice() ? m_clearTextPath : m_device->udi());
+ }
+}
+
+void StorageAccess::updateCache()
+{
+ m_isAccessible = isAccessible();
@ -2840,11 +2864,12 @@ index 0000000..146c227
+ }
+ else
+ {
+ if (m_device->prop("Ejectable").toBool() && !m_device->isOpticalDisc()) // optical drives have their Eject method
+ // try to "eject" (aka safely remove) from the (parent) drive, e.g. SD card from a reader
+ QString drivePath = m_device->prop("Drive").value<QDBusObjectPath>().path();
+ if (!drivePath.isEmpty() || drivePath != "/")
+ {
+ // try to "eject" (aka safely remove) from the (parent) drive, e.g. SD card from a reader
+ QString drivePath = m_device->prop("Drive").value<QDBusObjectPath>().path();
+ if (!drivePath.isEmpty() || drivePath != "/")
+ Device drive(drivePath);
+ 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");
@ -2884,13 +2909,17 @@ index 0000000..146c227
+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<Solid::ErrorType>(error), errorString, m_device->udi());
+
+ checkAccessibility();
+}
+
+void StorageAccess::slotTeardownRequested()
@ -2904,6 +2933,8 @@ index 0000000..146c227
+ m_teardownInProgress = false;
+ m_clearTextPath.clear();
+ Q_EMIT teardownDone(static_cast<Solid::ErrorType>(error), errorString, m_device->udi());
+
+ checkAccessibility();
+}
+
+bool StorageAccess::mount()
@ -2916,8 +2947,12 @@ index 0000000..146c227
+
+ QDBusConnection c = QDBusConnection::systemBus();
+ QDBusMessage msg = QDBusMessage::createMethodCall(UD2_DBUS_SERVICE, path, UD2_DBUS_INTERFACE_FILESYSTEM, "Mount");
+ QVariantMap options;
+
+ msg << QVariantMap(); // options, unused now
+ if (m_device->prop("IdType").toString() == "vfat")
+ options.insert("options", "flush");
+
+ msg << options;
+
+ return c.callWithCallback(msg, this,
+ SLOT(slotDBusReply(const QDBusMessage &)),
@ -3020,7 +3055,7 @@ index 0000000..146c227
+}
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 @@
@ -3086,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);
+
@ -3097,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();

View File

@ -25,7 +25,7 @@
Summary: KDE Libraries
Version: 4.8.4
Release: 5%{?dist}
Release: 6%{?dist}
Name: kdelibs
Epoch: 6
@ -615,6 +615,9 @@ rm -rf %{buildroot}
%changelog
* Fri Jun 29 2012 Lukáš Tinkl <ltinkl@redhat.com> - 6:4.8.4-6
- sync the udisks2 backend patch
* Wed Jun 20 2012 Rex Dieter <rdieter@fedoraproject.org> 6:4.8.4-5
- rebuild (attica)