update udisks2 backend patch
This commit is contained in:
parent
04893e481a
commit
c8f1a5d078
|
@ -1,5 +1,5 @@
|
||||||
diff --git a/solid/solid/CMakeLists.txt b/solid/solid/CMakeLists.txt
|
diff --git a/solid/solid/CMakeLists.txt b/solid/solid/CMakeLists.txt
|
||||||
index 0aa7a43..c2cc4f9 100644
|
index 0aa7a43..b00e50a 100644
|
||||||
--- a/solid/solid/CMakeLists.txt
|
--- a/solid/solid/CMakeLists.txt
|
||||||
+++ b/solid/solid/CMakeLists.txt
|
+++ b/solid/solid/CMakeLists.txt
|
||||||
@@ -1,6 +1,7 @@
|
@@ -1,6 +1,7 @@
|
||||||
|
@ -52,7 +52,7 @@ index 0aa7a43..c2cc4f9 100644
|
||||||
message(STATUS "Building Solid UPower backend." )
|
message(STATUS "Building Solid UPower backend." )
|
||||||
set(solid_LIB_SRCS ${solid_LIB_SRCS}
|
set(solid_LIB_SRCS ${solid_LIB_SRCS}
|
||||||
backends/upower/upowermanager.cpp
|
backends/upower/upowermanager.cpp
|
||||||
@@ -264,19 +237,38 @@ if(NOT WIN32 AND NOT APPLE)
|
@@ -264,19 +237,39 @@ if(NOT WIN32 AND NOT APPLE)
|
||||||
|
|
||||||
# FIXME: this should work on more Unix systems
|
# FIXME: this should work on more Unix systems
|
||||||
if (CMAKE_SYSTEM_NAME MATCHES Linux)
|
if (CMAKE_SYSTEM_NAME MATCHES Linux)
|
||||||
|
@ -76,6 +76,7 @@ index 0aa7a43..c2cc4f9 100644
|
||||||
+ set(solid_LIB_SRCS ${solid_LIB_SRCS}
|
+ set(solid_LIB_SRCS ${solid_LIB_SRCS}
|
||||||
+ backends/udisks2/udisksmanager.cpp
|
+ backends/udisks2/udisksmanager.cpp
|
||||||
+ backends/udisks2/udisksdevice.cpp
|
+ backends/udisks2/udisksdevice.cpp
|
||||||
|
+ backends/udisks2/udisksdevicebackend.cpp
|
||||||
+ backends/udisks2/udisksblock.cpp
|
+ backends/udisks2/udisksblock.cpp
|
||||||
+ backends/udisks2/udisksstoragevolume.cpp
|
+ backends/udisks2/udisksstoragevolume.cpp
|
||||||
+ backends/udisks2/udisksdeviceinterface.cpp
|
+ backends/udisks2/udisksdeviceinterface.cpp
|
||||||
|
@ -314,10 +315,10 @@ index 0000000..8dda86a
|
||||||
+#endif // SOLID_BACKENDS_UDISKS2_H
|
+#endif // SOLID_BACKENDS_UDISKS2_H
|
||||||
diff --git a/solid/solid/backends/udisks2/udisksblock.cpp b/solid/solid/backends/udisks2/udisksblock.cpp
|
diff --git a/solid/solid/backends/udisks2/udisksblock.cpp b/solid/solid/backends/udisks2/udisksblock.cpp
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000..027ea03
|
index 0000000..f3cd1e8
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/solid/solid/backends/udisks2/udisksblock.cpp
|
+++ b/solid/solid/backends/udisks2/udisksblock.cpp
|
||||||
@@ -0,0 +1,89 @@
|
@@ -0,0 +1,88 @@
|
||||||
+/*
|
+/*
|
||||||
+ Copyright 2012 Lukáš Tinkl <ltinkl@redhat.com>
|
+ Copyright 2012 Lukáš Tinkl <ltinkl@redhat.com>
|
||||||
+
|
+
|
||||||
|
@ -350,8 +351,7 @@ index 0000000..027ea03
|
||||||
+using namespace Solid::Backends::UDisks2;
|
+using namespace Solid::Backends::UDisks2;
|
||||||
+
|
+
|
||||||
+Block::Block(Device *dev)
|
+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_devNum = m_device->prop("DeviceNumber").toULongLong();
|
||||||
+ m_devFile = QFile::decodeName(m_device->prop("Device").toByteArray());
|
+ m_devFile = QFile::decodeName(m_device->prop("Device").toByteArray());
|
||||||
|
@ -361,7 +361,7 @@ index 0000000..027ea03
|
||||||
+ const QString path = "/org/freedesktop/UDisks2/block_devices";
|
+ const QString path = "/org/freedesktop/UDisks2/block_devices";
|
||||||
+ QDBusMessage call = QDBusMessage::createMethodCall(UD2_DBUS_SERVICE, path,
|
+ QDBusMessage call = QDBusMessage::createMethodCall(UD2_DBUS_SERVICE, path,
|
||||||
+ DBUS_INTERFACE_INTROSPECT, "Introspect");
|
+ DBUS_INTERFACE_INTROSPECT, "Introspect");
|
||||||
+ QDBusPendingReply<QString> reply = m_connection.asyncCall(call);
|
+ QDBusPendingReply<QString> reply = QDBusConnection::systemBus().asyncCall(call);
|
||||||
+ reply.waitForFinished();
|
+ reply.waitForFinished();
|
||||||
+
|
+
|
||||||
+ if (reply.isValid()) {
|
+ if (reply.isValid()) {
|
||||||
|
@ -409,10 +409,10 @@ index 0000000..027ea03
|
||||||
+}
|
+}
|
||||||
diff --git a/solid/solid/backends/udisks2/udisksblock.h b/solid/solid/backends/udisks2/udisksblock.h
|
diff --git a/solid/solid/backends/udisks2/udisksblock.h b/solid/solid/backends/udisks2/udisksblock.h
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000..65ef2b8
|
index 0000000..19cb70a
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/solid/solid/backends/udisks2/udisksblock.h
|
+++ b/solid/solid/backends/udisks2/udisksblock.h
|
||||||
@@ -0,0 +1,57 @@
|
@@ -0,0 +1,56 @@
|
||||||
+/*
|
+/*
|
||||||
+ Copyright 2012 Lukáš Tinkl <ltinkl@redhat.com>
|
+ Copyright 2012 Lukáš Tinkl <ltinkl@redhat.com>
|
||||||
+
|
+
|
||||||
|
@ -460,7 +460,6 @@ index 0000000..65ef2b8
|
||||||
+ virtual int deviceMinor() const;
|
+ virtual int deviceMinor() const;
|
||||||
+ virtual int deviceMajor() const;
|
+ virtual int deviceMajor() const;
|
||||||
+private:
|
+private:
|
||||||
+ QDBusConnection m_connection;
|
|
||||||
+ dev_t m_devNum;
|
+ dev_t m_devNum;
|
||||||
+ QString m_devFile;
|
+ QString m_devFile;
|
||||||
+};
|
+};
|
||||||
|
@ -472,10 +471,10 @@ index 0000000..65ef2b8
|
||||||
+#endif // UDISKS2BLOCK_H
|
+#endif // UDISKS2BLOCK_H
|
||||||
diff --git a/solid/solid/backends/udisks2/udisksdevice.cpp b/solid/solid/backends/udisks2/udisksdevice.cpp
|
diff --git a/solid/solid/backends/udisks2/udisksdevice.cpp b/solid/solid/backends/udisks2/udisksdevice.cpp
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000..3508d57
|
index 0000000..d70456d
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/solid/solid/backends/udisks2/udisksdevice.cpp
|
+++ b/solid/solid/backends/udisks2/udisksdevice.cpp
|
||||||
@@ -0,0 +1,927 @@
|
@@ -0,0 +1,806 @@
|
||||||
+/*
|
+/*
|
||||||
+ Copyright 2010 Michael Zanetti <mzanetti@kde.org>
|
+ Copyright 2010 Michael Zanetti <mzanetti@kde.org>
|
||||||
+ Copyright 2010-2012 Lukáš Tinkl <ltinkl@redhat.com>
|
+ Copyright 2010-2012 Lukáš Tinkl <ltinkl@redhat.com>
|
||||||
|
@ -498,6 +497,7 @@ index 0000000..3508d57
|
||||||
+*/
|
+*/
|
||||||
+
|
+
|
||||||
+#include "udisksdevice.h"
|
+#include "udisksdevice.h"
|
||||||
|
+#include "udisksdevicebackend.h"
|
||||||
+#include "udisksblock.h"
|
+#include "udisksblock.h"
|
||||||
+#include "udisksdeviceinterface.h"
|
+#include "udisksdeviceinterface.h"
|
||||||
+#include "udisksstoragevolume.h"
|
+#include "udisksstoragevolume.h"
|
||||||
|
@ -569,29 +569,15 @@ index 0000000..3508d57
|
||||||
+
|
+
|
||||||
+Device::Device(const QString &udi)
|
+Device::Device(const QString &udi)
|
||||||
+ : Solid::Ifaces::Device()
|
+ : Solid::Ifaces::Device()
|
||||||
+ , m_udi(udi)
|
+ , m_backend(DeviceBackend::backendForUDI(udi))
|
||||||
+ , m_connection(QDBusConnection::connectToBus(QDBusConnection::SystemBus, "Solid::Udisks2::Device::" + udi))
|
|
||||||
+{
|
+{
|
||||||
+ m_device = new QDBusInterface(UD2_DBUS_SERVICE, m_udi,
|
+ connect(m_backend, SIGNAL(changed()), this, SIGNAL(changed()));
|
||||||
+ QString(), // no interface, we aggregate them
|
+ connect(m_backend, SIGNAL(propertyChanged(QMap<QString,int>)), this, SIGNAL(propertyChanged(QMap<QString,int>)));
|
||||||
+ m_connection);
|
|
||||||
+
|
|
||||||
+ if (m_device->isValid()) {
|
|
||||||
+ m_connection.connect(UD2_DBUS_SERVICE, m_udi, DBUS_INTERFACE_PROPS, "PropertiesChanged", this,
|
|
||||||
+ SLOT(slotPropertiesChanged(QString,QVariantMap,QStringList)));
|
|
||||||
+
|
|
||||||
+ m_connection.connect(UD2_DBUS_SERVICE, UD2_DBUS_PATH, DBUS_INTERFACE_MANAGER, "InterfacesAdded",
|
|
||||||
+ this, SLOT(slotInterfacesAdded(QDBusObjectPath,QVariantMapMap)));
|
|
||||||
+ m_connection.connect(UD2_DBUS_SERVICE, UD2_DBUS_PATH, DBUS_INTERFACE_MANAGER, "InterfacesRemoved",
|
|
||||||
+ this, SLOT(slotInterfacesRemoved(QDBusObjectPath,QStringList)));
|
|
||||||
+
|
|
||||||
+ initInterfaces();
|
|
||||||
+ }
|
|
||||||
+}
|
+}
|
||||||
+
|
+
|
||||||
+Device::~Device()
|
+Device::~Device()
|
||||||
+{
|
+{
|
||||||
+ delete m_device;
|
+
|
||||||
+}
|
+}
|
||||||
+
|
+
|
||||||
+QObject* Device::createDeviceInterface(const Solid::DeviceInterface::Type& type)
|
+QObject* Device::createDeviceInterface(const Solid::DeviceInterface::Type& type)
|
||||||
|
@ -1117,7 +1103,7 @@ index 0000000..3508d57
|
||||||
+
|
+
|
||||||
+QString Device::udi() const
|
+QString Device::udi() const
|
||||||
+{
|
+{
|
||||||
+ return m_udi;
|
+ return m_backend->udi;
|
||||||
+}
|
+}
|
||||||
+
|
+
|
||||||
+QString Device::parentUdi() const
|
+QString Device::parentUdi() const
|
||||||
|
@ -1134,139 +1120,31 @@ index 0000000..3508d57
|
||||||
+ return parent;
|
+ return parent;
|
||||||
+}
|
+}
|
||||||
+
|
+
|
||||||
+void Device::checkCache(const QString &key) const
|
|
||||||
+{
|
|
||||||
+ if (m_cache.isEmpty()) // recreate the cache
|
|
||||||
+ allProperties();
|
|
||||||
+
|
|
||||||
+ if (m_cache.contains(key))
|
|
||||||
+ return;
|
|
||||||
+
|
|
||||||
+ QVariant reply = m_device->property(key.toUtf8());
|
|
||||||
+
|
|
||||||
+ if (reply.isValid()) {
|
|
||||||
+ m_cache.insert(key, reply);
|
|
||||||
+ } else {
|
|
||||||
+ //qDebug() << "got invalid reply for cache:" << key;
|
|
||||||
+ }
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+QString Device::introspect() const
|
|
||||||
+{
|
|
||||||
+ QDBusMessage call = QDBusMessage::createMethodCall(UD2_DBUS_SERVICE, m_udi,
|
|
||||||
+ DBUS_INTERFACE_INTROSPECT, "Introspect");
|
|
||||||
+ QDBusPendingReply<QString> reply = m_connection.asyncCall(call);
|
|
||||||
+ reply.waitForFinished();
|
|
||||||
+
|
|
||||||
+ if (reply.isValid())
|
|
||||||
+ return reply.value();
|
|
||||||
+ else {
|
|
||||||
+ return QString();
|
|
||||||
+ }
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+QVariant Device::prop(const QString &key) const
|
+QVariant Device::prop(const QString &key) const
|
||||||
+{
|
+{
|
||||||
+ checkCache(key);
|
+ return m_backend->prop(key);
|
||||||
+ return m_cache.value(key);
|
|
||||||
+}
|
+}
|
||||||
+
|
+
|
||||||
+bool Device::propertyExists(const QString &key) const
|
+bool Device::propertyExists(const QString &key) const
|
||||||
+{
|
+{
|
||||||
+ checkCache(key);
|
+ return m_backend->propertyExists(key);
|
||||||
+ return m_cache.contains(key);
|
|
||||||
+}
|
+}
|
||||||
+
|
+
|
||||||
+QVariantMap Device::allProperties() const
|
+QVariantMap Device::allProperties() const
|
||||||
+{
|
+{
|
||||||
+ QDBusMessage call = QDBusMessage::createMethodCall(UD2_DBUS_SERVICE, m_udi, DBUS_INTERFACE_PROPS, "GetAll");
|
+ return m_backend->allProperties();
|
||||||
+
|
|
||||||
+ Q_FOREACH (const QString & iface, m_interfaces) {
|
|
||||||
+ if (iface.startsWith("org.freedesktop.DBus"))
|
|
||||||
+ continue;
|
|
||||||
+ call.setArguments(QVariantList() << iface);
|
|
||||||
+ QDBusPendingReply<QVariantMap> reply = m_connection.asyncCall(call);
|
|
||||||
+ reply.waitForFinished();
|
|
||||||
+
|
|
||||||
+ if (reply.isValid())
|
|
||||||
+ m_cache.unite(reply.value());
|
|
||||||
+ else
|
|
||||||
+ qWarning() << "Error getting props:" << reply.error().name() << reply.error().message();
|
|
||||||
+ //qDebug() << "After iface" << iface << ", cache now contains" << m_cache.size() << "items";
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ return m_cache;
|
|
||||||
+}
|
+}
|
||||||
+
|
+
|
||||||
+bool Device::hasInterface(const QString &name) const
|
+bool Device::hasInterface(const QString &name) const
|
||||||
+{
|
+{
|
||||||
+ return m_interfaces.contains(name);
|
+ return m_backend->interfaces().contains(name);
|
||||||
+}
|
+}
|
||||||
+
|
+
|
||||||
+QStringList Device::interfaces() const
|
+QStringList Device::interfaces() const
|
||||||
+{
|
+{
|
||||||
+ return m_interfaces;
|
+ return m_backend->interfaces();
|
||||||
+}
|
+}
|
||||||
+
|
+
|
||||||
+void Device::initInterfaces()
|
|
||||||
+{
|
|
||||||
+ m_interfaces.clear();
|
|
||||||
+ const QString xmlData = introspect();
|
|
||||||
+ QDomDocument dom;
|
|
||||||
+ dom.setContent(xmlData);
|
|
||||||
+ QDomNodeList ifaceNodeList = dom.elementsByTagName("interface");
|
|
||||||
+ for (int i = 0; i < ifaceNodeList.count(); i++) {
|
|
||||||
+ QDomElement ifaceElem = ifaceNodeList.item(i).toElement();
|
|
||||||
+ if (!ifaceElem.isNull())
|
|
||||||
+ m_interfaces.append(ifaceElem.attribute("name"));
|
|
||||||
+ }
|
|
||||||
+ //qDebug() << "Device" << m_udi << "has interfaces:" << m_interfaces;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+void Device::slotPropertiesChanged(const QString &ifaceName, const QVariantMap &changedProps, const QStringList &invalidatedProps)
|
|
||||||
+{
|
|
||||||
+ //Q_UNUSED(ifaceName);
|
|
||||||
+
|
|
||||||
+ qDebug() << m_udi << "'s interface" << ifaceName << "changed props:";
|
|
||||||
+
|
|
||||||
+ QMap<QString, int> changeMap;
|
|
||||||
+
|
|
||||||
+ Q_FOREACH(const QString & key, invalidatedProps) {
|
|
||||||
+ m_cache.remove(key);
|
|
||||||
+ changeMap.insert(key, Solid::GenericInterface::PropertyRemoved);
|
|
||||||
+ qDebug() << "\t invalidated:" << key;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ QMapIterator<QString, QVariant> i(changedProps);
|
|
||||||
+ while (i.hasNext()) {
|
|
||||||
+ i.next();
|
|
||||||
+ const QString key = i.key();
|
|
||||||
+ m_cache.insert(key, i.value()); // replace the value
|
|
||||||
+ changeMap.insert(key, Solid::GenericInterface::PropertyModified);
|
|
||||||
+ qDebug() << "\t modified:" << key << ":" << m_cache.value(key);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ Q_EMIT propertyChanged(changeMap);
|
|
||||||
+ Q_EMIT changed();
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+void Device::slotInterfacesAdded(const QDBusObjectPath &object_path, const QVariantMapMap &interfaces_and_properties)
|
|
||||||
+{
|
|
||||||
+ if (object_path.path() == m_udi) {
|
|
||||||
+ m_interfaces.append(interfaces_and_properties.keys());
|
|
||||||
+ }
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+void Device::slotInterfacesRemoved(const QDBusObjectPath &object_path, const QStringList &interfaces)
|
|
||||||
+{
|
|
||||||
+ if (object_path.path() == m_udi) {
|
|
||||||
+ Q_FOREACH(const QString & iface, interfaces) {
|
|
||||||
+ m_interfaces.removeAll(iface);
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+
|
|
||||||
+QString Device::errorToString(const QString & error) const
|
+QString Device::errorToString(const QString & error) const
|
||||||
+{
|
+{
|
||||||
+ if (error == UD2_ERROR_UNAUTHORIZED || error == UD2_ERROR_NOT_AUTHORIZED)
|
+ if (error == UD2_ERROR_UNAUTHORIZED || error == UD2_ERROR_NOT_AUTHORIZED)
|
||||||
|
@ -1405,10 +1283,10 @@ index 0000000..3508d57
|
||||||
+}
|
+}
|
||||||
diff --git a/solid/solid/backends/udisks2/udisksdevice.h b/solid/solid/backends/udisks2/udisksdevice.h
|
diff --git a/solid/solid/backends/udisks2/udisksdevice.h b/solid/solid/backends/udisks2/udisksdevice.h
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000..ee6bc1b
|
index 0000000..90bb042
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/solid/solid/backends/udisks2/udisksdevice.h
|
+++ b/solid/solid/backends/udisks2/udisksdevice.h
|
||||||
@@ -0,0 +1,115 @@
|
@@ -0,0 +1,103 @@
|
||||||
+/*
|
+/*
|
||||||
+ Copyright 2010 Michael Zanetti <mzanetti@kde.org>
|
+ Copyright 2010 Michael Zanetti <mzanetti@kde.org>
|
||||||
+ Copyright 2010-2012 Lukáš Tinkl <ltinkl@redhat.com>
|
+ Copyright 2010-2012 Lukáš Tinkl <ltinkl@redhat.com>
|
||||||
|
@ -1450,6 +1328,8 @@ index 0000000..ee6bc1b
|
||||||
+namespace UDisks2
|
+namespace UDisks2
|
||||||
+{
|
+{
|
||||||
+
|
+
|
||||||
|
+class DeviceBackend;
|
||||||
|
+
|
||||||
+class Device: public Solid::Ifaces::Device
|
+class Device: public Solid::Ifaces::Device
|
||||||
+{
|
+{
|
||||||
+ Q_OBJECT
|
+ Q_OBJECT
|
||||||
|
@ -1498,25 +1378,11 @@ index 0000000..ee6bc1b
|
||||||
+ void changed();
|
+ void changed();
|
||||||
+ void propertyChanged(const QMap<QString,int> &changes);
|
+ void propertyChanged(const QMap<QString,int> &changes);
|
||||||
+
|
+
|
||||||
+private Q_SLOTS:
|
|
||||||
+ void slotPropertiesChanged(const QString & ifaceName, const QVariantMap & changedProps, const QStringList & invalidatedProps);
|
|
||||||
+ void slotInterfacesAdded(const QDBusObjectPath &object_path, const QVariantMapMap &interfaces_and_properties);
|
|
||||||
+ void slotInterfacesRemoved(const QDBusObjectPath &object_path, const QStringList &interfaces);
|
|
||||||
+
|
|
||||||
+private:
|
+private:
|
||||||
+ QString storageDescription() const;
|
+ QString storageDescription() const;
|
||||||
+ QString volumeDescription() const;
|
+ QString volumeDescription() const;
|
||||||
+ mutable QDBusInterface *m_device;
|
|
||||||
+ QString m_udi;
|
|
||||||
+ mutable QVariantMap m_cache;
|
|
||||||
+
|
+
|
||||||
+ void initInterfaces();
|
+ DeviceBackend *m_backend;
|
||||||
+ QStringList m_interfaces;
|
|
||||||
+
|
|
||||||
+ void checkCache(const QString &key) const;
|
|
||||||
+ QString introspect() const;
|
|
||||||
+
|
|
||||||
+ QDBusConnection m_connection;
|
|
||||||
+};
|
+};
|
||||||
+
|
+
|
||||||
+}
|
+}
|
||||||
|
@ -1524,6 +1390,305 @@ index 0000000..ee6bc1b
|
||||||
+}
|
+}
|
||||||
+
|
+
|
||||||
+#endif // UDISKS2DEVICE_H
|
+#endif // UDISKS2DEVICE_H
|
||||||
|
diff --git a/solid/solid/backends/udisks2/udisksdevicebackend.cpp b/solid/solid/backends/udisks2/udisksdevicebackend.cpp
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000..895a79c
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/solid/solid/backends/udisks2/udisksdevicebackend.cpp
|
||||||
|
@@ -0,0 +1,203 @@
|
||||||
|
+/*
|
||||||
|
+ Copyright 2010 Michael Zanetti <mzanetti@kde.org>
|
||||||
|
+ Copyright 2010-2012 Lukáš Tinkl <ltinkl@redhat.com>
|
||||||
|
+ Copyright 2012 Dan Vrátil <dvratil@redhat.com>
|
||||||
|
+
|
||||||
|
+ This library is free software; you can redistribute it and/or
|
||||||
|
+ modify it under the terms of the GNU Lesser General Public
|
||||||
|
+ License as published by the Free Software Foundation; either
|
||||||
|
+ version 2.1 of the License, or (at your option) version 3, or any
|
||||||
|
+ later version accepted by the membership of KDE e.V. (or its
|
||||||
|
+ successor approved by the membership of KDE e.V.), which shall
|
||||||
|
+ act as a proxy defined in Section 6 of version 3 of the license.
|
||||||
|
+
|
||||||
|
+ This library is distributed in the hope that it will be useful,
|
||||||
|
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
+ Lesser General Public License for more details.
|
||||||
|
+
|
||||||
|
+ You should have received a copy of the GNU Lesser General Public
|
||||||
|
+ License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
+*/
|
||||||
|
+
|
||||||
|
+#include "udisksdevicebackend.h"
|
||||||
|
+
|
||||||
|
+#include <QtDBus/QDBusConnection>
|
||||||
|
+#include <QtDBus/QDBusInterface>
|
||||||
|
+#include <QtXml/QDomDocument>
|
||||||
|
+
|
||||||
|
+#include "solid/deviceinterface.h"
|
||||||
|
+#include "solid/genericinterface.h"
|
||||||
|
+
|
||||||
|
+using namespace Solid::Backends::UDisks2;
|
||||||
|
+
|
||||||
|
+/* Static cache for DeviceBackends for all UDIs */
|
||||||
|
+QMap<QString /* UDI */, DeviceBackend*> DeviceBackend::s_backends;
|
||||||
|
+
|
||||||
|
+DeviceBackend* DeviceBackend::backendForUDI(const QString& udi)
|
||||||
|
+{
|
||||||
|
+ DeviceBackend *backend = 0;
|
||||||
|
+
|
||||||
|
+ if (s_backends.contains(udi)) {
|
||||||
|
+ backend = s_backends.value(udi);
|
||||||
|
+ } else {
|
||||||
|
+ backend = new DeviceBackend(udi);
|
||||||
|
+ s_backends.insert(udi, backend);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ return backend;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+DeviceBackend::DeviceBackend(const QString& udi)
|
||||||
|
+ : udi(udi)
|
||||||
|
+{
|
||||||
|
+ qDebug() << udi;
|
||||||
|
+ m_device = new QDBusInterface(UD2_DBUS_SERVICE, udi,
|
||||||
|
+ QString(), // no interface, we aggregate them
|
||||||
|
+ QDBusConnection::systemBus());
|
||||||
|
+
|
||||||
|
+ if (m_device->isValid()) {
|
||||||
|
+ QDBusConnection::systemBus().connect(UD2_DBUS_SERVICE, udi, DBUS_INTERFACE_PROPS, "PropertiesChanged", this,
|
||||||
|
+ SLOT(slotPropertiesChanged(QString,QVariantMap,QStringList)));
|
||||||
|
+ QDBusConnection::systemBus().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",
|
||||||
|
+ this, SLOT(slotInterfacesRemoved(QDBusObjectPath,QStringList)));
|
||||||
|
+
|
||||||
|
+ initInterfaces();
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+DeviceBackend::~DeviceBackend()
|
||||||
|
+{
|
||||||
|
+ delete m_device;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+void DeviceBackend::initInterfaces()
|
||||||
|
+{
|
||||||
|
+ m_interfaces.clear();
|
||||||
|
+ const QString xmlData = introspect();
|
||||||
|
+ QDomDocument dom;
|
||||||
|
+ dom.setContent(xmlData);
|
||||||
|
+ QDomNodeList ifaceNodeList = dom.elementsByTagName("interface");
|
||||||
|
+ for (int i = 0; i < ifaceNodeList.count(); i++) {
|
||||||
|
+ QDomElement ifaceElem = ifaceNodeList.item(i).toElement();
|
||||||
|
+ if (!ifaceElem.isNull())
|
||||||
|
+ m_interfaces.append(ifaceElem.attribute("name"));
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+QStringList DeviceBackend::interfaces() const
|
||||||
|
+{
|
||||||
|
+ return m_interfaces;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+QString DeviceBackend::introspect() const
|
||||||
|
+{
|
||||||
|
+ QDBusMessage call = QDBusMessage::createMethodCall(UD2_DBUS_SERVICE, udi,
|
||||||
|
+ DBUS_INTERFACE_INTROSPECT, "Introspect");
|
||||||
|
+ QDBusPendingReply<QString> reply = QDBusConnection::systemBus().call(call);
|
||||||
|
+
|
||||||
|
+ if (reply.isValid())
|
||||||
|
+ return reply.value();
|
||||||
|
+ else {
|
||||||
|
+ return QString();
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+QVariant DeviceBackend::prop(const QString& key)
|
||||||
|
+{
|
||||||
|
+ checkCache(key);
|
||||||
|
+ return m_propertyCache.value(key);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+bool DeviceBackend::propertyExists(const QString& key)
|
||||||
|
+{
|
||||||
|
+ checkCache(key);
|
||||||
|
+ return m_propertyCache.contains(key);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+QVariantMap DeviceBackend::allProperties() const
|
||||||
|
+{
|
||||||
|
+ QDBusMessage call = QDBusMessage::createMethodCall(UD2_DBUS_SERVICE, udi, DBUS_INTERFACE_PROPS, "GetAll");
|
||||||
|
+
|
||||||
|
+ Q_FOREACH (const QString & iface, m_interfaces) {
|
||||||
|
+ if (iface.startsWith("org.freedesktop.DBus")) {
|
||||||
|
+ continue;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ call.setArguments(QVariantList() << iface);
|
||||||
|
+ QDBusPendingReply<QVariantMap> reply = QDBusConnection::systemBus().call(call);
|
||||||
|
+
|
||||||
|
+ if (reply.isValid()) {
|
||||||
|
+ m_propertyCache.unite(reply.value());
|
||||||
|
+ } else {
|
||||||
|
+ qWarning() << "Error getting props:" << reply.error().name() << reply.error().message();
|
||||||
|
+ }
|
||||||
|
+ //qDebug() << "After iface" << iface << ", cache now contains" << m_cache.size() << "items";
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ return m_propertyCache;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+void DeviceBackend::checkCache(const QString& key) const
|
||||||
|
+{
|
||||||
|
+ if (m_propertyCache.isEmpty()) { // recreate the cache
|
||||||
|
+ allProperties();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if (m_propertyCache.contains(key)) {
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ QVariant reply = m_device->property(key.toUtf8());
|
||||||
|
+
|
||||||
|
+ if (reply.isValid()) {
|
||||||
|
+ m_propertyCache.insert(key, reply);
|
||||||
|
+ } else {
|
||||||
|
+ qWarning() << "got invalid reply for cache:" << key;
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+void DeviceBackend::slotPropertiesChanged(const QString& ifaceName, const QVariantMap& changedProps, const QStringList& invalidatedProps)
|
||||||
|
+{
|
||||||
|
+ qDebug() << udi << "'s interface" << ifaceName << "changed props:";
|
||||||
|
+
|
||||||
|
+ QMap<QString, int> changeMap;
|
||||||
|
+
|
||||||
|
+ Q_FOREACH(const QString & key, invalidatedProps) {
|
||||||
|
+ m_propertyCache.remove(key);
|
||||||
|
+ changeMap.insert(key, Solid::GenericInterface::PropertyRemoved);
|
||||||
|
+ qDebug() << "\t invalidated:" << key;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ QMapIterator<QString, QVariant> i(changedProps);
|
||||||
|
+ while (i.hasNext()) {
|
||||||
|
+ i.next();
|
||||||
|
+ const QString key = i.key();
|
||||||
|
+ m_propertyCache.insert(key, i.value()); // replace the value
|
||||||
|
+ changeMap.insert(key, Solid::GenericInterface::PropertyModified);
|
||||||
|
+ qDebug() << "\t modified:" << key << ":" << m_propertyCache.value(key);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ Q_EMIT propertyChanged(changeMap);
|
||||||
|
+ Q_EMIT changed();
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+void DeviceBackend::slotInterfacesAdded(const QDBusObjectPath& object_path, const QVariantMapMap& interfaces_and_properties)
|
||||||
|
+{
|
||||||
|
+ if (object_path.path() == udi) {
|
||||||
|
+ m_interfaces.append(interfaces_and_properties.keys());
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+void DeviceBackend::slotInterfacesRemoved(const QDBusObjectPath& object_path, const QStringList& interfaces)
|
||||||
|
+{
|
||||||
|
+ if (object_path.path() == udi) {
|
||||||
|
+ Q_FOREACH(const QString & iface, interfaces) {
|
||||||
|
+ m_interfaces.removeAll(iface);
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
diff --git a/solid/solid/backends/udisks2/udisksdevicebackend.h b/solid/solid/backends/udisks2/udisksdevicebackend.h
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000..4953ad5
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/solid/solid/backends/udisks2/udisksdevicebackend.h
|
||||||
|
@@ -0,0 +1,83 @@
|
||||||
|
+/*
|
||||||
|
+ Copyright 2010 Michael Zanetti <mzanetti@kde.org>
|
||||||
|
+ Copyright 2010-2012 Lukáš Tinkl <ltinkl@redhat.com>
|
||||||
|
+ Copyright 2012 Dan Vrátil <dvratil@redhat.com>
|
||||||
|
+
|
||||||
|
+ This library is free software; you can redistribute it and/or
|
||||||
|
+ modify it under the terms of the GNU Lesser General Public
|
||||||
|
+ License as published by the Free Software Foundation; either
|
||||||
|
+ version 2.1 of the License, or (at your option) version 3, or any
|
||||||
|
+ later version accepted by the membership of KDE e.V. (or its
|
||||||
|
+ successor approved by the membership of KDE e.V.), which shall
|
||||||
|
+ act as a proxy defined in Section 6 of version 3 of the license.
|
||||||
|
+
|
||||||
|
+ This library is distributed in the hope that it will be useful,
|
||||||
|
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
+ Lesser General Public License for more details.
|
||||||
|
+
|
||||||
|
+ You should have received a copy of the GNU Lesser General Public
|
||||||
|
+ License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
+*/
|
||||||
|
+
|
||||||
|
+#ifndef UDISKSDEVICEBACKEND_H
|
||||||
|
+#define UDISKSDEVICEBACKEND_H
|
||||||
|
+
|
||||||
|
+#include <QObject>
|
||||||
|
+#include <QtDBus/QDBusConnection>
|
||||||
|
+#include <QtDBus/QDBusObjectPath>
|
||||||
|
+#include <QtDBus/QDBusInterface>
|
||||||
|
+#include <QStringList>
|
||||||
|
+
|
||||||
|
+#include "udisks2.h"
|
||||||
|
+
|
||||||
|
+namespace Solid {
|
||||||
|
+namespace Backends {
|
||||||
|
+namespace UDisks2 {
|
||||||
|
+
|
||||||
|
+class DeviceBackend: public QObject {
|
||||||
|
+
|
||||||
|
+ Q_OBJECT
|
||||||
|
+
|
||||||
|
+ public:
|
||||||
|
+ static DeviceBackend* backendForUDI(const QString &udi);
|
||||||
|
+
|
||||||
|
+ DeviceBackend(const QString &udi);
|
||||||
|
+ ~DeviceBackend();
|
||||||
|
+
|
||||||
|
+ void initInterfaces();
|
||||||
|
+ QString introspect() const;
|
||||||
|
+
|
||||||
|
+ QVariant prop(const QString &key);
|
||||||
|
+ bool propertyExists(const QString &key);
|
||||||
|
+ QVariantMap allProperties() const;
|
||||||
|
+ void checkCache(const QString &key) const;
|
||||||
|
+
|
||||||
|
+ QStringList interfaces() const;
|
||||||
|
+
|
||||||
|
+ QString udi;
|
||||||
|
+
|
||||||
|
+ Q_SIGNALS:
|
||||||
|
+ void propertyChanged(const QMap<QString, int> &changeMap);
|
||||||
|
+ void changed();
|
||||||
|
+
|
||||||
|
+ private Q_SLOTS:
|
||||||
|
+ void slotInterfacesAdded(const QDBusObjectPath &object_path, const QVariantMapMap &interfaces_and_properties);
|
||||||
|
+ void slotInterfacesRemoved(const QDBusObjectPath &object_path, const QStringList &interfaces);
|
||||||
|
+ void slotPropertiesChanged(const QString &ifaceName, const QVariantMap &changedProps, const QStringList &invalidatedProps);
|
||||||
|
+
|
||||||
|
+ private:
|
||||||
|
+ QDBusInterface *m_device;
|
||||||
|
+
|
||||||
|
+ mutable QVariantMap m_propertyCache;
|
||||||
|
+ QStringList m_interfaces;
|
||||||
|
+
|
||||||
|
+ static QMap<QString, DeviceBackend*> s_backends;
|
||||||
|
+
|
||||||
|
+};
|
||||||
|
+
|
||||||
|
+} /* namespace UDisks2 */
|
||||||
|
+} /* namespace Backends */
|
||||||
|
+} /* namespace Solid */
|
||||||
|
+
|
||||||
|
+#endif /* UDISKSDEVICEBACKEND_H */
|
||||||
|
\ No newline at end of file
|
||||||
diff --git a/solid/solid/backends/udisks2/udisksdeviceinterface.cpp b/solid/solid/backends/udisks2/udisksdeviceinterface.cpp
|
diff --git a/solid/solid/backends/udisks2/udisksdeviceinterface.cpp b/solid/solid/backends/udisks2/udisksdeviceinterface.cpp
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000..9fa60e5
|
index 0000000..9fa60e5
|
||||||
|
@ -1841,10 +2006,10 @@ index 0000000..d225f32
|
||||||
+#endif // SOLID_BACKENDS_UDISKS2_GENERICINTERFACE_H
|
+#endif // SOLID_BACKENDS_UDISKS2_GENERICINTERFACE_H
|
||||||
diff --git a/solid/solid/backends/udisks2/udisksmanager.cpp b/solid/solid/backends/udisks2/udisksmanager.cpp
|
diff --git a/solid/solid/backends/udisks2/udisksmanager.cpp b/solid/solid/backends/udisks2/udisksmanager.cpp
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000..e781abb
|
index 0000000..69e053f
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/solid/solid/backends/udisks2/udisksmanager.cpp
|
+++ b/solid/solid/backends/udisks2/udisksmanager.cpp
|
||||||
@@ -0,0 +1,239 @@
|
@@ -0,0 +1,238 @@
|
||||||
+/*
|
+/*
|
||||||
+ Copyright 2012 Lukáš Tinkl <ltinkl@redhat.com>
|
+ Copyright 2012 Lukáš Tinkl <ltinkl@redhat.com>
|
||||||
+
|
+
|
||||||
|
@ -1879,10 +2044,9 @@ index 0000000..e781abb
|
||||||
+
|
+
|
||||||
+Manager::Manager(QObject *parent)
|
+Manager::Manager(QObject *parent)
|
||||||
+ : Solid::Ifaces::DeviceManager(parent),
|
+ : Solid::Ifaces::DeviceManager(parent),
|
||||||
+ m_connection(QDBusConnection::connectToBus(QDBusConnection::SystemBus, "Solid::Udisks2")),
|
|
||||||
+ m_manager(UD2_DBUS_SERVICE,
|
+ m_manager(UD2_DBUS_SERVICE,
|
||||||
+ UD2_DBUS_PATH,
|
+ UD2_DBUS_PATH,
|
||||||
+ m_connection)
|
+ QDBusConnection::systemBus())
|
||||||
+{
|
+{
|
||||||
+ m_supportedInterfaces
|
+ m_supportedInterfaces
|
||||||
+ << Solid::DeviceInterface::GenericInterface
|
+ << Solid::DeviceInterface::GenericInterface
|
||||||
|
@ -1907,9 +2071,9 @@ index 0000000..e781abb
|
||||||
+ "org.freedesktop.DBus",
|
+ "org.freedesktop.DBus",
|
||||||
+ "ListActivatableNames");
|
+ "ListActivatableNames");
|
||||||
+
|
+
|
||||||
+ QDBusReply<QStringList> reply = m_connection.call(message);
|
+ QDBusReply<QStringList> reply = QDBusConnection::systemBus().call(message);
|
||||||
+ if (reply.isValid() && reply.value().contains(UD2_DBUS_SERVICE)) {
|
+ if (reply.isValid() && reply.value().contains(UD2_DBUS_SERVICE)) {
|
||||||
+ m_connection.interface()->startService(UD2_DBUS_SERVICE);
|
+ QDBusConnection::systemBus().interface()->startService(UD2_DBUS_SERVICE);
|
||||||
+ serviceFound = true;
|
+ serviceFound = true;
|
||||||
+ }
|
+ }
|
||||||
+ }
|
+ }
|
||||||
|
@ -1924,6 +2088,7 @@ index 0000000..e781abb
|
||||||
+
|
+
|
||||||
+Manager::~Manager()
|
+Manager::~Manager()
|
||||||
+{
|
+{
|
||||||
|
+ QDBusConnection::systemBus().disconnectFromBus("Solid::UDisks2");
|
||||||
+}
|
+}
|
||||||
+
|
+
|
||||||
+QObject* Manager::createDevice(const QString& udi)
|
+QObject* Manager::createDevice(const QString& udi)
|
||||||
|
@ -1987,8 +2152,7 @@ index 0000000..e781abb
|
||||||
+{
|
+{
|
||||||
+ QDBusMessage call = QDBusMessage::createMethodCall(UD2_DBUS_SERVICE, path,
|
+ QDBusMessage call = QDBusMessage::createMethodCall(UD2_DBUS_SERVICE, path,
|
||||||
+ DBUS_INTERFACE_INTROSPECT, "Introspect");
|
+ DBUS_INTERFACE_INTROSPECT, "Introspect");
|
||||||
+ QDBusPendingReply<QString> reply = QDBusConnection::systemBus().asyncCall(call);
|
+ QDBusPendingReply<QString> reply = QDBusConnection::systemBus().call(call);
|
||||||
+ reply.waitForFinished();
|
|
||||||
+
|
+
|
||||||
+ if (reply.isValid()) {
|
+ if (reply.isValid()) {
|
||||||
+ QDomDocument dom;
|
+ QDomDocument dom;
|
||||||
|
@ -2002,7 +2166,7 @@ index 0000000..e781abb
|
||||||
+ if (checkOptical) {
|
+ if (checkOptical) {
|
||||||
+ Device device(udi);
|
+ Device device(udi);
|
||||||
+ if (device.mightBeOpticalDisc()) {
|
+ if (device.mightBeOpticalDisc()) {
|
||||||
+ m_connection.connect(UD2_DBUS_SERVICE, udi, DBUS_INTERFACE_PROPS, "PropertiesChanged", this,
|
+ QDBusConnection::systemBus().connect(UD2_DBUS_SERVICE, udi, DBUS_INTERFACE_PROPS, "PropertiesChanged", this,
|
||||||
+ SLOT(slotMediaChanged(QDBusMessage)));
|
+ SLOT(slotMediaChanged(QDBusMessage)));
|
||||||
+ if (!device.isOpticalDisc()) // skip empty CD disc
|
+ if (!device.isOpticalDisc()) // skip empty CD disc
|
||||||
+ continue;
|
+ continue;
|
||||||
|
@ -2086,10 +2250,10 @@ index 0000000..e781abb
|
||||||
+
|
+
|
||||||
diff --git a/solid/solid/backends/udisks2/udisksmanager.h b/solid/solid/backends/udisks2/udisksmanager.h
|
diff --git a/solid/solid/backends/udisks2/udisksmanager.h b/solid/solid/backends/udisks2/udisksmanager.h
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000..bf74703
|
index 0000000..fb929ce
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/solid/solid/backends/udisks2/udisksmanager.h
|
+++ b/solid/solid/backends/udisks2/udisksmanager.h
|
||||||
@@ -0,0 +1,71 @@
|
@@ -0,0 +1,70 @@
|
||||||
+/*
|
+/*
|
||||||
+ Copyright 2010 Michael Zanetti <mzanetti@kde.org>
|
+ Copyright 2010 Michael Zanetti <mzanetti@kde.org>
|
||||||
+ Copyright 2010-2012 Lukáš Tinkl <ltinkl@redhat.com>
|
+ Copyright 2010-2012 Lukáš Tinkl <ltinkl@redhat.com>
|
||||||
|
@ -2152,7 +2316,6 @@ index 0000000..bf74703
|
||||||
+ const QStringList &deviceCache();
|
+ const QStringList &deviceCache();
|
||||||
+ void introspect(const QString & path, bool checkOptical = false);
|
+ void introspect(const QString & path, bool checkOptical = false);
|
||||||
+ QSet<Solid::DeviceInterface::Type> m_supportedInterfaces;
|
+ QSet<Solid::DeviceInterface::Type> m_supportedInterfaces;
|
||||||
+ QDBusConnection m_connection;
|
|
||||||
+ org::freedesktop::DBus::ObjectManager m_manager;
|
+ org::freedesktop::DBus::ObjectManager m_manager;
|
||||||
+ QStringList m_deviceCache;
|
+ QStringList m_deviceCache;
|
||||||
+};
|
+};
|
||||||
|
@ -2541,10 +2704,10 @@ index 0000000..0cdcc66
|
||||||
+#endif // UDISKS2OPTICALDISC_H
|
+#endif // UDISKS2OPTICALDISC_H
|
||||||
diff --git a/solid/solid/backends/udisks2/udisksopticaldrive.cpp b/solid/solid/backends/udisks2/udisksopticaldrive.cpp
|
diff --git a/solid/solid/backends/udisks2/udisksopticaldrive.cpp b/solid/solid/backends/udisks2/udisksopticaldrive.cpp
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000..8ad3df0
|
index 0000000..74a901e
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/solid/solid/backends/udisks2/udisksopticaldrive.cpp
|
+++ b/solid/solid/backends/udisks2/udisksopticaldrive.cpp
|
||||||
@@ -0,0 +1,222 @@
|
@@ -0,0 +1,226 @@
|
||||||
+/*
|
+/*
|
||||||
+ Copyright 2010 Michael Zanetti <mzanetti@kde.org>
|
+ Copyright 2010 Michael Zanetti <mzanetti@kde.org>
|
||||||
+ Copyright 2010-2012 Lukáš Tinkl <ltinkl@redhat.com>
|
+ Copyright 2010-2012 Lukáš Tinkl <ltinkl@redhat.com>
|
||||||
|
@ -2585,7 +2748,11 @@ index 0000000..8ad3df0
|
||||||
+using namespace Solid::Backends::UDisks2;
|
+using namespace Solid::Backends::UDisks2;
|
||||||
+
|
+
|
||||||
+OpticalDrive::OpticalDrive(Device *device)
|
+OpticalDrive::OpticalDrive(Device *device)
|
||||||
+ : StorageDrive(device), m_ejectInProgress(false), m_readSpeed(0), m_writeSpeed(0), m_speedsInit(false)
|
+ : StorageDrive(device)
|
||||||
|
+ , m_ejectInProgress(false)
|
||||||
|
+ , m_readSpeed(0)
|
||||||
|
+ , m_writeSpeed(0)
|
||||||
|
+ , m_speedsInit(false)
|
||||||
+{
|
+{
|
||||||
+ m_device->registerAction("eject", this,
|
+ m_device->registerAction("eject", this,
|
||||||
+ SLOT(slotEjectRequested()),
|
+ SLOT(slotEjectRequested()),
|
||||||
|
@ -2606,7 +2773,7 @@ index 0000000..8ad3df0
|
||||||
+ m_device->broadcastActionRequested("eject");
|
+ m_device->broadcastActionRequested("eject");
|
||||||
+
|
+
|
||||||
+ const QString path = m_device->udi();
|
+ const QString path = m_device->udi();
|
||||||
+ QDBusConnection c = QDBusConnection::connectToBus(QDBusConnection::SystemBus, "Solid::Udisks2::OpticalDrive::" + path);
|
+ QDBusConnection c = QDBusConnection::systemBus();
|
||||||
+
|
+
|
||||||
+ // if the device is mounted, unmount first
|
+ // if the device is mounted, unmount first
|
||||||
+ QString blockPath;
|
+ QString blockPath;
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
|
|
||||||
Summary: KDE Libraries
|
Summary: KDE Libraries
|
||||||
Version: 4.9.3
|
Version: 4.9.3
|
||||||
Release: 6%{?dist}
|
Release: 7%{?dist}
|
||||||
|
|
||||||
Name: kdelibs
|
Name: kdelibs
|
||||||
Epoch: 6
|
Epoch: 6
|
||||||
|
@ -596,6 +596,9 @@ rm -rf %{buildroot}
|
||||||
|
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Fri Nov 30 2012 Dan Vrátil <dvratil@redhat.com> - 6:4.9.3-7
|
||||||
|
- update udisks2 backend patch
|
||||||
|
|
||||||
* Thu Nov 29 2012 Than Ngo <than@redhat.com> - 6:4.9.3-6
|
* Thu Nov 29 2012 Than Ngo <than@redhat.com> - 6:4.9.3-6
|
||||||
- fix file filter
|
- fix file filter
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue