rebase udisks2 backend patch

This commit is contained in:
Lukáš Tinkl 2012-11-29 15:46:42 +01:00
parent 4294e82645
commit 9d5428cf35
2 changed files with 147 additions and 111 deletions

View File

@ -1,5 +1,5 @@
diff --git a/solid/solid/CMakeLists.txt b/solid/solid/CMakeLists.txt
index 0aa7a43..21e774c 100644
index 0aa7a43..c2cc4f9 100644
--- a/solid/solid/CMakeLists.txt
+++ b/solid/solid/CMakeLists.txt
@@ -1,6 +1,7 @@
@ -52,7 +52,7 @@ index 0aa7a43..21e774c 100644
message(STATUS "Building Solid UPower backend." )
set(solid_LIB_SRCS ${solid_LIB_SRCS}
backends/upower/upowermanager.cpp
@@ -264,19 +237,19 @@ if(NOT WIN32 AND NOT APPLE)
@@ -264,19 +237,38 @@ if(NOT WIN32 AND NOT APPLE)
# FIXME: this should work on more Unix systems
if (CMAKE_SYSTEM_NAME MATCHES Linux)
@ -69,7 +69,10 @@ index 0aa7a43..21e774c 100644
- backends/udisks/udisksstorageaccess.cpp
- backends/udisks/udisksgenericinterface.cpp
- )
+
+ if ( WITH_SOLID_UDISKS2 )
+ message(STATUS "Building Solid UDisks2 backend." )
+ add_definitions(-DWITH_SOLID_UDISKS2)
+ set(solid_LIB_SRCS ${solid_LIB_SRCS}
+ backends/udisks2/udisksmanager.cpp
+ backends/udisks2/udisksdevice.cpp
@ -81,7 +84,23 @@ index 0aa7a43..21e774c 100644
+ backends/udisks2/udisksstoragedrive.cpp
+ backends/udisks2/udisksstorageaccess.cpp
+ backends/udisks2/udisksgenericinterface.cpp
+ backends/udisks2/dbus/manager.cpp)
+ backends/udisks2/dbus/manager.cpp
+ )
+ else ( WITH_SOLID_UDISKS2 )
+ message(STATUS "Building Solid UDisks backend." )
+ set(solid_LIB_SRCS ${solid_LIB_SRCS}
+ backends/udisks/udisksmanager.cpp
+ backends/udisks/udisksdevice.cpp
+ backends/udisks/udisksblock.cpp
+ backends/udisks/udisksstoragevolume.cpp
+ backends/udisks/udisksdeviceinterface.cpp
+ backends/udisks/udisksopticaldisc.cpp
+ backends/udisks/udisksopticaldrive.cpp
+ backends/udisks/udisksstoragedrive.cpp
+ backends/udisks/udisksstorageaccess.cpp
+ backends/udisks/udisksgenericinterface.cpp
+ )
+ endif ( WITH_SOLID_UDISKS2 )
endif (CMAKE_SYSTEM_NAME MATCHES Linux)
message(STATUS "Building Solid fstab backend." )
@ -295,10 +314,10 @@ index 0000000..8dda86a
+#endif // SOLID_BACKENDS_UDISKS2_H
diff --git a/solid/solid/backends/udisks2/udisksblock.cpp b/solid/solid/backends/udisks2/udisksblock.cpp
new file mode 100644
index 0000000..f3cd1e8
index 0000000..027ea03
--- /dev/null
+++ b/solid/solid/backends/udisks2/udisksblock.cpp
@@ -0,0 +1,88 @@
@@ -0,0 +1,89 @@
+/*
+ Copyright 2012 Lukáš Tinkl <ltinkl@redhat.com>
+
@ -331,7 +350,8 @@ index 0000000..f3cd1e8
+using namespace Solid::Backends::UDisks2;
+
+Block::Block(Device *dev)
+ : DeviceInterface(dev)
+ : DeviceInterface(dev),
+ m_connection(QDBusConnection::connectToBus(QDBusConnection::SystemBus, "Solid::Udisks2::Block::" + dev->udi()))
+{
+ m_devNum = m_device->prop("DeviceNumber").toULongLong();
+ m_devFile = QFile::decodeName(m_device->prop("Device").toByteArray());
@ -341,7 +361,7 @@ index 0000000..f3cd1e8
+ const QString path = "/org/freedesktop/UDisks2/block_devices";
+ QDBusMessage call = QDBusMessage::createMethodCall(UD2_DBUS_SERVICE, path,
+ DBUS_INTERFACE_INTROSPECT, "Introspect");
+ QDBusPendingReply<QString> reply = QDBusConnection::systemBus().asyncCall(call);
+ QDBusPendingReply<QString> reply = m_connection.asyncCall(call);
+ reply.waitForFinished();
+
+ if (reply.isValid()) {
@ -389,10 +409,10 @@ index 0000000..f3cd1e8
+}
diff --git a/solid/solid/backends/udisks2/udisksblock.h b/solid/solid/backends/udisks2/udisksblock.h
new file mode 100644
index 0000000..19cb70a
index 0000000..65ef2b8
--- /dev/null
+++ b/solid/solid/backends/udisks2/udisksblock.h
@@ -0,0 +1,56 @@
@@ -0,0 +1,57 @@
+/*
+ Copyright 2012 Lukáš Tinkl <ltinkl@redhat.com>
+
@ -440,6 +460,7 @@ index 0000000..19cb70a
+ virtual int deviceMinor() const;
+ virtual int deviceMajor() const;
+private:
+ QDBusConnection m_connection;
+ dev_t m_devNum;
+ QString m_devFile;
+};
@ -451,7 +472,7 @@ index 0000000..19cb70a
+#endif // UDISKS2BLOCK_H
diff --git a/solid/solid/backends/udisks2/udisksdevice.cpp b/solid/solid/backends/udisks2/udisksdevice.cpp
new file mode 100644
index 0000000..a3f780f
index 0000000..3508d57
--- /dev/null
+++ b/solid/solid/backends/udisks2/udisksdevice.cpp
@@ -0,0 +1,927 @@
@ -549,18 +570,19 @@ index 0000000..a3f780f
+Device::Device(const QString &udi)
+ : Solid::Ifaces::Device()
+ , m_udi(udi)
+ , m_connection(QDBusConnection::connectToBus(QDBusConnection::SystemBus, "Solid::Udisks2::Device::" + udi))
+{
+ m_device = new QDBusInterface(UD2_DBUS_SERVICE, m_udi,
+ QString(), // no interface, we aggregate them
+ QDBusConnection::systemBus());
+ m_connection);
+
+ if (m_device->isValid()) {
+ QDBusConnection::systemBus().connect(UD2_DBUS_SERVICE, m_udi, DBUS_INTERFACE_PROPS, "PropertiesChanged", this,
+ m_connection.connect(UD2_DBUS_SERVICE, m_udi, DBUS_INTERFACE_PROPS, "PropertiesChanged", this,
+ SLOT(slotPropertiesChanged(QString,QVariantMap,QStringList)));
+
+ QDBusConnection::systemBus().connect(UD2_DBUS_SERVICE, UD2_DBUS_PATH, DBUS_INTERFACE_MANAGER, "InterfacesAdded",
+ m_connection.connect(UD2_DBUS_SERVICE, UD2_DBUS_PATH, DBUS_INTERFACE_MANAGER, "InterfacesAdded",
+ this, SLOT(slotInterfacesAdded(QDBusObjectPath,QVariantMapMap)));
+ QDBusConnection::systemBus().connect(UD2_DBUS_SERVICE, UD2_DBUS_PATH, DBUS_INTERFACE_MANAGER, "InterfacesRemoved",
+ m_connection.connect(UD2_DBUS_SERVICE, UD2_DBUS_PATH, DBUS_INTERFACE_MANAGER, "InterfacesRemoved",
+ this, SLOT(slotInterfacesRemoved(QDBusObjectPath,QStringList)));
+
+ initInterfaces();
@ -950,9 +972,9 @@ index 0000000..a3f780f
+ if (isEncryptedContainer())
+ {
+ if (!size_str.isEmpty())
+ description = QCoreApplication::translate("", "%1 Encrypted Container", "%1 is the size").arg(size_str);
+ description = QCoreApplication::translate("", "%1 Encrypted Drive", "%1 is the size").arg(size_str);
+ else
+ description = QCoreApplication::translate("", "Encrypted Container");
+ description = QCoreApplication::translate("", "Encrypted Drive");
+ }
+ else if (drive_type == Solid::StorageDrive::HardDisk && !drive_is_removable)
+ {
@ -1075,20 +1097,21 @@ index 0000000..a3f780f
+
+QString Device::product() const
+{
+ QString product = prop("Model").toString();
+
+ if (!isDrive()) {
+ QString label = prop("IdLabel").toString();
+ if (!label.isEmpty()) {
+ product = label;
+ }
+ Device drive(drivePath());
+ return drive.prop("Model").toString();
+ }
+
+ return product;
+ return prop("Model").toString();
+}
+
+QString Device::vendor() const
+{
+ if (!isDrive()) {
+ Device drive(drivePath());
+ return drive.prop("Vendor").toString();
+ }
+
+ return prop("Vendor").toString();
+}
+
@ -1101,9 +1124,7 @@ index 0000000..a3f780f
+{
+ QString parent;
+
+ if (isEncryptedContainer())
+ parent = prop("CryptoBackingDevice").value<QDBusObjectPath>().path();
+ else if (propertyExists("Drive")) // block
+ if (propertyExists("Drive")) // block
+ parent = prop("Drive").value<QDBusObjectPath>().path();
+ else if (propertyExists("Table")) // partition
+ parent = prop("Table").value<QDBusObjectPath>().path();
@ -1126,7 +1147,7 @@ index 0000000..a3f780f
+ if (reply.isValid()) {
+ m_cache.insert(key, reply);
+ } else {
+ qWarning() << "got invalid reply for cache:" << key;
+ //qDebug() << "got invalid reply for cache:" << key;
+ }
+}
+
@ -1134,7 +1155,7 @@ index 0000000..a3f780f
+{
+ QDBusMessage call = QDBusMessage::createMethodCall(UD2_DBUS_SERVICE, m_udi,
+ DBUS_INTERFACE_INTROSPECT, "Introspect");
+ QDBusPendingReply<QString> reply = QDBusConnection::systemBus().asyncCall(call);
+ QDBusPendingReply<QString> reply = m_connection.asyncCall(call);
+ reply.waitForFinished();
+
+ if (reply.isValid())
@ -1164,7 +1185,7 @@ index 0000000..a3f780f
+ if (iface.startsWith("org.freedesktop.DBus"))
+ continue;
+ call.setArguments(QVariantList() << iface);
+ QDBusPendingReply<QVariantMap> reply = QDBusConnection::systemBus().asyncCall(call);
+ QDBusPendingReply<QVariantMap> reply = m_connection.asyncCall(call);
+ reply.waitForFinished();
+
+ if (reply.isValid())
@ -1384,10 +1405,10 @@ index 0000000..a3f780f
+}
diff --git a/solid/solid/backends/udisks2/udisksdevice.h b/solid/solid/backends/udisks2/udisksdevice.h
new file mode 100644
index 0000000..7e27634
index 0000000..ee6bc1b
--- /dev/null
+++ b/solid/solid/backends/udisks2/udisksdevice.h
@@ -0,0 +1,113 @@
@@ -0,0 +1,115 @@
+/*
+ Copyright 2010 Michael Zanetti <mzanetti@kde.org>
+ Copyright 2010-2012 Lukáš Tinkl <ltinkl@redhat.com>
@ -1494,6 +1515,8 @@ index 0000000..7e27634
+
+ void checkCache(const QString &key) const;
+ QString introspect() const;
+
+ QDBusConnection m_connection;
+};
+
+}
@ -1818,10 +1841,10 @@ index 0000000..d225f32
+#endif // SOLID_BACKENDS_UDISKS2_GENERICINTERFACE_H
diff --git a/solid/solid/backends/udisks2/udisksmanager.cpp b/solid/solid/backends/udisks2/udisksmanager.cpp
new file mode 100644
index 0000000..fab5208
index 0000000..e781abb
--- /dev/null
+++ b/solid/solid/backends/udisks2/udisksmanager.cpp
@@ -0,0 +1,269 @@
@@ -0,0 +1,239 @@
+/*
+ Copyright 2012 Lukáš Tinkl <ltinkl@redhat.com>
+
@ -1856,9 +1879,10 @@ index 0000000..fab5208
+
+Manager::Manager(QObject *parent)
+ : Solid::Ifaces::DeviceManager(parent),
+ m_connection(QDBusConnection::connectToBus(QDBusConnection::SystemBus, "Solid::Udisks2")),
+ m_manager(UD2_DBUS_SERVICE,
+ UD2_DBUS_PATH,
+ QDBusConnection::systemBus())
+ m_connection)
+{
+ m_supportedInterfaces
+ << Solid::DeviceInterface::GenericInterface
@ -1883,9 +1907,9 @@ index 0000000..fab5208
+ "org.freedesktop.DBus",
+ "ListActivatableNames");
+
+ QDBusReply<QStringList> reply = QDBusConnection::systemBus().call(message);
+ QDBusReply<QStringList> reply = m_connection.call(message);
+ if (reply.isValid() && reply.value().contains(UD2_DBUS_SERVICE)) {
+ QDBusConnection::systemBus().interface()->startService(UD2_DBUS_SERVICE);
+ m_connection.interface()->startService(UD2_DBUS_SERVICE);
+ serviceFound = true;
+ }
+ }
@ -1953,37 +1977,6 @@ index 0000000..fab5208
+{
+ m_deviceCache.clear();
+
+#if 0
+ QDBusPendingReply<DBUSManagerStruct> reply = m_manager.GetManagedObjects();
+ reply.waitForFinished();
+ if (!reply.isError()) { // enum devices
+ m_deviceCache << udiPrefix();
+
+ Q_FOREACH(const QDBusObjectPath &path, reply.value().keys()) {
+ const QString udi = path.path();
+ //qDebug() << "Adding device" << udi;
+
+ if (udi == UD2_DBUS_PATH_MANAGER || udi == UD2_UDI_DISKS_PREFIX || udi.startsWith(UD2_DBUS_PATH_JOBS))
+ continue;
+
+ Device device(udi);
+ if (device.mightBeOpticalDisc()) {
+ QDBusConnection::systemBus().connect(UD2_DBUS_SERVICE, udi, DBUS_INTERFACE_PROPS, "PropertiesChanged", this,
+ SLOT(slotMediaChanged(QDBusMessage)));
+ if (!device.isOpticalDisc()) // skip empty CD disc
+ continue;
+ }
+
+ m_deviceCache.append(udi);
+ }
+ }
+ else // show error
+ {
+ qWarning() << "Failed enumerating UDisks2 objects:" << reply.error().name() << "\n" << reply.error().message();
+ }
+
+#endif
+
+ introspect("/org/freedesktop/UDisks2/block_devices", true /*checkOptical*/);
+ introspect("/org/freedesktop/UDisks2/drives");
+
@ -2009,7 +2002,7 @@ index 0000000..fab5208
+ if (checkOptical) {
+ Device device(udi);
+ if (device.mightBeOpticalDisc()) {
+ QDBusConnection::systemBus().connect(UD2_DBUS_SERVICE, udi, DBUS_INTERFACE_PROPS, "PropertiesChanged", this,
+ m_connection.connect(UD2_DBUS_SERVICE, udi, DBUS_INTERFACE_PROPS, "PropertiesChanged", this,
+ SLOT(slotMediaChanged(QDBusMessage)));
+ if (!device.isOpticalDisc()) // skip empty CD disc
+ continue;
@ -2093,10 +2086,10 @@ index 0000000..fab5208
+
diff --git a/solid/solid/backends/udisks2/udisksmanager.h b/solid/solid/backends/udisks2/udisksmanager.h
new file mode 100644
index 0000000..fb929ce
index 0000000..bf74703
--- /dev/null
+++ b/solid/solid/backends/udisks2/udisksmanager.h
@@ -0,0 +1,70 @@
@@ -0,0 +1,71 @@
+/*
+ Copyright 2010 Michael Zanetti <mzanetti@kde.org>
+ Copyright 2010-2012 Lukáš Tinkl <ltinkl@redhat.com>
@ -2159,6 +2152,7 @@ index 0000000..fb929ce
+ const QStringList &deviceCache();
+ void introspect(const QString & path, bool checkOptical = false);
+ QSet<Solid::DeviceInterface::Type> m_supportedInterfaces;
+ QDBusConnection m_connection;
+ org::freedesktop::DBus::ObjectManager m_manager;
+ QStringList m_deviceCache;
+};
@ -2547,7 +2541,7 @@ index 0000000..0cdcc66
+#endif // UDISKS2OPTICALDISC_H
diff --git a/solid/solid/backends/udisks2/udisksopticaldrive.cpp b/solid/solid/backends/udisks2/udisksopticaldrive.cpp
new file mode 100644
index 0000000..f4351a7
index 0000000..8ad3df0
--- /dev/null
+++ b/solid/solid/backends/udisks2/udisksopticaldrive.cpp
@@ -0,0 +1,222 @@
@ -2612,7 +2606,7 @@ index 0000000..f4351a7
+ m_device->broadcastActionRequested("eject");
+
+ const QString path = m_device->udi();
+ QDBusConnection c = QDBusConnection::systemBus();
+ QDBusConnection c = QDBusConnection::connectToBus(QDBusConnection::SystemBus, "Solid::Udisks2::OpticalDrive::" + path);
+
+ // if the device is mounted, unmount first
+ QString blockPath;
@ -2862,10 +2856,10 @@ index 0000000..4c98ef5
+#endif // UDISKS2OPTICALDRIVE_H
diff --git a/solid/solid/backends/udisks2/udisksstorageaccess.cpp b/solid/solid/backends/udisks2/udisksstorageaccess.cpp
new file mode 100644
index 0000000..f28540b
index 0000000..6958459
--- /dev/null
+++ b/solid/solid/backends/udisks2/udisksstorageaccess.cpp
@@ -0,0 +1,362 @@
@@ -0,0 +1,390 @@
+/*
+ Copyright 2009 Pino Toscano <pino@kde.org>
+ Copyright 2009-2012 Lukáš Tinkl <ltinkl@redhat.com>
@ -2890,10 +2884,10 @@ index 0000000..f28540b
+#include "udisksstorageaccess.h"
+#include "udisks2.h"
+
+#include <QtCore/QProcess>
+#include <QtDBus/QtDBus>
+#include <QtGui/QApplication>
+#include <QtGui/QWidget>
+#include <QtXml/QDomDocument>
+
+using namespace Solid::Backends::UDisks2;
+
@ -2931,9 +2925,11 @@ index 0000000..f28540b
+bool StorageAccess::isAccessible() const
+{
+ if (isLuksDevice()) { // check if the cleartext slave is mounted
+ if (m_clearTextPath.isEmpty() || m_clearTextPath == "/")
+ const QString path = clearTextPath();
+ //qDebug() << Q_FUNC_INFO << "CLEARTEXT device path: " << path;
+ if (path.isEmpty() || path == "/")
+ return false;
+ Device holderDevice(m_clearTextPath);
+ Device holderDevice(path);
+ return holderDevice.isMounted();
+ }
+
@ -2942,15 +2938,13 @@ index 0000000..f28540b
+
+QString StorageAccess::filePath() const
+{
+ if (!isAccessible())
+ return QString();
+
+ QByteArrayList mntPoints;
+
+ if (isLuksDevice()) { // encrypted (and unlocked) device
+ if (m_clearTextPath.isEmpty() || m_clearTextPath == "/")
+ const QString path = clearTextPath();
+ if (path.isEmpty() || path == "/")
+ return QString();
+ Device holderDevice(m_clearTextPath);
+ Device holderDevice(path);
+ mntPoints = qdbus_cast<QByteArrayList>(holderDevice.prop("MountPoints"));
+ if (!mntPoints.isEmpty())
+ return QFile::decodeName(mntPoints.first()); // FIXME Solid doesn't support multiple mount points
@ -2968,7 +2962,7 @@ index 0000000..f28540b
+
+bool StorageAccess::isIgnored() const
+{
+ return m_device->prop("HintIgnore").toBool(); // FIXME tune
+ return m_device->prop("HintIgnore").toBool();
+}
+
+bool StorageAccess::setup()
@ -2978,7 +2972,7 @@ index 0000000..f28540b
+ m_setupInProgress = true;
+ m_device->broadcastActionRequested("setup");
+
+ if (m_device->isEncryptedContainer())
+ if (m_device->isEncryptedContainer() && clearTextPath().isEmpty())
+ return requestPassphrase();
+ else
+ return mount();
@ -3005,17 +2999,16 @@ index 0000000..f28540b
+ updateCache();
+
+ if (old_isAccessible != m_isAccessible) {
+ Q_EMIT accessibilityChanged(m_isAccessible, isLuksDevice() ? m_clearTextPath : m_device->udi());
+ Q_EMIT accessibilityChanged(m_isAccessible, m_device->udi());
+ }
+}
+
+void StorageAccess::slotDBusReply( const QDBusMessage & reply )
+void StorageAccess::slotDBusReply( const QDBusMessage & /*reply*/ )
+{
+ const QString ctPath = clearTextPath();
+ if (m_setupInProgress)
+ {
+ if (isLuksDevice() && !isAccessible()) { // unlocked device, now mount it
+ if (reply.type() == QDBusMessage::ReplyMessage) // we've got a response from Unlock
+ m_clearTextPath = reply.arguments().value(0).value<QDBusObjectPath>().path();
+ mount();
+ }
+ else // Don't broadcast setupDone unless the setup is really done. (Fix kde#271156)
@ -3028,17 +3021,17 @@ index 0000000..f28540b
+ }
+ else if (m_teardownInProgress) // FIXME
+ {
+ if (isLuksDevice() && !m_clearTextPath.isEmpty() && m_clearTextPath != "/") // unlocked device, lock it
+ if (isLuksDevice() && !ctPath.isEmpty() && ctPath != "/") // unlocked device, lock it
+ {
+ callCryptoTeardown();
+ }
+ else if (!m_clearTextPath.isEmpty() && m_clearTextPath != "/") {
+ else if (!ctPath.isEmpty() && ctPath != "/") {
+ callCryptoTeardown(true); // Lock crypted parent
+ }
+ else
+ {
+ // 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();
+ QString drivePath = m_device->drivePath();
+ if (!drivePath.isEmpty() || drivePath != "/")
+ {
+ Device drive(drivePath);
@ -3063,6 +3056,8 @@ index 0000000..f28540b
+
+void StorageAccess::slotDBusError( const QDBusError & error )
+{
+ //qDebug() << Q_FUNC_INFO << "DBUS ERROR:" << error.name() << error.message();
+
+ if (m_setupInProgress)
+ {
+ m_setupInProgress = false;
@ -3074,7 +3069,6 @@ index 0000000..f28540b
+ else if (m_teardownInProgress)
+ {
+ m_teardownInProgress = false;
+ m_clearTextPath.clear();
+ m_device->broadcastActionDone("teardown", m_device->errorToSolidError(error.name()),
+ m_device->errorToString(error.name()) + ": " + error.message());
+ checkAccessibility();
@ -3106,7 +3100,6 @@ index 0000000..f28540b
+void StorageAccess::slotTeardownDone(int error, const QString &errorString)
+{
+ m_teardownInProgress = false;
+ m_clearTextPath.clear();
+ Q_EMIT teardownDone(static_cast<Solid::ErrorType>(error), errorString, m_device->udi());
+
+ checkAccessibility();
@ -3115,9 +3108,10 @@ index 0000000..f28540b
+bool StorageAccess::mount()
+{
+ QString path = m_device->udi();
+ const QString ctPath = clearTextPath();
+
+ if (isLuksDevice()) { // mount options for the cleartext volume
+ path = m_clearTextPath;
+ if (isLuksDevice() && !ctPath.isEmpty()) { // mount options for the cleartext volume
+ path = ctPath;
+ }
+
+ QDBusConnection c = QDBusConnection::systemBus();
@ -3137,9 +3131,10 @@ index 0000000..f28540b
+bool StorageAccess::unmount()
+{
+ QString path = m_device->udi();
+ const QString ctPath = clearTextPath();
+
+ if (isLuksDevice()) { // unmount options for the cleartext volume
+ path = m_clearTextPath;
+ if (isLuksDevice() && !ctPath.isEmpty()) { // unmount options for the cleartext volume
+ path = ctPath;
+ }
+
+ QDBusConnection c = QDBusConnection::systemBus();
@ -3160,6 +3155,35 @@ index 0000000..f28540b
+ return "/org/kde/solid/UDisks2StorageAccess_"+QString::number(number++);
+}
+
+QString StorageAccess::clearTextPath() const
+{
+ const QString prefix = "/org/freedesktop/UDisks2/block_devices";
+ QDBusMessage call = QDBusMessage::createMethodCall(UD2_DBUS_SERVICE, prefix,
+ DBUS_INTERFACE_INTROSPECT, "Introspect");
+ QDBusPendingReply<QString> reply = QDBusConnection::systemBus().asyncCall(call);
+ reply.waitForFinished();
+
+ if (reply.isValid()) {
+ QDomDocument dom;
+ dom.setContent(reply.value());
+ QDomNodeList nodeList = dom.documentElement().elementsByTagName("node");
+ for (int i = 0; i < nodeList.count(); i++) {
+ QDomElement nodeElem = nodeList.item(i).toElement();
+ if (!nodeElem.isNull() && nodeElem.hasAttribute("name")) {
+ const QString udi = prefix + "/" + nodeElem.attribute("name");
+ Device holderDevice(udi);
+
+ if (m_device->udi() == holderDevice.prop("CryptoBackingDevice").value<QDBusObjectPath>().path()) {
+ //qDebug() << Q_FUNC_INFO << "CLEARTEXT device path: " << udi;
+ return udi;
+ }
+ }
+ }
+ }
+
+ return QString();
+}
+
+bool StorageAccess::requestPassphrase()
+{
+ QString udi = m_device->udi();
@ -3222,15 +3246,13 @@ index 0000000..f28540b
+ UD2_DBUS_INTERFACE_ENCRYPTED, "Lock");
+ msg << QVariantMap(); // options, unused now
+
+ m_clearTextPath.clear();
+
+ return c.callWithCallback(msg, this,
+ SLOT(slotDBusReply(const QDBusMessage &)),
+ SLOT(slotDBusError(const QDBusError &)));
+}
diff --git a/solid/solid/backends/udisks2/udisksstorageaccess.h b/solid/solid/backends/udisks2/udisksstorageaccess.h
new file mode 100644
index 0000000..2901067
index 0000000..ec91f89
--- /dev/null
+++ b/solid/solid/backends/udisks2/udisksstorageaccess.h
@@ -0,0 +1,104 @@
@ -3322,6 +3344,7 @@ index 0000000..2901067
+ bool callCryptoTeardown( bool actOnParent=false );
+
+ QString generateReturnObjectPath();
+ QString clearTextPath() const;
+
+private:
+ bool m_isAccessible;
@ -3329,7 +3352,6 @@ index 0000000..2901067
+ bool m_teardownInProgress;
+ bool m_passphraseRequested;
+ QString m_lastReturnObject;
+ QString m_clearTextPath; // path to the unlocked cleartext device
+
+ static const int s_unmountTimeout = 0x7fffffff;
+};
@ -3733,20 +3755,23 @@ index 0000000..2ca04d2
+
+#endif // UDISKS2STORAGEVOLUME_H
diff --git a/solid/solid/managerbase.cpp b/solid/solid/managerbase.cpp
index fb5a67c..d58736e 100644
index fb5a67c..c7005ff 100644
--- a/solid/solid/managerbase.cpp
+++ b/solid/solid/managerbase.cpp
@@ -30,8 +30,7 @@
@@ -30,8 +30,11 @@
#if defined (Q_OS_MAC)
#include "backends/iokit/iokitmanager.h"
#elif defined (Q_OS_UNIX)
-#include "backends/hal/halmanager.h"
-#include "backends/udisks/udisksmanager.h"
+#if defined (WITH_SOLID_UDISKS2)
+#include "backends/udisks2/udisksmanager.h"
+#else
#include "backends/udisks/udisksmanager.h"
+#endif
#include "backends/upower/upowermanager.h"
#if defined (HUPNP_FOUND)
@@ -71,22 +70,13 @@ void Solid::ManagerBasePrivate::loadBackends()
@@ -71,22 +74,17 @@ void Solid::ManagerBasePrivate::loadBackends()
# elif defined(Q_WS_WIN) && defined(HAVE_WBEM) && !defined(_WIN32_WCE)
m_backends << new Solid::Backends::Wmi::WmiManager(0);
@ -3762,23 +3787,31 @@ index fb5a67c..d58736e 100644
# if defined(UDEV_FOUND)
m_backends << new Solid::Backends::UDev::UDevManager(0);
# endif
- m_backends << new Solid::Backends::UDisks::UDisksManager(0)
+# if defined(WITH_SOLID_UDISKS2)
+ m_backends << new Solid::Backends::UDisks2::Manager(0)
+# else
m_backends << new Solid::Backends::UDisks::UDisksManager(0)
+# endif
<< new Solid::Backends::UPower::UPowerManager(0)
<< new Solid::Backends::Fstab::FstabManager(0);
- }
# endif
# if defined (HUPNP_FOUND)
@@ -99,5 +97,3 @@ QList<QObject*> Solid::ManagerBasePrivate::managerBackends() const
{
return m_backends;
}
-
-
diff --git a/solid/tests/CMakeLists.txt b/solid/tests/CMakeLists.txt
index ef507d1..b9f3720 100644
index ef507d1..9212741 100644
--- a/solid/tests/CMakeLists.txt
+++ b/solid/tests/CMakeLists.txt
@@ -15,21 +15,6 @@ endif(WIN32)
target_link_libraries(fakehardwaretest solid_static ${QT_QTCORE_LIBRARY} ${QT_QTDBUS_LIBRARY} ${QT_QTXML_LIBRARY} ${QT_QTTEST_LIBRARY} )
@@ -16,20 +16,6 @@ target_link_libraries(fakehardwaretest solid_static ${QT_QTCORE_LIBRARY} ${QT_QT
add_definitions(-DTEST_DATA="\\"${CMAKE_CURRENT_SOURCE_DIR}/../solid/backends/fakehw/fakecomputer.xml\\"")
-
-########### halbasictest ###############
-
-if(NOT WIN32 AND NOT APPLE)

View File

@ -25,7 +25,7 @@
Summary: KDE Libraries
Version: 4.9.3
Release: 4%{?dist}
Release: 5%{?dist}
Name: kdelibs
Epoch: 6
@ -588,6 +588,9 @@ rm -rf %{buildroot}
%changelog
* Thu Nov 29 2012 Lukáš Tinkl <ltinkl@redhat.com> 6:4.9.3-5
- update udisks2 backend patch
* Fri Nov 23 2012 Jan Grulich <jgrulich@redhat.com> 6:4.9.3-4
- Fix previous patch