Update copy of Solid to KDE4.10.5
This commit is contained in:
committed by
craig.p.drummond
parent
8a57bf1052
commit
30637bda8e
@@ -34,7 +34,7 @@ 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* DeviceBackend::backendForUDI(const QString& udi, bool create)
|
||||
{
|
||||
DeviceBackend *backend = 0;
|
||||
if (udi.isEmpty()) {
|
||||
@@ -43,7 +43,7 @@ DeviceBackend* DeviceBackend::backendForUDI(const QString& udi)
|
||||
|
||||
if (s_backends.contains(udi)) {
|
||||
backend = s_backends.value(udi);
|
||||
} else {
|
||||
} else if (create) {
|
||||
backend = new DeviceBackend(udi);
|
||||
s_backends.insert(udi, backend);
|
||||
}
|
||||
@@ -154,6 +154,11 @@ QVariantMap DeviceBackend::allProperties() const
|
||||
return m_propertyCache;
|
||||
}
|
||||
|
||||
void DeviceBackend::invalidateProperties()
|
||||
{
|
||||
m_propertyCache.clear();
|
||||
}
|
||||
|
||||
QString DeviceBackend::introspect() const
|
||||
{
|
||||
QDBusMessage call = QDBusMessage::createMethodCall(UD2_DBUS_SERVICE, m_udi,
|
||||
|
||||
@@ -40,7 +40,7 @@ class DeviceBackend: public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
static DeviceBackend* backendForUDI(const QString &udi);
|
||||
static DeviceBackend* backendForUDI(const QString &udi, bool create = true);
|
||||
static void destroyBackend(const QString &udi);
|
||||
|
||||
DeviceBackend(const QString &udi);
|
||||
@@ -53,6 +53,7 @@ class DeviceBackend: public QObject {
|
||||
QStringList interfaces() const;
|
||||
const QString & udi() const;
|
||||
|
||||
void invalidateProperties();
|
||||
Q_SIGNALS:
|
||||
void propertyChanged(const QMap<QString, int> &changeMap);
|
||||
void changed();
|
||||
|
||||
@@ -198,6 +198,8 @@ void Manager::slotInterfacesAdded(const QDBusObjectPath &object_path, const QVar
|
||||
|
||||
qDebug() << udi << "has new interfaces:" << interfaces_and_properties.keys();
|
||||
|
||||
updateBackend(udi);
|
||||
|
||||
// new device, we don't know it yet
|
||||
if (!m_deviceCache.contains(udi)) {
|
||||
m_deviceCache.append(udi);
|
||||
@@ -220,6 +222,8 @@ void Manager::slotInterfacesRemoved(const QDBusObjectPath &object_path, const QS
|
||||
|
||||
qDebug() << udi << "lost interfaces:" << interfaces;
|
||||
|
||||
updateBackend(udi);
|
||||
|
||||
Device device(udi);
|
||||
|
||||
if (!udi.isEmpty() && (interfaces.isEmpty() || device.interfaces().isEmpty())) {
|
||||
@@ -237,6 +241,7 @@ void Manager::slotMediaChanged(const QDBusMessage & msg)
|
||||
return;
|
||||
|
||||
const QString udi = msg.path();
|
||||
updateBackend(udi);
|
||||
qulonglong size = properties.value("Size").toULongLong();
|
||||
qDebug() << "MEDIA CHANGED in" << udi << "; size is:" << size;
|
||||
|
||||
@@ -260,3 +265,23 @@ const QStringList & Manager::deviceCache()
|
||||
return m_deviceCache;
|
||||
}
|
||||
|
||||
void Manager::updateBackend(const QString & udi)
|
||||
{
|
||||
DeviceBackend *backend = DeviceBackend::backendForUDI(udi);
|
||||
if (!backend)
|
||||
return;
|
||||
|
||||
//This doesn't emit "changed" signals. Signals are emitted later by DeviceBackend's slots
|
||||
backend->allProperties();
|
||||
|
||||
QVariant driveProp = backend->prop("Drive");
|
||||
if (!driveProp.isValid())
|
||||
return;
|
||||
|
||||
QDBusObjectPath drivePath = qdbus_cast<QDBusObjectPath>(driveProp);
|
||||
DeviceBackend *driveBackend = DeviceBackend::backendForUDI(drivePath.path(), false);
|
||||
if (!driveBackend)
|
||||
return;
|
||||
|
||||
driveBackend->invalidateProperties();
|
||||
}
|
||||
|
||||
@@ -59,6 +59,7 @@ private Q_SLOTS:
|
||||
private:
|
||||
const QStringList &deviceCache();
|
||||
void introspect(const QString & path, bool checkOptical = false);
|
||||
void updateBackend(const QString & udi);
|
||||
QSet<Solid::DeviceInterface::Type> m_supportedInterfaces;
|
||||
org::freedesktop::DBus::ObjectManager m_manager;
|
||||
QStringList m_deviceCache;
|
||||
|
||||
Reference in New Issue
Block a user