[solid] src/solid: Removed deprecated wmi backend for Windows.
Àlex Fiestas
afiestas at kde.org
Tue May 6 15:20:06 UTC 2014
Git commit 55a1fcc5eb2f8346b5a56426205b84cc217e6659 by Àlex Fiestas.
Committed on 06/05/2014 at 15:11.
Pushed by afiestas into branch 'master'.
Removed deprecated wmi backend for Windows.
Acked by ps_ml at gmx.de
CCMAIL: kde-windows at kde.org
M +4 -27 src/solid/CMakeLists.txt
D +0 -17 src/solid/backends/wmi/CMakeLists.txt
D +0 -151 src/solid/backends/wmi/wmibattery.cpp
D +0 -78 src/solid/backends/wmi/wmibattery.h
D +0 -63 src/solid/backends/wmi/wmiblock.cpp
D +0 -50 src/solid/backends/wmi/wmiblock.h
D +0 -73 src/solid/backends/wmi/wmicamera.cpp
D +0 -50 src/solid/backends/wmi/wmicamera.h
D +0 -151 src/solid/backends/wmi/wmicdrom.cpp
D +0 -69 src/solid/backends/wmi/wmicdrom.h
D +0 -649 src/solid/backends/wmi/wmidevice.cpp
D +0 -98 src/solid/backends/wmi/wmidevice.h
D +0 -33 src/solid/backends/wmi/wmideviceinterface.cpp
D +0 -131 src/solid/backends/wmi/wmideviceinterface.h
D +0 -55 src/solid/backends/wmi/wmigenericinterface.cpp
D +0 -57 src/solid/backends/wmi/wmigenericinterface.h
D +0 -262 src/solid/backends/wmi/wmimanager.cpp
D +0 -101 src/solid/backends/wmi/wmimanager.h
D +0 -116 src/solid/backends/wmi/wmiopticaldisc.cpp
D +0 -57 src/solid/backends/wmi/wmiopticaldisc.h
D +0 -68 src/solid/backends/wmi/wmiportablemediaplayer.cpp
D +0 -55 src/solid/backends/wmi/wmiportablemediaplayer.h
D +0 -62 src/solid/backends/wmi/wmiprocessor.cpp
D +0 -53 src/solid/backends/wmi/wmiprocessor.h
D +0 -389 src/solid/backends/wmi/wmiquery.cpp
D +0 -92 src/solid/backends/wmi/wmiquery.h
D +0 -101 src/solid/backends/wmi/wmistorage.cpp
D +0 -57 src/solid/backends/wmi/wmistorage.h
D +0 -203 src/solid/backends/wmi/wmistorageaccess.cpp
D +0 -81 src/solid/backends/wmi/wmistorageaccess.h
D +0 -75 src/solid/backends/wmi/wmivolume.cpp
D +0 -58 src/solid/backends/wmi/wmivolume.h
M +0 -5 src/solid/managerbase.cpp
http://commits.kde.org/solid/55a1fcc5eb2f8346b5a56426205b84cc217e6659
diff --git a/src/solid/CMakeLists.txt b/src/solid/CMakeLists.txt
index 31ee922..3a5eb28 100644
--- a/src/solid/CMakeLists.txt
+++ b/src/solid/CMakeLists.txt
@@ -157,38 +157,15 @@ if(APPLE)
endif()
if(WIN32)
-
- if(WITH_SOLID_WMI)
- include(CheckIncludeFileCXX)
- check_include_file_cxx(wbemidl.h HAVE_WBEM)
- FIND_LIBRARY(WBEM_LIBRARIES NAMES wbemuuid wbemuuidd)
- if(HAVE_WBEM AND WBEM_LIBRARIES)
- set(HAVE_WBEM True)
- message(STATUS "Found wbemuuid library: ${WBEM_LIBRARIES}")
- else()
- set(HAVE_WBEM False)
- set(WITH_SOLID_WMI False)
- endif()
- endif()
- if(WITH_SOLID_WMI)
- add_definitions(-DWITH_SOLID_WMI)
- message(STATUS "-- Building Solid WMI backend." )
- include(backends/wmi/CMakeLists.txt)
- else()
- message(STATUS "-- Building Solid Windows backend." )
- include(backends/win/CMakeLists.txt)
- endif()
+ message(STATUS "-- Building Solid Windows backend." )
+ include(backends/win/CMakeLists.txt)
endif()
set(solid_OPTIONAL_LIBS)
if(WIN32)
- set(solid_OPTIONAL_LIBS ${solid_OPTIONAL_LIBS} Qt5::Network)
- if(WITH_SOLID_WMI)
- set(solid_OPTIONAL_LIBS ${solid_OPTIONAL_LIBS} ${WBEM_LIBRARIES})
- else()
- set(solid_OPTIONAL_LIBS ${solid_OPTIONAL_LIBS} setupapi)
- endif()
+ set(solid_OPTIONAL_LIBS ${solid_OPTIONAL_LIBS} Qt5::Network setupapi)
+ set(solid_OPTIONAL_LIBS ${solid_OPTIONAL_LIBS} setupapi)
endif()
if(APPLE)
diff --git a/src/solid/backends/wmi/CMakeLists.txt b/src/solid/backends/wmi/CMakeLists.txt
deleted file mode 100644
index 189d8f4..0000000
--- a/src/solid/backends/wmi/CMakeLists.txt
+++ /dev/null
@@ -1,17 +0,0 @@
-set(solid_LIB_SRCS ${solid_LIB_SRCS}
- backends/wmi/wmibattery.cpp
- backends/wmi/wmiblock.cpp
- backends/wmi/wmicamera.cpp
- backends/wmi/wmicdrom.cpp
- backends/wmi/wmideviceinterface.cpp
- backends/wmi/wmigenericinterface.cpp
- backends/wmi/wmidevice.cpp
- backends/wmi/wmimanager.cpp
- backends/wmi/wmiopticaldisc.cpp
- backends/wmi/wmiportablemediaplayer.cpp
- backends/wmi/wmiprocessor.cpp
- backends/wmi/wmiquery.cpp
- backends/wmi/wmistorageaccess.cpp
- backends/wmi/wmistorage.cpp
- backends/wmi/wmivolume.cpp
-)
\ No newline at end of file
diff --git a/src/solid/backends/wmi/wmibattery.cpp b/src/solid/backends/wmi/wmibattery.cpp
deleted file mode 100644
index 44fbfc4..0000000
--- a/src/solid/backends/wmi/wmibattery.cpp
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- Copyright 2012 Patrick von Reth <vonreth at kde.org>
- Copyright 2006 Kevin Ottens <ervin at kde.org>
-
- 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 "wmibattery.h"
-
-using namespace Solid::Backends::Wmi;
-
-Battery::Battery(WmiDevice *device)
- : DeviceInterface(device)
-{
-// connect(device, SIGNAL(propertyChanged(QMap<QString,int>)),
-// this, SLOT(slotPropertyChanged(QMap<QString,int>)));
-}
-
-Battery::~Battery()
-{
-
-}
-
-bool Battery::isPlugged() const
-{
- return true;
-}
-
-Solid::Battery::BatteryType Battery::type() const
-{
- //as far as i know peripheral bateries are not listed
- return Solid::Battery::PrimaryBattery;
-}
-
-int Battery::chargePercent() const
-{
- return m_device->property("EstimatedChargeRemaining").toInt();
-}
-
-bool Battery::isRechargeable() const
-{
- return true;
-}
-
-Solid::Battery::ChargeState Battery::chargeState() const
-{
- ushort status = m_device->property("BatteryStatus").toInt();
- bool charging = status == 2 || status >= 6 && status <= 8; //2 = The system has access to AC so no battery is being discharged. However, the battery is not necessarily charging , but windows mostlikly wont tell anything else then 2 or 1
- bool discharging = status == 1 || status >= 3 && status <= 5 || status == 11;
-
- if (!charging && !discharging) {
- return Solid::Battery::NoCharge;
- } else if (charging) {
- return Solid::Battery::Charging;
- } else {
- return Solid::Battery::Discharging;
- }
-}
-
-Solid::Battery::Technology Battery::technology() const
-{
- return Solid::Battery::UnknownTechnology;
-}
-
-int Battery::capacity() const
-{
- return m_device->property("").toInt();
-}
-
-QString Battery::batteryTechnology() const
-{
- const ushort tech = m_device->property("Chemistry").toUInt();
- switch (tech) {
- case 3:
- return tr("Lead Acid", "battery technology");
- case 4:
- return tr("Nickel Cadmium", "battery technology");
- case 5:
- return tr("Nickel Metal Hydride", "battery technology");
- case 6:
- return tr("Lithium Ion", "battery technology");
- case 8:
- return tr("Lithium Polymer", "battery technology");
- default:
- return tr("Unknown", "battery technology");
- }
-}
-
-double Battery::energy() const
-{
- return 0.0;
-}
-
-double Battery::energyRate() const
-{
- return 0.0;
-}
-
-double Battery::voltage() const
-{
- return 0.0;
-}
-
-bool Battery::isPowerSupply() const
-{
- return chargeState() == Solid::Battery::Charging;
-}
-
-int Battery::capacity() const
-{
- const unsigned int fullChargeCapacity = m_device->property("FullChargeCapacity").toUInt();
- const unsigned int designCapacity = m_device->property("DesignCapacity").toUInt();
-
- if (designCapacity == 0) {
- return 0;
- }
- return ((int)(100.0 * fullChargeCapacity / designCapacity));
-}
-
-void Battery::slotPropertyChanged(const QMap<QString, int> &changes)
-{
-// if (changes.contains("battery.charge_level.percentage"))
-// {
-// emit chargePercentChanged(chargePercent(), m_device->udi());
-// }
-// else if (changes.contains("battery.rechargeable.is_charging")
-// || changes.contains("battery.rechargeable.is_discharging"))
-// {
-// emit chargeStateChanged(chargeState(), m_device->udi());
-// }
-// else if ( changes.contains( "battery.present" ) )
-// {
-// emit plugStateChanged(isPlugged(), m_device->udi());
-// }
-
-}
-
diff --git a/src/solid/backends/wmi/wmibattery.h b/src/solid/backends/wmi/wmibattery.h
deleted file mode 100644
index b7aed65..0000000
--- a/src/solid/backends/wmi/wmibattery.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- Copyright 2012 Patrick von Reth <vonreth at kde.org>
- Copyright 2006 Kevin Ottens <ervin at kde.org>
-
- 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 SOLID_BACKENDS_WMI_BATTERY_H
-#define SOLID_BACKENDS_WMI_BATTERY_H
-
-#include <solid/ifaces/battery.h>
-#include "wmideviceinterface.h"
-
-namespace Solid
-{
-namespace Backends
-{
-namespace Wmi
-{
-class Battery : public DeviceInterface, virtual public Solid::Ifaces::Battery
-{
- Q_OBJECT
- Q_INTERFACES(Solid::Ifaces::Battery)
-
-public:
- Battery(WmiDevice *device);
- virtual ~Battery();
-
- virtual bool isPlugged() const;
- virtual Solid::Battery::BatteryType type() const;
-
- virtual int chargePercent() const;
-
- virtual bool isRechargeable() const;
- virtual Solid::Battery::ChargeState chargeState() const;
-
- virtual int capacity() const;
- virtual Solid::Battery::Technology technology() const;
-
- QString batteryTechnology() const;
-
- double energy() const;
- double energyRate() const;
- double voltage() const;
-
- virtual bool isPowerSupply() const;
-
-Q_SIGNALS:
- void chargePercentChanged(int value, const QString &udi);
- void chargeStateChanged(int newState, const QString &udi);
- void plugStateChanged(bool newState, const QString &udi);
- void energyChanged(double energy, const QString &udi);
- void energyRateChanged(double energyRate, const QString &udi);
- void capacityChanged(int value, const QString &udi);
- void powerSupplyStateChanged(bool newState, const QString &udi);
-
-private Q_SLOTS:
- void slotPropertyChanged(const QMap<QString, int> &changes);
-};
-}
-}
-}
-
-#endif // SOLID_BACKENDS_WMI_BATTERY_H
diff --git a/src/solid/backends/wmi/wmiblock.cpp b/src/solid/backends/wmi/wmiblock.cpp
deleted file mode 100644
index 6954ac0..0000000
--- a/src/solid/backends/wmi/wmiblock.cpp
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- Copyright 2006 Kevin Ottens <ervin at kde.org>
-
- 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 "wmiblock.h"
-
-#include "wmidevice.h"
-
-using namespace Solid::Backends::Wmi;
-
-Block::Block(WmiDevice *device)
- : DeviceInterface(device)
-{
-
-}
-
-Block::~Block()
-{
-
-}
-
-int Block::deviceMajor() const
-{
- return 0;
-}
-
-int Block::deviceMinor() const
-{
- return 0;
-}
-
-QString Block::device() const
-{
- QString drive;
- switch (m_device->type()) {
- case Solid::DeviceInterface::StorageVolume: {
- drive = WmiDevice::win32LogicalDiskByDiskPartitionID(m_device->property("DeviceID").toString()).getProperty("DeviceID").toString();
- }
- break;
- case Solid::DeviceInterface::OpticalDrive:
- case Solid::DeviceInterface::OpticalDisc:
- drive = m_device->property("Drive").toString();
- break;
- }
- return drive;
-}
-
diff --git a/src/solid/backends/wmi/wmiblock.h b/src/solid/backends/wmi/wmiblock.h
deleted file mode 100644
index ce53283..0000000
--- a/src/solid/backends/wmi/wmiblock.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- Copyright 2006 Kevin Ottens <ervin at kde.org>
-
- 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 SOLID_BACKENDS_WMI_BLOCK_H
-#define SOLID_BACKENDS_WMI_BLOCK_H
-
-#include <solid/ifaces/block.h>
-#include "wmideviceinterface.h"
-
-namespace Solid
-{
-namespace Backends
-{
-namespace Wmi
-{
-class Block : public DeviceInterface, virtual public Solid::Ifaces::Block
-{
- Q_OBJECT
- Q_INTERFACES(Solid::Ifaces::Block)
-
-public:
- Block(WmiDevice *device);
- virtual ~Block();
-
- virtual int deviceMajor() const;
- virtual int deviceMinor() const;
- virtual QString device() const;
-};
-}
-}
-}
-
-#endif // SOLID_BACKENDS_WMI_BLOCK_H
diff --git a/src/solid/backends/wmi/wmicamera.cpp b/src/solid/backends/wmi/wmicamera.cpp
deleted file mode 100644
index 65fc9d9..0000000
--- a/src/solid/backends/wmi/wmicamera.cpp
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- Copyright 2006 Kevin Ottens <ervin at kde.org>
-
- 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 "wmicamera.h"
-
-using namespace Solid::Backends::Wmi;
-
-Camera::Camera(WmiDevice *device)
- : DeviceInterface(device)
-{
-
-}
-
-Camera::~Camera()
-{
-
-}
-
-QStringList Camera::supportedProtocols() const
-{
- QStringList protocols;
-
- QString method = m_device->property("camera.access_method").toString();
-
- protocols << method;
-
- return protocols;
-}
-
-QStringList Camera::supportedDrivers(QString /*protocol*/) const
-{
- QStringList res;
-
- if (m_device->property("camera.libgphoto2.support").toBool()) {
- res << "gphoto";
- }
-
- return res;
-}
-
-QVariant Solid::Backends::Wmi::Camera::driverHandle(const QString &driver) const
-{
- if (driver == "gphoto"
- && m_device->property("info.subsystem").toString() == "usb") {
- QVariantList list;
-
- list << "usb"
- << m_device->property("usb.vendor_id")
- << m_device->property("usb.product_id");
-
- return list;
- }
-
- return QVariant();
-}
-
diff --git a/src/solid/backends/wmi/wmicamera.h b/src/solid/backends/wmi/wmicamera.h
deleted file mode 100644
index 2436eb6..0000000
--- a/src/solid/backends/wmi/wmicamera.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- Copyright 2006 Kevin Ottens <ervin at kde.org>
-
- 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 SOLID_BACKENDS_WMI_CAMERA_H
-#define SOLID_BACKENDS_WMI_CAMERA_H
-
-#include <solid/ifaces/camera.h>
-#include "wmideviceinterface.h"
-
-namespace Solid
-{
-namespace Backends
-{
-namespace Wmi
-{
-class Camera : public DeviceInterface, virtual public Solid::Ifaces::Camera
-{
- Q_OBJECT
- Q_INTERFACES(Solid::Ifaces::Camera)
-
-public:
- Camera(WmiDevice *device);
- virtual ~Camera();
-
- virtual QStringList supportedProtocols() const;
- virtual QStringList supportedDrivers(QString protocol = QString()) const;
- virtual QVariant driverHandle(const QString &driver) const;
-};
-}
-}
-}
-
-#endif // SOLID_BACKENDS_WMI_CAMERA_H
diff --git a/src/solid/backends/wmi/wmicdrom.cpp b/src/solid/backends/wmi/wmicdrom.cpp
deleted file mode 100644
index dbf0a78..0000000
--- a/src/solid/backends/wmi/wmicdrom.cpp
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- Copyright 2012 Patrick von Reth <vonreth at kde.org>
- Copyright 2006 Kevin Ottens <ervin at kde.org>
-
- 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 "wmicdrom.h"
-
-#include <QtCore/QStringList>
-
-using namespace Solid::Backends::Wmi;
-
-Cdrom::Cdrom(WmiDevice *device)
- : Storage(device), m_ejectInProgress(false)
-{
- connect(device, SIGNAL(conditionRaised(QString,QString)),
- this, SLOT(slotCondition(QString,QString)));
-}
-
-Cdrom::~Cdrom()
-{
-
-}
-
-Solid::OpticalDrive::MediumTypes Cdrom::supportedMedia() const
-{
- Solid::OpticalDrive::MediumTypes supported;
-
- QString type = m_device->property("MediaType").toString();
- if (type == "CdRomOnly" || type == "CD-ROM") {
- supported |= Solid::OpticalDrive::Cdr;
- } else if (type == "CdRomWrite") {
- supported |= Solid::OpticalDrive::Cdr | Solid::OpticalDrive::Cdrw;
- } else if (type == "DVDRomOnly") {
- supported |= Solid::OpticalDrive::Dvd;
- } else if (type == "DVDRomWrite" || type == "DVD Writer") {
- supported |= Solid::OpticalDrive::Dvd | Solid::OpticalDrive::Dvdr | Solid::OpticalDrive::Dvdrw;
- }
-
- return supported;
-}
-
-int Cdrom::readSpeed() const
-{
- return m_device->property("TransferRate").toInt();
-}
-
-int Cdrom::writeSpeed() const
-{
- return m_device->property("TransferRate").toInt();
-}
-
-QList<int> Cdrom::writeSpeeds() const
-{
- QList<int> speeds;
- QStringList speed_strlist = m_device->property("storage.cdrom.write_speeds").toStringList();
-
- Q_FOREACH (const QString &speed_str, speed_strlist) {
- speeds << speed_str.toInt();
- }
-
- return speeds;
-}
-
-void Cdrom::slotCondition(const QString &name, const QString &/*reason */)
-{
- if (name == "EjectPressed") {
- emit ejectPressed(m_device->udi());
- }
-}
-
-bool Cdrom::eject()
-{
- if (m_ejectInProgress) {
- return false;
- }
- m_ejectInProgress = true;
-
- return callWmiDriveEject();
-}
-
-bool Cdrom::callWmiDriveEject()
-{
-// QString udi = m_device->udi();
-// QString interface = "org.freedesktop.Wmi.Device.Storage";
-
- // HACK: Eject doesn't work on cdrom drives when there's a mounted disc,
- // let's try to workaround this by calling a child volume...
- // if (m_device->property("storage.removable.media_available").toBool()) {
- // QDBusInterface manager("org.freedesktop.Wmi",
- // "/org/freedesktop/Wmi/Manager",
- // "org.freedesktop.Wmi.Manager",
- // QDBusConnection::systemBus());
-
- // QDBusReply<QStringList> reply = manager.call("FindDeviceStringMatch", "info.parent", udi);
-
- // if (reply.isValid())
- // {
- // QStringList udis = reply;
- // if (!udis.isEmpty()) {
- // udi = udis[0];
- // interface = "org.freedesktop.Wmi.Device.Volume";
- // }
- // }
- // }
-
- // QDBusConnection c = QDBusConnection::systemBus();
- // QDBusMessage msg = QDBusMessage::createMethodCall("org.freedesktop.Wmi", udi,
- // interface, "Eject");
-
- // msg << QStringList();
-
- // return c.callWithCallback(msg, this,
- // SLOT(slotDBusReply(QDBusMessage)),
- // SLOT(slotDBusError(QDBusError)));
- return false;
-}
-
-void Solid::Backends::Wmi::Cdrom::slotProcessFinished(int exitCode, QProcess::ExitStatus exitStatus)
-{
- Q_UNUSED(exitStatus);
- if (m_ejectInProgress) {
- m_ejectInProgress = false;
-
- if (exitCode == 0) {
- emit ejectDone(Solid::NoError, QVariant(), m_device->udi());
- } else {
- emit ejectDone(Solid::UnauthorizedOperation,
- m_process->readAllStandardError(),
- m_device->udi());
- }
- }
-
- delete m_process;
-}
-
diff --git a/src/solid/backends/wmi/wmicdrom.h b/src/solid/backends/wmi/wmicdrom.h
deleted file mode 100644
index 294ebe8..0000000
--- a/src/solid/backends/wmi/wmicdrom.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- Copyright 2012 Patrick von Reth <vonreth at kde.org>
- Copyright 2006 Kevin Ottens <ervin at kde.org>
-
- 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 SOLID_BACKENDS_WMI_CDROM_H
-#define SOLID_BACKENDS_WMI_CDROM_H
-
-#include <solid/ifaces/opticaldrive.h>
-#include "wmistorage.h"
-
-#include <QtCore/QProcess>
-
-namespace Solid
-{
-namespace Backends
-{
-namespace Wmi
-{
-class Cdrom : public Storage, virtual public Solid::Ifaces::OpticalDrive
-{
- Q_OBJECT
- Q_INTERFACES(Solid::Ifaces::OpticalDrive)
-
-public:
- Cdrom(WmiDevice *device);
- virtual ~Cdrom();
-
- virtual Solid::OpticalDrive::MediumTypes supportedMedia() const;
- virtual int readSpeed() const;
- virtual int writeSpeed() const;
- virtual QList<int> writeSpeeds() const;
- virtual bool eject();
-
-Q_SIGNALS:
- void ejectPressed(const QString &udi);
- void ejectDone(Solid::ErrorType error, QVariant errorData, const QString &udi);
-
-private Q_SLOTS:
- void slotCondition(const QString &name, const QString &reason);
- void slotProcessFinished(int exitCode, QProcess::ExitStatus exitStatus);
-
-private:
- bool callWmiDriveEject();
-
- bool m_ejectInProgress;
- QProcess *m_process;
-};
-}
-}
-}
-
-#endif // SOLID_BACKENDS_WMI_CDROM_H
diff --git a/src/solid/backends/wmi/wmidevice.cpp b/src/solid/backends/wmi/wmidevice.cpp
deleted file mode 100644
index 43f1921..0000000
--- a/src/solid/backends/wmi/wmidevice.cpp
+++ /dev/null
@@ -1,649 +0,0 @@
-/*
- Copyright 2012 Patrick von Reth <vonreth at kde.org>
- Copyright 2005-2007 Kevin Ottens <ervin at kde.org>
-
- 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 "wmidevice.h"
-
-#include <solid/genericinterface.h>
-
-#include "wmiquery.h"
-#include "wmimanager.h"
-#include "wmideviceinterface.h"
-#include "wmigenericinterface.h"
-#include "wmiprocessor.h"
-#include "wmiblock.h"
-#include "wmistorageaccess.h"
-#include "wmistorage.h"
-#include "wmicdrom.h"
-#include "wmivolume.h"
-#include "wmiopticaldisc.h"
-#include "wmicamera.h"
-#include "wmiportablemediaplayer.h"
-#include "wmibattery.h"
-
-#include <QtCore/QDebug>
-
-using namespace Solid::Backends::Wmi;
-
-class Solid::Backends::Wmi::WmiDevicePrivate
-{
-public:
- WmiDevicePrivate(const QString &_udi)
- : parent(0)
- , m_udi(_udi)
- , m_wmiTable()
- , m_wmiProperty()
- , m_wmiValue()
- {
- }
-
- ~WmiDevicePrivate()
- {
- }
-
- void discoverType()
- {
- if (!convertUDItoWMI(m_udi, m_wmiTable, m_wmiProperty, m_wmiValue, m_type)) {
- return;
- }
- interfaceList << getInterfaces(m_type);
-
- }
-
- const QString udi() const
- {
- return m_udi;
- }
-
- WmiQuery::Item sendQuery()
- {
- if (m_item.isNull()) {
- QString query("SELECT * FROM " + m_wmiTable + " WHERE " + m_wmiProperty + "='" + m_wmiValue + "'");
- WmiQuery::ItemList items = WmiQuery::instance().sendQuery(query);
- Q_ASSERT(items.length() == 1);
- if (items.length() != 1) {
- qDebug() << "WmiDevicePrivate::sendQuery() failed";
- }
- m_item = items[0];
- }
- return m_item;
- }
-
- static bool convertUDItoWMI(const QString &udi, QString &wmiTable, QString &wmiProperty, QString &wmiValue, Solid::DeviceInterface::Type &type)
- {
- QString _udi = udi;
- QStringList x = _udi.remove("/org/kde/solid/wmi/").split('/');
- if (x.size() != 2 || x[1].isEmpty()) {
- qDebug() << "invalid udi detected" << udi;
- return false;
- }
- type = DeviceInterface::fromString(x[0]);
- wmiProperty = getPropertyNameForUDI(type);
- wmiValue = x[1];
- wmiTable = getWMITable(type);
-// qDebug()<<"wmi"<< type <<wmiTable <<wmiProperty <<wmiValue;
- return true;
- }
-
- static bool exists(const QString &udi)
- {
- QString wmiTable;
- QString wmiProperty;
- QString wmiValue;
- Solid::DeviceInterface::Type solidDevice;
-
- if (!convertUDItoWMI(udi, wmiTable, wmiProperty, wmiValue, solidDevice)) {
- return false;
- }
-
- QString query("SELECT * FROM " + wmiTable + " WHERE " + wmiProperty + "='" + wmiValue + "'");
- WmiQuery::ItemList list = WmiQuery::instance().sendQuery(query);
- if (list.size() > 0) {
- return true;
- }
- qWarning() << "Device UDI:" << udi << "doesn't exist";
-// qDebug()<<query;
- return false;
- }
-
- static QString generateUDI(const QString &key, const QString &property)
- {
- return QString("/org/kde/solid/wmi/%1/%2").arg(key).arg(property);
- }
-
- static QList<Solid::DeviceInterface::Type> getInterfaces(const Solid::DeviceInterface::Type &type)
- {
- QList<Solid::DeviceInterface::Type> interfaceList;
- interfaceList << type;
-
- switch (type) {
- case Solid::DeviceInterface::GenericInterface:
- break;
- case Solid::DeviceInterface::Processor:
- break;
- case Solid::DeviceInterface::Block:
- break;
- case Solid::DeviceInterface::StorageAccess:
- break;
- case Solid::DeviceInterface::StorageDrive:
- break;
- case Solid::DeviceInterface::OpticalDrive:
- interfaceList << Solid::DeviceInterface::Block << Solid::DeviceInterface::StorageDrive;
- break;
- case Solid::DeviceInterface::StorageVolume:
- interfaceList << Solid::DeviceInterface::Block << Solid::DeviceInterface::StorageAccess;
- break;
- case Solid::DeviceInterface::OpticalDisc:
- interfaceList << Solid::DeviceInterface::Block << Solid::DeviceInterface::StorageVolume;
- break;
- case Solid::DeviceInterface::Camera:
- break;
- case Solid::DeviceInterface::PortableMediaPlayer:
- break;
- case Solid::DeviceInterface::Battery:
- break;
- case Solid::DeviceInterface::Unknown:
- case Solid::DeviceInterface::Last:
- default:
- break;
- }
- if (interfaceList.size() == 0) {
- qWarning() << "no interface found for type" << type;
- }
- return interfaceList;
- }
-
- static QString getUDIKey(const Solid::DeviceInterface::Type &type)
- {
- QStringList list = DeviceInterface::toStringList(type);
- QString value = list.size() > 0 ? list[0] : QString();
- return value;
- }
-
- static QString getWMITable(const Solid::DeviceInterface::Type &type)
- {
- QString wmiTable;
- switch (type) {
- case Solid::DeviceInterface::GenericInterface:
- break;
- case Solid::DeviceInterface::Processor:
- wmiTable = "Win32_Processor";
- break;
- case Solid::DeviceInterface::Block:
- break;
- case Solid::DeviceInterface::StorageAccess:
- wmiTable = "Win32_DiskPartition";
- break;
- case Solid::DeviceInterface::StorageDrive:
- wmiTable = "Win32_DiskDrive";
- break;
- case Solid::DeviceInterface::OpticalDrive:
- wmiTable = "Win32_CDROMDrive";
- break;
- case Solid::DeviceInterface::StorageVolume:
- wmiTable = "Win32_DiskPartition";
- break;
- case Solid::DeviceInterface::OpticalDisc:
- wmiTable = "Win32_CDROMDrive";
- break;
- case Solid::DeviceInterface::Camera:
- break;
- case Solid::DeviceInterface::PortableMediaPlayer:
- break;
- case Solid::DeviceInterface::Battery:
- wmiTable = "Win32_Battery";
- break;
- case Solid::DeviceInterface::Unknown:
- case Solid::DeviceInterface::Last:
- default:
- wmiTable = "unknown";
- break;
- }
- return wmiTable;
- }
-
- static QString getIgnorePattern(const Solid::DeviceInterface::Type &type)
- {
- QString propertyName;
- switch (type) {
- case Solid::DeviceInterface::OpticalDisc:
- propertyName = " WHERE MediaLoaded=TRUE";
- break;
- }
- return propertyName;
- }
-
- static QString getPropertyNameForUDI(const Solid::DeviceInterface::Type &type)
- {
- QString propertyName;
- switch (type) {
- case Solid::DeviceInterface::OpticalDrive:
- case Solid::DeviceInterface::OpticalDisc:
- propertyName = "Drive";
- break;
- case Solid::DeviceInterface::StorageDrive:
- propertyName = "Index";
- break;
- default:
- propertyName = "DeviceID";
- }
-
- return propertyName;
- }
-
- static QStringList generateUDIList(const Solid::DeviceInterface::Type &type)
- {
- QStringList result;
-
- WmiQuery::ItemList list = WmiQuery::instance().sendQuery("SELECT * FROM " + getWMITable(type) + getIgnorePattern(type));
- Q_FOREACH (const WmiQuery::Item &item, list) {
- QString propertyName = getPropertyNameForUDI(type);
- QString property = item.getProperty(propertyName).toString();
- result << generateUDI(getUDIKey(type), property.toLower());
- }
- return result;
- }
-
- WmiDevice *parent;
- static int m_instanceCount;
- QString m_parent_uid;
- QString m_udi;
- QString m_wmiTable;
- QString m_wmiProperty;
- QString m_wmiValue;
- Solid::DeviceInterface::Type m_type;
- WmiQuery::Item m_item;
- QList<Solid::DeviceInterface::Type> interfaceList;
-
-};
-
-Q_DECLARE_METATYPE(ChangeDescription)
-WmiDevice::WmiDevice(const QString &udi)
- : Device(), d(new WmiDevicePrivate(udi))
-{
- d->discoverType();
- Q_FOREACH (Solid::DeviceInterface::Type type, d->interfaceList) {
- createDeviceInterface(type);
- }
-}
-
-WmiDevice::~WmiDevice()
-{
- //delete d->parent;
- delete d;
-}
-
-QStringList WmiDevice::generateUDIList(const Solid::DeviceInterface::Type &type)
-{
- return WmiDevicePrivate::generateUDIList(type);
-}
-
-bool WmiDevice::exists(const QString &udi)
-{
- return WmiDevicePrivate::exists(udi);
-}
-
-bool WmiDevice::isValid() const
-{
- // does not work
- //return sendQuery( "SELECT * FROM Win32_SystemDevices WHERE PartComponent='\\\\\\\\BEAST\root\cimv2:Win32_Processor.DeviceID=\"CPU0\"'" ).count() == 1;
- return true;
-}
-
-QString WmiDevice::udi() const
-{
- return d->udi();
-}
-
-QString WmiDevice::parentUdi() const
-{
- if (!d->m_parent_uid.isEmpty()) {
- return d->m_parent_uid;
- }
- QString result;
- const QString value = udi().split("/").last();
-
- switch (d->m_type) {
- case Solid::DeviceInterface::StorageVolume:
- case Solid::DeviceInterface::StorageAccess:
- result = "/org/kde/solid/wmi/storage/" + property("DiskIndex").toString();
- break;
- case Solid::DeviceInterface::OpticalDisc:
- result = "/org/kde/solid/wmi/storage.cdrom/" + property("Drive").toString().toLower();
- break;
- }
-
- if (result.isEmpty() && !value.isEmpty()) {
- result = udi();
- result = result.remove("/" + value);
- }
- d->m_parent_uid = result;
- return d->m_parent_uid;
-}
-
-QString WmiDevice::vendor() const
-{
- QString propertyName;
- switch (type()) {
- case Solid::DeviceInterface::Processor:
- propertyName = "Manufacturer";
- break;
- case Solid::DeviceInterface::OpticalDrive:
- case Solid::DeviceInterface::OpticalDisc:
- propertyName = "Caption";
- break;
- case Solid::DeviceInterface::Battery:
- propertyName = "DeviceID";
- break;
- case Solid::DeviceInterface::StorageAccess:
- case Solid::DeviceInterface::StorageVolume: {
- WmiDevice parent(parentUdi());
- return parent.vendor();
- }
- break;
- case Solid::DeviceInterface::StorageDrive:
- propertyName = "Model";
- break;
- default:
- propertyName = "DeviceID";//TODO:
- }
- return property(propertyName).toString();
-}
-
-QString WmiDevice::product() const
-{
- QString propertyName;
- switch (type()) {
- case Solid::DeviceInterface::Processor:
- propertyName = "Name";
- break;
- case Solid::DeviceInterface::StorageAccess:
- case Solid::DeviceInterface::StorageVolume: {
- WmiQuery::Item item = win32LogicalDiskByDiskPartitionID(property("DeviceID").toString());
- return item.getProperty("VolumeName").toString();
- }
- break;
- default:
- propertyName = "Caption";
- }
- return property(propertyName).toString();
-}
-
-QString WmiDevice::icon() const
-{
- QString propertyName;
- switch (type()) {
- case Solid::DeviceInterface::Processor:
- propertyName = "cpu";
- break;
- case Solid::DeviceInterface::OpticalDisc: {
- WmiDevice dev(udi());
- OpticalDisc disk(&dev);
- if (disk.availableContent() | Solid::OpticalDisc::Audio) { //no other are recognized yet
- propertyName = "media-optical-audio";
- } else {
- propertyName = "drive-optical";
- }
-
- break;
- }
- case Solid::DeviceInterface::Battery:
- propertyName = "battery";
- break;
- case Solid::DeviceInterface::StorageAccess:
- case Solid::DeviceInterface::StorageVolume: {
- WmiDevice parent(parentUdi());
- Storage storage(&parent);
- if (storage.bus() == Solid::StorageDrive::Usb) {
- propertyName = "drive-removable-media-usb-pendrive";
- } else {
- propertyName = "drive-harddisk";
- }
- }
- break;
- }
- return propertyName;
-}
-
-QStringList WmiDevice::emblems() const
-{
- return QStringList(); // TODO
-}
-
-QString WmiDevice::description() const
-{
- switch (type()) {
- case Solid::DeviceInterface::OpticalDisc:
- return property("VolumeName").toString();
- case Solid::DeviceInterface::Battery: {
- WmiDevice dev(udi());
- Battery bat(&dev);
- return tr("%1 Battery", "%1 is battery technology").arg(bat.batteryTechnology());
- }
- default:
- return product();
- }
-}
-
-QVariant WmiDevice::property(const QString &key) const
-{
- WmiQuery::Item item = d->sendQuery();
-
- QVariant result = item.getProperty(key);
-// qDebug()<<"property"<<key<<result;
- return result;
-}
-
-const Solid::DeviceInterface::Type WmiDevice::type() const
-{
- return d->m_type;
-}
-
-/**
- * @brief WmiDevice::win32DiskPartitionByDeviceIndex
- * @param deviceID something like "\\.\PHYSICALDRIVE0"
- * @return
- */
-WmiQuery::Item WmiDevice::win32DiskPartitionByDeviceIndex(const QString &deviceID)
-{
- WmiQuery::Item result;
- QString id = deviceID;
- QString query("ASSOCIATORS OF {Win32_DiskDrive.DeviceID='" + id + "'} WHERE AssocClass = Win32_DiskDriveToDiskPartition");
- WmiQuery::ItemList items = WmiQuery::instance().sendQuery(query);
- if (items.length() > 0) {
- result = items[0];
- }
- return result;
-}
-
-/**
- * @brief WmiDevice::win32DiskDriveByDiskPartitionID
- * @param deviceID something like "disk #1, partition #0"
- * @return
- */
-
-WmiQuery::Item WmiDevice::win32DiskDriveByDiskPartitionID(const QString &deviceID)
-{
- WmiQuery::Item result;
- QString id = deviceID;
- QString query("ASSOCIATORS OF {Win32_DiskPartition.DeviceID='" + id + "'} WHERE AssocClass = Win32_DiskDriveToDiskPartition");
- WmiQuery::ItemList items = WmiQuery::instance().sendQuery(query);
- if (items.length() > 0) {
- result = items[0];
- }
- return result;
-}
-
-/**
- * @brief WmiDevice::win32LogicalDiskByDiskPartitionID
- * @param deviceID something like "disk #1, partition #0"
- * @return
- */
-
-WmiQuery::Item WmiDevice::win32LogicalDiskByDiskPartitionID(const QString &deviceID)
-{
- WmiQuery::Item result;
- QString id = deviceID;
- QString query("ASSOCIATORS OF {Win32_DiskPartition.DeviceID='" + id + "'} WHERE AssocClass = Win32_LogicalDiskToPartition");
- WmiQuery::ItemList items = WmiQuery::instance().sendQuery(query);
- if (items.length() > 0) {
- result = items[0];
- }
- return result;
-}
-
-/**
- * @brief WmiDevice::win32DiskPartitionByDriveLetter
- * @param driveLetter something lik "D:"
- * @return
- */
-
-WmiQuery::Item WmiDevice::win32DiskPartitionByDriveLetter(const QString &driveLetter)
-{
- WmiQuery::Item result;
- QString id = driveLetter;
- QString query("ASSOCIATORS OF {Win32_LogicalDisk.DeviceID='" + id + "'} WHERE AssocClass = Win32_LogicalDiskToPartition");
- WmiQuery::ItemList items = WmiQuery::instance().sendQuery(query);
- if (items.length() > 0) {
- result = items[0];
- }
- return result;
-}
-
-/**
- * @brief WmiDevice::win32LogicalDiskByDriveLetter
- * @param driveLetter something lik "D:"
- * @return
- */
-
-WmiQuery::Item WmiDevice::win32LogicalDiskByDriveLetter(const QString &driveLetter)
-{
- WmiQuery::Item result;
- QString id = driveLetter;
- QString query("SELECT * FROM Win32_LogicalDisk WHERE DeviceID='" + id + "'");
- WmiQuery::ItemList items = WmiQuery::instance().sendQuery(query);
- if (items.length() > 0) {
- result = items[0];
- }
- return result;
-}
-
-QMap<QString, QVariant> WmiDevice::allProperties() const
-{
- WmiQuery::Item item = d->sendQuery();
-
- return item.getAllProperties();
-}
-
-bool WmiDevice::propertyExists(const QString &key) const
-{
- WmiQuery::Item item = d->sendQuery();
- const bool isEmpty = item.getProperty(key).isValid();
- return isEmpty;
-}
-
-bool WmiDevice::queryDeviceInterface(const Solid::DeviceInterface::Type &type) const
-{
- // Special cases not matching with WMI capabilities
- if (type == Solid::DeviceInterface::GenericInterface) {
- return true;
- }
-
- return d->interfaceList.contains(type);
-}
-
-QObject *WmiDevice::createDeviceInterface(const Solid::DeviceInterface::Type &type)
-{
- if (!queryDeviceInterface(type)) {
- return 0;
- }
-
- DeviceInterface *iface = 0;
-
- switch (type) {
- case Solid::DeviceInterface::GenericInterface:
- iface = new GenericInterface(this);
- break;
- case Solid::DeviceInterface::Processor:
- iface = new Processor(this);
- break;
- case Solid::DeviceInterface::Block:
- iface = new Block(this);
- break;
- case Solid::DeviceInterface::StorageAccess:
- iface = new StorageAccess(this);
- break;
- case Solid::DeviceInterface::StorageDrive:
- iface = new Storage(this);
- break;
- case Solid::DeviceInterface::OpticalDrive:
- iface = new Cdrom(this);
- break;
- case Solid::DeviceInterface::StorageVolume:
- iface = new Volume(this);
- break;
- case Solid::DeviceInterface::OpticalDisc:
- iface = new OpticalDisc(this);
- break;
- case Solid::DeviceInterface::Camera:
- iface = new Camera(this);
- break;
- case Solid::DeviceInterface::PortableMediaPlayer:
- iface = new PortableMediaPlayer(this);
- break;
- case Solid::DeviceInterface::Battery:
- iface = new Battery(this);
- break;
- case Solid::DeviceInterface::Unknown:
- case Solid::DeviceInterface::Last:
- break;
- }
-
- return iface;
-}
-
-void WmiDevice::slotPropertyModified(int /*count */, const QList<ChangeDescription> &changes)
-{
- QMap<QString, int> result;
-
- Q_FOREACH (const ChangeDescription &change, changes) {
- QString key = change.key;
- bool added = change.added;
- bool removed = change.removed;
-
- Solid::GenericInterface::PropertyChange type = Solid::GenericInterface::PropertyModified;
-
- if (added) {
- type = Solid::GenericInterface::PropertyAdded;
- } else if (removed) {
- type = Solid::GenericInterface::PropertyRemoved;
- }
-
- result[key] = type;
- }
-
- emit propertyChanged(result);
-}
-
-void WmiDevice::slotCondition(const QString &condition, const QString &reason)
-{
- emit conditionRaised(condition, reason);
-}
-
diff --git a/src/solid/backends/wmi/wmidevice.h b/src/solid/backends/wmi/wmidevice.h
deleted file mode 100644
index 350401c..0000000
--- a/src/solid/backends/wmi/wmidevice.h
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- Copyright 2012 Patrick von Reth <vonreth at kde.org>
- Copyright 2005,2006 Kevin Ottens <ervin at kde.org>
-
- 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 SOLID_BACKENDS_WMI_WMIDEVICE_H
-#define SOLID_BACKENDS_WMI_WMIDEVICE_H
-
-#include <solid/ifaces/device.h>
-#include "wmiquery.h"
-
-namespace Solid
-{
-namespace Backends
-{
-namespace Wmi
-{
-class WmiManager;
-class WmiDevicePrivate;
-
-struct ChangeDescription {
- QString key;
- bool added;
- bool removed;
-};
-
-class WmiDevice : public Solid::Ifaces::Device
-{
- Q_OBJECT
-
-public:
- WmiDevice(const QString &udi);
- virtual ~WmiDevice();
-
- virtual QString udi() const;
- virtual QString parentUdi() const;
-
- virtual QString vendor() const;
- virtual QString product() const;
- virtual QString icon() const;
- virtual QStringList emblems() const;
- virtual QString description() const;
-
- virtual bool isValid() const;
-
- virtual QVariant property(const QString &key) const;
-
- virtual QMap<QString, QVariant> allProperties() const;
-
- virtual bool propertyExists(const QString &key) const;
-
- virtual bool queryDeviceInterface(const Solid::DeviceInterface::Type &type) const;
- virtual QObject *createDeviceInterface(const Solid::DeviceInterface::Type &type);
-
- static QStringList generateUDIList(const Solid::DeviceInterface::Type &type);
- static bool exists(const QString &udi);
- const Solid::DeviceInterface::Type type() const;
-
- //TODO:rename the following methodes...
- static WmiQuery::Item win32LogicalDiskByDiskPartitionID(const QString &deviceID);
- static WmiQuery::Item win32DiskDriveByDiskPartitionID(const QString &deviceID);
- static WmiQuery::Item win32DiskPartitionByDeviceIndex(const QString &deviceID);
- static WmiQuery::Item win32DiskPartitionByDriveLetter(const QString &driveLetter);
- static WmiQuery::Item win32LogicalDiskByDriveLetter(const QString &driveLetter);
-
-Q_SIGNALS:
- void propertyChanged(const QMap<QString, int> &changes);
- void conditionRaised(const QString &condition, const QString &reason);
-
-private Q_SLOTS:
- void slotPropertyModified(int count, const QList<ChangeDescription> &changes);
- void slotCondition(const QString &condition, const QString &reason);
-
-private:
- WmiDevicePrivate *d;
- friend class WmiDevicePrivate;
-};
-}
-}
-}
-
-#endif // SOLID_BACKENDS_WMI_WMIDEVICE_H
diff --git a/src/solid/backends/wmi/wmideviceinterface.cpp b/src/solid/backends/wmi/wmideviceinterface.cpp
deleted file mode 100644
index dbbe3c5..0000000
--- a/src/solid/backends/wmi/wmideviceinterface.cpp
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- Copyright 2006 Kevin Ottens <ervin at kde.org>
-
- 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 "wmideviceinterface.h"
-
-using namespace Solid::Backends::Wmi;
-
-DeviceInterface::DeviceInterface(WmiDevice *device)
- : QObject(device), m_device(device)
-{
-}
-
-DeviceInterface::~DeviceInterface()
-{
-}
-
diff --git a/src/solid/backends/wmi/wmideviceinterface.h b/src/solid/backends/wmi/wmideviceinterface.h
deleted file mode 100644
index a572a46..0000000
--- a/src/solid/backends/wmi/wmideviceinterface.h
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- Copyright 2006 Kevin Ottens <ervin at kde.org>
-
- 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 SOLID_BACKENDS_WMI_DEVICEINTERFACE_H
-#define SOLID_BACKENDS_WMI_DEVICEINTERFACE_H
-
-#include <solid/ifaces/deviceinterface.h>
-#include "wmidevice.h"
-
-#include <QtCore/QCoreApplication>
-#include <QtCore/QObject>
-#include <QtCore/QStringList>
-
-namespace Solid
-{
-namespace Backends
-{
-namespace Wmi
-{
-class DeviceInterface : public QObject, virtual public Solid::Ifaces::DeviceInterface
-{
- Q_OBJECT
- Q_INTERFACES(Solid::Ifaces::DeviceInterface)
-public:
- DeviceInterface(WmiDevice *device);
- virtual ~DeviceInterface();
-
-protected:
- WmiDevice *m_device;
-
-public:
- inline static QStringList toStringList(Solid::DeviceInterface::Type type)
- {
- QStringList list;
-
- switch (type) {
- case Solid::DeviceInterface::GenericInterface:
- // Doesn't exist with WMI
- break;
- case Solid::DeviceInterface::Processor:
- list << "processor";
- break;
- case Solid::DeviceInterface::Block:
- list << "block";
- break;
- case Solid::DeviceInterface::StorageAccess:
- // Doesn't exist with WMI, but let's assume volume always cover this type
- list << "volume";
- break;
- case Solid::DeviceInterface::StorageDrive:
- list << "storage";
- break;
- case Solid::DeviceInterface::OpticalDrive:
- list << "storage.cdrom";
- break;
- case Solid::DeviceInterface::StorageVolume:
- list << "volume";
- break;
- case Solid::DeviceInterface::OpticalDisc:
- list << "volume.disc";
- break;
- case Solid::DeviceInterface::Camera:
- list << "camera";
- break;
- case Solid::DeviceInterface::PortableMediaPlayer:
- list << "portable_audio_player";
- break;
- case Solid::DeviceInterface::Battery:
- list << "battery";
- break;
- case Solid::DeviceInterface::NetworkShare:
- list << "networkshare";
- break;
- case Solid::DeviceInterface::Unknown:
- break;
- case Solid::DeviceInterface::Last:
- break;
- }
-
- return list;
- }
-
- inline static Solid::DeviceInterface::Type fromString(const QString &capability)
- {
- if (capability == "processor") {
- return Solid::DeviceInterface::Processor;
- } else if (capability == "block") {
- return Solid::DeviceInterface::Block;
- } else if (capability == "storage") {
- return Solid::DeviceInterface::StorageDrive;
- } else if (capability == "storage.cdrom") {
- return Solid::DeviceInterface::OpticalDrive;
- } else if (capability == "volume") {
- return Solid::DeviceInterface::StorageVolume;
- } else if (capability == "volume.disc") {
- return Solid::DeviceInterface::OpticalDisc;
- } else if (capability == "camera") {
- return Solid::DeviceInterface::Camera;
- } else if (capability == "portable_audio_player") {
- return Solid::DeviceInterface::PortableMediaPlayer;
- } else if (capability == "battery") {
- return Solid::DeviceInterface::Battery;
- } else if (capability == "networkshare") {
- return Solid::DeviceInterface::NetworkShare;
- } else {
- return Solid::DeviceInterface::Unknown;
- }
- }
-};
-}
-}
-}
-
-#endif // SOLID_BACKENDS_WMI_DEVICEINTERFACE_H
diff --git a/src/solid/backends/wmi/wmigenericinterface.cpp b/src/solid/backends/wmi/wmigenericinterface.cpp
deleted file mode 100644
index 9bd4343..0000000
--- a/src/solid/backends/wmi/wmigenericinterface.cpp
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- Copyright 2006 Kevin Ottens <ervin at kde.org>
-
- 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 "wmigenericinterface.h"
-
-#include "wmidevice.h"
-
-using namespace Solid::Backends::Wmi;
-
-GenericInterface::GenericInterface(WmiDevice *device)
- : DeviceInterface(device)
-{
- connect(device, SIGNAL(propertyChanged(QMap<QString,int>)),
- this, SIGNAL(propertyChanged(QMap<QString,int>)));
- connect(device, SIGNAL(conditionRaised(QString,QString)),
- this, SIGNAL(conditionRaised(QString,QString)));
-}
-
-GenericInterface::~GenericInterface()
-{
-
-}
-
-QVariant GenericInterface::property(const QString &key) const
-{
- return m_device->property(key);
-}
-
-QMap<QString, QVariant> GenericInterface::allProperties() const
-{
- return m_device->allProperties();
-}
-
-bool GenericInterface::propertyExists(const QString &key) const
-{
- return m_device->propertyExists(key);
-}
-
diff --git a/src/solid/backends/wmi/wmigenericinterface.h b/src/solid/backends/wmi/wmigenericinterface.h
deleted file mode 100644
index 3b71e9f..0000000
--- a/src/solid/backends/wmi/wmigenericinterface.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- Copyright 2007 Kevin Ottens <ervin at kde.org>
-
- 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 SOLID_BACKENDS_WMI_GENERICINTERFACE_H
-#define SOLID_BACKENDS_WMI_GENERICINTERFACE_H
-
-#include <solid/ifaces/genericinterface.h>
-#include <solid/genericinterface.h>
-#include "wmideviceinterface.h"
-
-namespace Solid
-{
-namespace Backends
-{
-namespace Wmi
-{
-class WmiDevice;
-
-class GenericInterface : public DeviceInterface, virtual public Solid::Ifaces::GenericInterface
-{
- Q_OBJECT
- Q_INTERFACES(Solid::Ifaces::GenericInterface)
-
-public:
- GenericInterface(WmiDevice *device);
- virtual ~GenericInterface();
-
- virtual QVariant property(const QString &key) const;
- virtual QMap<QString, QVariant> allProperties() const;
- virtual bool propertyExists(const QString &key) const;
-
-Q_SIGNALS:
- void propertyChanged(const QMap<QString, int> &changes);
- void conditionRaised(const QString &condition, const QString &reason);
-};
-}
-}
-}
-
-#endif // SOLID_BACKENDS_WMI_GENERICINTERFACE_H
diff --git a/src/solid/backends/wmi/wmimanager.cpp b/src/solid/backends/wmi/wmimanager.cpp
deleted file mode 100644
index b87b72c..0000000
--- a/src/solid/backends/wmi/wmimanager.cpp
+++ /dev/null
@@ -1,262 +0,0 @@
-/*
- Copyright 2012 Patrick von Reth <vonreth at kde.org>
- Copyright 2005,2006 Kevin Ottens <ervin at kde.org>
-
- 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 "wmimanager.h"
-
-#include <QtCore/QDebug>
-
-#include "wmidevice.h"
-#include "wmideviceinterface.h"
-#include "wmiquery.h"
-
-using namespace Solid::Backends::Wmi;
-
-class Solid::Backends::Wmi::WmiManagerPrivate
-{
-public:
- WmiManagerPrivate(WmiManager *parent)
- : m_parent(parent)
- {
- supportedInterfaces << Solid::DeviceInterface::GenericInterface
- << Solid::DeviceInterface::Processor
- // << Solid::DeviceInterface::Block
- << Solid::DeviceInterface::StorageAccess
- << Solid::DeviceInterface::StorageDrive
- << Solid::DeviceInterface::OpticalDrive
- << Solid::DeviceInterface::StorageVolume
- << Solid::DeviceInterface::OpticalDisc
- // << Solid::DeviceInterface::Camera
- // << Solid::DeviceInterface::PortableMediaPlayer
- << Solid::DeviceInterface::Battery
- ;
-
- update();
- }
-
- ~WmiManagerPrivate()
- {
-
- }
-
- void update()
- {
- init();
-
- }
-
- void init()
- {
- if (m_deviceCache.isEmpty()) {
- Q_FOREACH (const Solid::DeviceInterface::Type &dev, supportedInterfaces) {
- updateDeviceCache(dev);
- }
- }
- }
-
- void updateDeviceCache(const Solid::DeviceInterface::Type &type)
- {
- QSet<QString> devSet = m_parent->findDeviceByDeviceInterface(type).toSet();
- if (m_deviceCache.contains(type)) {
- QSet<QString> added = devSet - m_deviceCache[type];
- Q_FOREACH (const QString &s, added) {
- m_parent->slotDeviceAdded(s);
- }
- QSet<QString> removed = m_deviceCache[type] - devSet;
- Q_FOREACH (const QString &s, removed) {
- m_parent->slotDeviceRemoved(s);
- }
- }
- m_deviceCache[type] = devSet;
- }
-
- WmiQuery::ItemList sendQuery(const QString &wql)
- {
- return WmiQuery::instance().sendQuery(wql);
- }
-
- WmiManager *m_parent;
- QSet<Solid::DeviceInterface::Type> supportedInterfaces;
- QMap<Solid::DeviceInterface::Type, QSet<QString> > m_deviceCache;
-};
-
-WmiManager::WmiManager(QObject *parent)
- : DeviceManager(parent)
-{
- d = new WmiManagerPrivate(this);
-
- QList<Solid::DeviceInterface::Type> types;
- types << Solid::DeviceInterface::StorageDrive << Solid::DeviceInterface::StorageVolume;
- //partition added
- WmiQuery::instance().addDeviceListeners(new WmiManager::WmiEventSink(this, "SELECT * FROM __InstanceCreationEvent WITHIN 10 WHERE TargetInstance ISA 'Win32_DiskPartition'", types));
- //partition removed
- WmiQuery::instance().addDeviceListeners(new WmiManager::WmiEventSink(this, "SELECT * FROM __InstanceDeletionEvent WITHIN 10 WHERE TargetInstance ISA 'Win32_DiskPartition'", types));
-
- types.clear();
- types << Solid::DeviceInterface::OpticalDisc;
- //MediaLoaded=True/False change
- WmiQuery::instance().addDeviceListeners(new WmiManager::WmiEventSink(this, "SELECT * from __InstanceModificationEvent WITHIN 10 WHERE TargetInstance ISA 'Win32_CDromDrive'", types));
-
-}
-
-WmiManager::~WmiManager()
-{
- delete d;
-}
-
-QString WmiManager::udiPrefix() const
-{
- return QString(); //FIXME: We should probably use a prefix there... has to be tested on Windows
-}
-
-QSet<Solid::DeviceInterface::Type> WmiManager::supportedInterfaces() const
-{
- return d->supportedInterfaces;
-}
-
-QStringList WmiManager::allDevices()
-{
- QStringList deviceUdiList;
-
- QStringList aList;
- Q_FOREACH (const Solid::DeviceInterface::Type &dev, d->supportedInterfaces) {
- aList << findDeviceByDeviceInterface(dev);
- }
- Q_FOREACH (const QString &udi, aList) {
- if (!deviceUdiList.contains(udi)) {
- deviceUdiList << udi;
- }
- }
- return aList;
-}
-
-bool WmiManager::deviceExists(const QString &udi)
-{
- return WmiDevice::exists(udi);
-}
-
-QStringList WmiManager::devicesFromQuery(const QString &parentUdi,
- Solid::DeviceInterface::Type type)
-{
- QStringList result;
- if (!parentUdi.isEmpty()) {
- Q_FOREACH (const QString &udi, allDevices()) {
- WmiDevice device(udi);
- if (device.type() == type && device.parentUdi() == parentUdi) {
- result << udi;
- }
- }
-
- } else if (type != Solid::DeviceInterface::Unknown) {
- result << findDeviceByDeviceInterface(type);
- } else {
- result << allDevices();
- }
- return result;
-}
-
-QObject *WmiManager::createDevice(const QString &udi)
-{
- if (deviceExists(udi)) {
- return new WmiDevice(udi);
- } else {
- return 0;
- }
-}
-
-QStringList WmiManager::findDeviceStringMatch(const QString &key, const QString &value)
-{
- qDebug() << "has to be implemented" << key << value;
- QStringList result;
-
-// qDebug() << result;
- return result;
-}
-
-QStringList WmiManager::findDeviceByDeviceInterface(Solid::DeviceInterface::Type type)
-{
- return WmiDevice::generateUDIList(type);
-}
-
-void WmiManager::slotDeviceAdded(const QString &udi)
-{
- qDebug() << "Device added" << udi;
- emit deviceAdded(udi);
-}
-
-void WmiManager::slotDeviceRemoved(const QString &udi)
-{
- qDebug() << "Device removed" << udi;
- emit deviceRemoved(udi);
-}
-
-WmiManager::WmiEventSink::WmiEventSink(WmiManager *parent, const QString &query, const QList<Solid::DeviceInterface::Type> &types):
- m_parent(parent),
- m_query(query),
- m_types(types),
- m_count(0)
-{}
-
-WmiManager::WmiEventSink::~WmiEventSink()
-{}
-
-ulong STDMETHODCALLTYPE WmiManager::WmiEventSink::AddRef()
-{
- return InterlockedIncrement(&m_count);
-}
-
-ulong STDMETHODCALLTYPE WmiManager::WmiEventSink::Release()
-{
- long lRef = InterlockedDecrement(&m_count);
- if (lRef == 0) {
- delete this;
- }
- return lRef;
-}
-
-HRESULT STDMETHODCALLTYPE WmiManager::WmiEventSink::QueryInterface(REFIID riid, void **ppv)
-{
- if (riid == IID_IUnknown || riid == IID_IWbemObjectSink) {
- *ppv = (IWbemObjectSink *) this;
- AddRef();
- return WBEM_S_NO_ERROR;
- } else {
- return E_NOINTERFACE;
- }
-}
-
-HRESULT STDMETHODCALLTYPE WmiManager::WmiEventSink::Indicate(long lObjectCount, IWbemClassObject **apObjArray)
-{
- Q_FOREACH (const Solid::DeviceInterface::Type &type, m_types) {
- m_parent->d->updateDeviceCache(type);
- }
- return WBEM_S_NO_ERROR;
-}
-
-HRESULT STDMETHODCALLTYPE WmiManager::WmiEventSink::SetStatus(long lFlags, HRESULT hResult, BSTR strParam, IWbemClassObject *pObjParam)
-{
- return WBEM_S_NO_ERROR;
-}
-
-const QString &WmiManager::WmiEventSink::query() const
-{
- return m_query;
-}
-
diff --git a/src/solid/backends/wmi/wmimanager.h b/src/solid/backends/wmi/wmimanager.h
deleted file mode 100644
index 3405c4d..0000000
--- a/src/solid/backends/wmi/wmimanager.h
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- Copyright 2012 Patrick von Reth <vonreth at kde.org>
- Copyright 2005,2006 Kevin Ottens <ervin at kde.org>
-
- 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 SOLID_BACKENDS_WMI_WMIMANAGER_H
-#define SOLID_BACKENDS_WMI_WMIMANAGER_H
-
-#include <solid/ifaces/devicemanager.h>
-#include <solid/deviceinterface.h>
-
-#include <QtCore/QVariant>
-#include <QtCore/QStringList>
-
-#include <Wbemidl.h>
-
-namespace Solid
-{
-namespace Backends
-{
-namespace Wmi
-{
-class WmiManagerPrivate;
-
-class WmiManager : public Solid::Ifaces::DeviceManager
-{
- Q_OBJECT
-
-public:
-
- class WmiEventSink : public IWbemObjectSink
- {
- public:
- WmiEventSink(class WmiManager *parent, const QString &query, const QList<Solid::DeviceInterface::Type> &types);
- ~WmiEventSink();
-
- virtual ulong STDMETHODCALLTYPE AddRef();
- virtual ulong STDMETHODCALLTYPE Release();
-
- virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void **ppv);
-
- virtual HRESULT STDMETHODCALLTYPE Indicate(long lObjectCount, IWbemClassObject **apObjArray);
-
- virtual HRESULT STDMETHODCALLTYPE SetStatus(long lFlags, HRESULT hResult, BSTR strParam, IWbemClassObject *pObjParam);
-
- const QString &query() const;
-
- private:
- WmiManager *m_parent;
- QString m_query;
- QList<Solid::DeviceInterface::Type> m_types;
- long m_count;
-
- };
-
- WmiManager(QObject *parent = 0);
- virtual ~WmiManager();
-
- virtual QString udiPrefix() const;
- virtual QSet<Solid::DeviceInterface::Type> supportedInterfaces() const;
-
- virtual QStringList allDevices();
- virtual bool deviceExists(const QString &udi);
-
- virtual QStringList devicesFromQuery(const QString &parentUdi,
- Solid::DeviceInterface::Type type);
-
- virtual QObject *createDevice(const QString &udi);
-
-private Q_SLOTS:
- void slotDeviceAdded(const QString &udi);
- void slotDeviceRemoved(const QString &udi);
-
-private:
- QStringList findDeviceStringMatch(const QString &key, const QString &value);
- QStringList findDeviceByDeviceInterface(Solid::DeviceInterface::Type type);
-
- WmiManagerPrivate *d;
- friend class WmiManagerPrivate;
-};
-}
-}
-}
-
-#endif // SOLID_BACKENDS_WMI_WMIMANAGER_H
diff --git a/src/solid/backends/wmi/wmiopticaldisc.cpp b/src/solid/backends/wmi/wmiopticaldisc.cpp
deleted file mode 100644
index 8ff7168..0000000
--- a/src/solid/backends/wmi/wmiopticaldisc.cpp
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- Copyright 2012 Patrick von Reth <vonreth at kde.org>
- Copyright 2006 Kevin Ottens <ervin at kde.org>
-
- 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 "wmiopticaldisc.h"
-
-#include <QDir>
-
-using namespace Solid::Backends::Wmi;
-
-OpticalDisc::OpticalDisc(WmiDevice *device)
- : Volume(device)
-{
- m_logicalDisk = WmiDevice::win32LogicalDiskByDriveLetter(m_device->property("Drive").toString());
-}
-
-OpticalDisc::~OpticalDisc()
-{
-
-}
-
-Solid::OpticalDisc::ContentTypes OpticalDisc::availableContent() const
-{
- Solid::OpticalDisc::ContentTypes content;
-
- QMap<Solid::OpticalDisc::ContentType, QString> map;
- map[Solid::OpticalDisc::Audio] = "volume.disc.has_audio";
- map[Solid::OpticalDisc::Data] = "volume.disc.has_data";
- map[Solid::OpticalDisc::VideoCd] = "volume.disc.is_vcd";
- map[Solid::OpticalDisc::SuperVideoCd] = "volume.disc.is_svcd";
- map[Solid::OpticalDisc::VideoDvd] = "volume.disc.is_videodvd";
-
- Q_FOREACH (const Solid::OpticalDisc::ContentType type, map.keys()) {
- if (m_device->property(map[type]).toBool()) {
- content |= type;
- }
- }
-
- return content;
-}
-
-Solid::OpticalDisc::DiscType OpticalDisc::discType() const
-{
- QString type = m_logicalDisk.getProperty("FileSystem").toString();
-
- if (type == "CDFS") {
- return Solid::OpticalDisc::CdRom;
- }
-// else if (type == "CdRomWrite")
-// {
-// return Solid::OpticalDisc::CdRecordable;
-// }
- else if (type == "UDF") {
- return Solid::OpticalDisc::DvdRom;
- }
-// else if (type == "DVDRomWrite")
-// {
-// return Solid::OpticalDisc::DvdRecordable;
-// }
- else {
- qDebug() << "Solid::OpticalDisc::DiscType OpticalDisc::discType(): Unknown Type" << type;
- return Solid::OpticalDisc::UnknownDiscType;
- }
-}
-
-bool OpticalDisc::isAppendable() const
-{
- return false;
-}
-
-bool OpticalDisc::isBlank() const
-{
- ushort val = m_device->property("FileSystemFlagsEx").toUInt();
- if (val == 0) {
- return true;
- }
- return false;
-}
-
-bool OpticalDisc::isRewritable() const
-{
- //TODO:
- return capacity() > 0 && isWriteable();
-}
-
-qulonglong OpticalDisc::capacity() const
-{
- return m_device->property("Size").toULongLong();
-}
-
-bool OpticalDisc::isWriteable() const
-{
- ushort val = m_device->property("FileSystemFlagsEx").toUInt();
- if (val == 0) {
- return true;
- }
- return !val & 0x80001;//read only
-}
-
diff --git a/src/solid/backends/wmi/wmiopticaldisc.h b/src/solid/backends/wmi/wmiopticaldisc.h
deleted file mode 100644
index 6829f3b..0000000
--- a/src/solid/backends/wmi/wmiopticaldisc.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- Copyright 2012 Patrick von Reth <vonreth at kde.org>
- Copyright 2006 Kevin Ottens <ervin at kde.org>
-
- 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 SOLID_BACKENDS_WMI_OPTICALDISC_H
-#define SOLID_BACKENDS_WMI_OPTICALDISC_H
-
-#include <solid/ifaces/opticaldisc.h>
-#include "wmivolume.h"
-
-namespace Solid
-{
-namespace Backends
-{
-namespace Wmi
-{
-class OpticalDisc : public Volume, virtual public Solid::Ifaces::OpticalDisc
-{
- Q_OBJECT
- Q_INTERFACES(Solid::Ifaces::OpticalDisc)
-
-public:
- OpticalDisc(WmiDevice *device);
- virtual ~OpticalDisc();
-
- virtual Solid::OpticalDisc::ContentTypes availableContent() const;
- virtual Solid::OpticalDisc::DiscType discType() const;
- virtual bool isAppendable() const;
- virtual bool isBlank() const;
- virtual bool isRewritable() const;
- virtual qulonglong capacity() const;
-private:
- bool isWriteable() const;
- WmiQuery::Item m_logicalDisk;
-};
-}
-}
-}
-
-#endif // SOLID_BACKENDS_WMI_OPTICALDISC_H
diff --git a/src/solid/backends/wmi/wmiportablemediaplayer.cpp b/src/solid/backends/wmi/wmiportablemediaplayer.cpp
deleted file mode 100644
index cc16978..0000000
--- a/src/solid/backends/wmi/wmiportablemediaplayer.cpp
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- Copyright 2006 Davide Bettio <davide.bettio at kdemail.net>
- Copyright 2007 Jeff Mitchell <kde-dev at emailgoeshere.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 "wmiportablemediaplayer.h"
-
-using namespace Solid::Backends::Wmi;
-
-PortableMediaPlayer::PortableMediaPlayer(WmiDevice *device)
- : DeviceInterface(device)
-{
-
-}
-
-PortableMediaPlayer::~PortableMediaPlayer()
-{
-
-}
-
-QStringList PortableMediaPlayer::supportedProtocols() const
-{
- return m_device->property("portable_audio_player.access_method.protocols").toStringList();
-}
-
-QStringList PortableMediaPlayer::supportedDrivers(QString protocol) const
-{
- QStringList drivers = m_device->property("portable_audio_player.access_method.drivers").toStringList();
- if (protocol.isNull()) {
- return drivers;
- }
- QStringList returnedDrivers;
- QString temp;
- for (int i = 0; i < drivers.size(); i++) {
- temp = drivers.at(i);
- if (m_device->property("portable_audio_player." + temp + ".protocol") == protocol) {
- returnedDrivers << temp;
- }
- }
- return returnedDrivers;
-}
-
-QVariant Solid::Backends::Wmi::PortableMediaPlayer::driverHandle(const QString &driver) const
-{
- if (driver == "mtp") {
- return m_device->property("usb.serial");
- }
- // TODO: Fill in the blank for other drivers
-
- return QVariant();
-}
-
diff --git a/src/solid/backends/wmi/wmiportablemediaplayer.h b/src/solid/backends/wmi/wmiportablemediaplayer.h
deleted file mode 100644
index 0eac6b9..0000000
--- a/src/solid/backends/wmi/wmiportablemediaplayer.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- Copyright 2006 Davide Bettio <davide.bettio at kdemail.net>
- Copyright 2007 Jeff Mitchell <kde-dev at emailgoeshere.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 SOLID_BACKENDS_WMI_PORTABLEMEDIAPLAYER_H
-#define SOLID_BACKENDS_WMI_PORTABLEMEDIAPLAYER_H
-
-#include <solid/ifaces/portablemediaplayer.h>
-#include "wmideviceinterface.h"
-
-#include <QtCore/QStringList>
-
-namespace Solid
-{
-namespace Backends
-{
-namespace Wmi
-{
-class WmiDevice;
-
-class PortableMediaPlayer : public DeviceInterface, virtual public Solid::Ifaces::PortableMediaPlayer
-{
- Q_OBJECT
- Q_INTERFACES(Solid::Ifaces::PortableMediaPlayer)
-
-public:
- PortableMediaPlayer(WmiDevice *device);
- virtual ~PortableMediaPlayer();
-
- virtual QStringList supportedProtocols() const;
- virtual QStringList supportedDrivers(QString protocol = QString()) const;
- virtual QVariant driverHandle(const QString &driver) const;
-};
-}
-}
-}
-
-#endif // SOLID_BACKENDS_WMI_PORTABLEMEDIAPLAYER_H
diff --git a/src/solid/backends/wmi/wmiprocessor.cpp b/src/solid/backends/wmi/wmiprocessor.cpp
deleted file mode 100644
index 2d1048d..0000000
--- a/src/solid/backends/wmi/wmiprocessor.cpp
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- Copyright 2006 Kevin Ottens <ervin at kde.org>
-
- 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 "wmiprocessor.h"
-
-#include "wmidevice.h"
-
-#include "../shared/cpufeatures.h"
-
-using namespace Solid::Backends::Wmi;
-
-Processor::Processor(WmiDevice *device)
- : DeviceInterface(device)
-{
-
-}
-
-Processor::~Processor()
-{
-
-}
-
-int Processor::number() const
-{
- return m_device->property("NumberOfCores").toInt();
-}
-
-int Processor::maxSpeed() const
-{
- return m_device->property("MaxClockSpeed").toInt();
-}
-
-bool Processor::canChangeFrequency() const
-{
- // dummy for now, need some changes in WMI!
- return false;
-}
-
-Solid::Processor::InstructionSets Processor::instructionSets() const
-{
- static Solid::Processor::InstructionSets cpuextensions = Solid::Backends::Shared::cpuFeatures();
-
- return cpuextensions;
-}
-
diff --git a/src/solid/backends/wmi/wmiprocessor.h b/src/solid/backends/wmi/wmiprocessor.h
deleted file mode 100644
index 84ec4ce..0000000
--- a/src/solid/backends/wmi/wmiprocessor.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- Copyright 2006 Kevin Ottens <ervin at kde.org>
-
- 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 SOLID_BACKENDS_WMI_PROCESSOR_H
-#define SOLID_BACKENDS_WMI_PROCESSOR_H
-
-#include <solid/ifaces/processor.h>
-#include "wmideviceinterface.h"
-
-namespace Solid
-{
-namespace Backends
-{
-namespace Wmi
-{
-class WmiDevice;
-
-class Processor : public DeviceInterface, virtual public Solid::Ifaces::Processor
-{
- Q_OBJECT
- Q_INTERFACES(Solid::Ifaces::Processor)
-
-public:
- Processor(WmiDevice *device);
- virtual ~Processor();
-
- virtual int number() const;
- virtual int maxSpeed() const;
- virtual bool canChangeFrequency() const;
- virtual Solid::Processor::InstructionSets instructionSets() const;
-};
-}
-}
-}
-
-#endif // SOLID_BACKENDS_WMI_PROCESSOR_H
diff --git a/src/solid/backends/wmi/wmiquery.cpp b/src/solid/backends/wmi/wmiquery.cpp
deleted file mode 100644
index 5019611..0000000
--- a/src/solid/backends/wmi/wmiquery.cpp
+++ /dev/null
@@ -1,389 +0,0 @@
-/*
- Copyright 2012 Patrick von Reth <vonreth at kde.org>
- Copyright 2008 Jeff Mitchell <mitchell at kde.org>
-
- 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/>.
-*/
-
-//#define _WIN32_DCOM
-//#include <comdef.h>
-
-#define INSIDE_WMIQUERY
-#include "wmiquery.h"
-#include "wmimanager.h"
-
-#ifdef _DEBUG
-# pragma comment(lib, "comsuppwd.lib")
-#else
-# pragma comment(lib, "comsuppw.lib")
-#endif
-# pragma comment(lib, "wbemuuid.lib")
-
-#include <iostream>
-#include <Wbemidl.h>
-#include <Oaidl.h>
-
-# pragma comment(lib, "wbemuuid.lib")
-
-#include <QtCore/QDebug>
-#include <QtCore/QVariant>
-#include <QtCore/QList>
-#include <QtCore/QStringList>
-#include <QtCore/QCoreApplication>
-
-//needed for mingw
-inline OLECHAR *SysAllocString(const QString &s)
-{
- const OLECHAR *olename = reinterpret_cast<const OLECHAR *>(s.utf16());
- return ::SysAllocString(olename);
-}
-
-using namespace Solid::Backends::Wmi;
-
-QString bstrToQString(BSTR bstr)
-{
- QString str((QChar *)bstr, ::SysStringLen(bstr));
- return str;
-
-}
-
-QVariant WmiQuery::Item::msVariantToQVariant(VARIANT msVariant, CIMTYPE variantType)
-{
- QVariant returnVariant(QVariant::Invalid);
- if (msVariant.vt == VT_NULL) {
- return QVariant(QVariant::String);
- }
-
- switch (variantType) {
- case CIM_STRING:
- case CIM_CHAR16:
- case CIM_UINT64: { //bug I get a wrong value from ullVal
- QString str = bstrToQString(msVariant.bstrVal);
- QVariant vs(str);
- returnVariant = vs;
-
- }
- break;
- case CIM_BOOLEAN: {
- QVariant vb(msVariant.boolVal);
- returnVariant = vb;
- }
- break;
- case CIM_UINT8: {
- QVariant vb(msVariant.uintVal);
- returnVariant = vb;
- }
- break;
- case CIM_UINT16: {
- QVariant vb(msVariant.uintVal);
- returnVariant = vb;
- }
- break;
- case CIM_UINT32: {
- QVariant vb(msVariant.uintVal);
- returnVariant = vb;
- }
- break;
- // case CIM_UINT64:
- // {
- // QVariant vb(msVariant.ullVal);
- //// wprintf(L"ulonglong %d %I64u\r\n",variantType, msVariant.ullVal); // 32-bit on x86, 64-bit on x64
- // returnVariant = vb;
- // }
- // break;
- // default:
- // qDebug()<<"Unsupported variant"<<variantType;
- };
- VariantClear(&msVariant);
- return returnVariant;
-}
-
-/**
- When a WmiQuery instance is created as a static global
- object a deadlock problem occurs in pLoc->ConnectServer.
- Please DO NOT USE the following or similar statement in
- the global space or a class.
-
- static WmiQuery instance;
-*/
-
-QVariant WmiQuery::Item::getProperty(BSTR bstrProp) const
-{
- QVariant result;
- if (m_p == NULL) {
- return result;
- }
- VARIANT vtProp;
- CIMTYPE variantType;
- HRESULT hr = m_p->Get(bstrProp, 0, &vtProp, &variantType, 0);
- if (SUCCEEDED(hr)) {
- result = msVariantToQVariant(vtProp, variantType);
- } else {
- QString className = getProperty(L"__CLASS").toString();
- QString qprop = bstrToQString(bstrProp);
- qFatal("\r\n--------------------------------------------------------------\r\n"
- "Error: Property: %s not found in %s\r\n"
- "--------------------------------------------------------------\r\n", qPrintable(qprop), qPrintable(className));
- }
- return result;
-}
-QVariant WmiQuery::Item::getProperty(const QString &property) const
-{
- QVariant result;
- BSTR bstrProp;
- bstrProp = ::SysAllocString(property);
- result = getProperty(bstrProp);
- ::SysFreeString(bstrProp);
- return result;
-}
-
-QVariantMap WmiQuery::Item::getAllProperties()
-{
- if (m_properies.isEmpty()) {
- SAFEARRAY *psaNames;
- HRESULT hr = m_p->GetNames(NULL, WBEM_FLAG_ALWAYS | WBEM_FLAG_NONSYSTEM_ONLY, NULL, &psaNames);
- if (SUCCEEDED(hr)) {
- long lLower, lUpper;
- SafeArrayGetLBound(psaNames, 1, &lLower);
- SafeArrayGetUBound(psaNames, 1, &lUpper);
- for (long i = lLower; i < lUpper; ++i) {
- BSTR pName = { 0 };
- hr = SafeArrayGetElement(psaNames, &i, &pName);
- QVariant vr = getProperty(pName);
- if (vr.isValid()) {
- QString key = bstrToQString(pName);
- m_properies[key] = getProperty(pName);
- }
- }
- } else {
- qWarning() << "Querying all failed";
- }
- SafeArrayDestroy(psaNames);
- }
- return m_properies;
-}
-
-WmiQuery::Item::Item()
- : m_p(NULL)
-{
-}
-
-WmiQuery::Item::Item(IWbemClassObject *p) : m_p(p)
-{
- if (m_p != NULL) {
- m_p->AddRef();
- }
-}
-
-WmiQuery::Item::Item(const Item &other) : m_p(other.m_p)
-{
- if (m_p != NULL) {
- m_p->AddRef();
- }
-}
-
-WmiQuery::Item &WmiQuery::Item::operator=(const Item &other)
-{
- if (m_p != NULL) {
- m_p->Release();
- m_p = NULL;
- }
- if (other.m_p != NULL) {
- m_p = other.m_p;
- m_p->AddRef();
- }
- return *this;
-}
-
-WmiQuery::Item::~Item()
-{
- if (m_p != NULL &&
- !(qApp->closingDown() || WmiQuery::instance().m_bNeedUninit)) { //this means we are in a QApplication, so qt already called CoUninitialize and all COM references are all ready freed
- m_p->Release();
- }
-}
-
-IWbemClassObject *WmiQuery::Item::data() const
-{
- if (m_p != NULL) {
- m_p->AddRef();
- }
- return m_p;
-}
-
-bool WmiQuery::Item::isNull() const
-{
- return m_p == NULL;
-}
-
-WmiQuery::WmiQuery()
- : m_failed(false)
- , pLoc(0)
- , pSvc(0)
-{
- HRESULT hres;
-
- hres = CoInitializeEx(0, COINIT_MULTITHREADED);
- if (FAILED(hres) && hres != S_FALSE && hres != RPC_E_CHANGED_MODE) {
- qCritical() << "Failed to initialize COM library. Error code = 0x" << hex << quint32(hres) << endl;
- m_failed = true;
- }
- m_bNeedUninit = (hres != S_FALSE && hres != RPC_E_CHANGED_MODE);
- if (!m_failed) {
- hres = CoInitializeSecurity(NULL, -1, NULL, NULL, RPC_C_AUTHN_LEVEL_DEFAULT,
- RPC_C_IMP_LEVEL_IMPERSONATE, NULL, EOAC_NONE, NULL);
-
- // RPC_E_TOO_LATE --> security already initialized
- if (FAILED(hres) && hres != RPC_E_TOO_LATE) {
- qCritical() << "Failed to initialize security. " << "Error code = " << hres << endl;
- if (m_bNeedUninit) {
- CoUninitialize();
- }
- m_failed = true;
- }
- }
- if (!m_failed) {
- hres = CoCreateInstance(CLSID_WbemLocator, 0, CLSCTX_INPROC_SERVER, IID_IWbemLocator, (LPVOID *) &pLoc);
- if (FAILED(hres)) {
- qCritical() << "Failed to create IWbemLocator object. " << "Error code = " << hres << endl;
- if (m_bNeedUninit) {
- CoUninitialize();
- }
- m_failed = true;
- }
- }
- if (!m_failed) {
- hres = pLoc->ConnectServer(L"ROOT\\CIMV2", NULL, NULL, 0, NULL, 0, 0, &pSvc);
- if (FAILED(hres)) {
- qCritical() << "Could not connect. Error code = " << hres << endl;
- pLoc->Release();
- if (m_bNeedUninit) {
- CoUninitialize();
- }
- m_failed = true;
- }
- // else
- // qDebug() << "Connected to ROOT\\CIMV2 WMI namespace" << endl;
- }
-
- if (!m_failed) {
- hres = CoSetProxyBlanket(pSvc, RPC_C_AUTHN_WINNT, RPC_C_AUTHZ_NONE, NULL,
- RPC_C_AUTHN_LEVEL_CALL, RPC_C_IMP_LEVEL_IMPERSONATE, NULL, EOAC_NONE);
- if (FAILED(hres)) {
- qCritical() << "Could not set proxy blanket. Error code = " << hres << endl;
- pSvc->Release();
- pLoc->Release();
- if (m_bNeedUninit) {
- CoUninitialize();
- }
- m_failed = true;
- }
- }
-}
-
-WmiQuery::~WmiQuery()
-{
- if (m_failed) {
- return; // already cleaned up properly
- }
- if (pSvc) {
- pSvc->Release();
- }
- if (pLoc) {
- pLoc->Release();
- }
- if (m_bNeedUninit) {
- CoUninitialize();
- }
-}
-
-void WmiQuery::addDeviceListeners(WmiManager::WmiEventSink *sink)
-{
- if (m_failed) {
- return;
- }
- BSTR bstrQuery;
- bstrQuery = ::SysAllocString(sink->query());
- HRESULT hr = pSvc->ExecNotificationQueryAsync(L"WQL", bstrQuery, 0, NULL, sink);
- ::SysFreeString(bstrQuery);
- if (FAILED(hr)) {
- qWarning() << "WmiQuery::addDeviceListeners " << sink->query() << " failed!";
- }
-}
-
-WmiQuery::ItemList WmiQuery::sendQuery(const QString &wql)
-{
-// qDebug()<<"WmiQuery::ItemList WmiQuery::sendQuery"<<wql;
- ItemList retList;
-
- if (!pSvc) {
- m_failed = true;
- return retList;
- }
-
- HRESULT hres;
-
- IEnumWbemClassObject *pEnumerator = NULL;
- BSTR bstrQuery;
- bstrQuery = ::SysAllocString(wql);
- hres = pSvc->ExecQuery(L"WQL", bstrQuery,
- WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY, NULL, &pEnumerator);
- ::SysFreeString(bstrQuery);
-
- if (FAILED(hres)) {
- qDebug() << "Query with string \"" << wql << "\" failed. Error code = " << hres << endl;
- } else {
- ULONG uReturn = 0;
-
- while (pEnumerator) {
- IWbemClassObject *pclsObj;
- hres = pEnumerator->Next(WBEM_INFINITE, 1, &pclsObj, &uReturn);
-
- if (!uReturn) {
- break;
- }
-
- // pclsObj will be released on destruction of Item
- retList.append(Item(pclsObj));
- pclsObj->Release();
- }
- if (pEnumerator) {
- pEnumerator->Release();
- } else {
- qDebug() << "failed to release enumerator!";
- }
- }
-// if(retList.size()== 0)
-// qDebug()<<"querying"<<wql<<"returned empty list";
-// else
-// qDebug()<<"Feteched"<<retList.size()<<"items";
- return retList;
-}
-
-bool WmiQuery::isLegit() const
-{
- return !m_failed;
-}
-
-WmiQuery &WmiQuery::instance()
-{
- static WmiQuery *query = 0;
- if (!query) {
- query = new WmiQuery;
- }
- return *query;
-}
diff --git a/src/solid/backends/wmi/wmiquery.h b/src/solid/backends/wmi/wmiquery.h
deleted file mode 100644
index 9dcd1ac..0000000
--- a/src/solid/backends/wmi/wmiquery.h
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- Copyright 2012 Patrick von Reth <vonreth at kde.org>
- Copyright 2008 Jeff Mitchell <mitchell at kde.org>
-
- 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 SOLID_BACKENDS_WMI_WMIQUERY_H
-#define SOLID_BACKENDS_WMI_WMIQUERY_H
-
-#include <QtCore/QDebug>
-#include <QtCore/QVariant>
-#include <QtCore/QList>
-#include <QtCore/QAtomicInt>
-#include <QtCore/QSharedPointer>
-
-#include <solid/solid_export.h>
-
-#include <qt_windows.h>
-#include <rpc.h>
-#include <comdef.h>
-#include <Wbemidl.h>
-#include <WTypes.h>
-
-#include "wmimanager.h"
-
-namespace Solid
-{
-namespace Backends
-{
-namespace Wmi
-{
-class WmiQuery
-{
-public:
- class Item
- {
- public:
- Item();
- Item(IWbemClassObject *p);
- Item(const Item &other);
- Item &operator=(const Item &other);
- ~Item();
-
- IWbemClassObject *data() const;
- bool isNull() const;
- QVariant getProperty(const QString &property) const;
- QVariantMap getAllProperties();
-
- private:
-
- static QVariant msVariantToQVariant(VARIANT msVariant, CIMTYPE variantType);
- QVariant getProperty(BSTR property) const;
- // QSharedPointer alone doesn't help because we need to call Release()
- IWbemClassObject *m_p;
- QVariantMap m_properies;
- };
-
- typedef QList<Item> ItemList;
-
- WmiQuery();
- ~WmiQuery();
- ItemList sendQuery(const QString &wql);
- void addDeviceListeners(WmiManager::WmiEventSink *sink);
- bool isLegit() const;
- static WmiQuery &instance();
-
-private:
- bool m_failed;
- bool m_bNeedUninit;
- IWbemLocator *pLoc;
- IWbemServices *pSvc;
-};
-}
-}
-}
-
-#endif
diff --git a/src/solid/backends/wmi/wmistorage.cpp b/src/solid/backends/wmi/wmistorage.cpp
deleted file mode 100644
index 07e205d..0000000
--- a/src/solid/backends/wmi/wmistorage.cpp
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- Copyright 2012 Patrick von Reth <vonreth at kde.org>
- Copyright 2006 Kevin Ottens <ervin at kde.org>
-
- 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 "wmistorage.h"
-#include "wmiquery.h"
-
-using namespace Solid::Backends::Wmi;
-
-Storage::Storage(WmiDevice *device)
- : Block(device)
-{
-
- if (m_device->type() == Solid::DeviceInterface::StorageDrive) {
- WmiQuery::Item item = WmiDevice::win32DiskPartitionByDeviceIndex(m_device->property("DeviceID").toString());
- QString id = item.getProperty("DeviceID").toString();
- m_logicalDisk = WmiDevice::win32LogicalDiskByDiskPartitionID(id);
- } else if (m_device->type() == Solid::DeviceInterface::OpticalDrive) {
- QString id = m_device->property("Drive").toString();
- m_logicalDisk = WmiDevice::win32LogicalDiskByDriveLetter(id);
- }
-}
-
-Storage::~Storage()
-{
-
-}
-
-Solid::StorageDrive::Bus Storage::bus() const
-{
- if (m_device->type() == Solid::DeviceInterface::OpticalDrive) {
- return Solid::StorageDrive::Platform;
- }
-
- QString bus = m_device->property("InterfaceType").toString().toLower();
-
- if (bus == "ide") {
- return Solid::StorageDrive::Ide;
- } else if (bus == "usb") {
- return Solid::StorageDrive::Usb;
- } else if (bus == "1394") {
- return Solid::StorageDrive::Ieee1394;
- } else if (bus == "scsi") {
- return Solid::StorageDrive::Scsi;
- }
-// else if (bus=="sata")//not availible http://msdn.microsoft.com/en-us/library/windows/desktop/aa394132(v=vs.85).aspx
-// {
-// return Solid::StorageDrive::Sata;
-// }
- else {
- return Solid::StorageDrive::Platform;
- }
-}
-
-Solid::StorageDrive::DriveType Storage::driveType() const
-{
- ushort type = m_logicalDisk.getProperty("DriveType").toUInt();
- switch (type) {
- case 2:
- return Solid::StorageDrive::MemoryStick;
- case 3:
- return Solid::StorageDrive::HardDisk;
- case 5:
- return Solid::StorageDrive::CdromDrive;
- default:
- return Solid::StorageDrive::HardDisk;
- }
-}
-
-bool Storage::isRemovable() const
-{
- return driveType() != Solid::StorageDrive::HardDisk;
-}
-
-bool Storage::isHotpluggable() const
-{
- return bus() == Solid::StorageDrive::Usb;
-}
-
-qulonglong Storage::size() const
-{
- return m_device->property("Size").toULongLong();
-}
-
diff --git a/src/solid/backends/wmi/wmistorage.h b/src/solid/backends/wmi/wmistorage.h
deleted file mode 100644
index 622c513..0000000
--- a/src/solid/backends/wmi/wmistorage.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- Copyright 2012 Patrick von Reth <vonreth at kde.org>
- Copyright 2006 Kevin Ottens <ervin at kde.org>
-
- 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 SOLID_BACKENDS_WMI_STORAGE_H
-#define SOLID_BACKENDS_WMI_STORAGE_H
-
-#include <solid/ifaces/storagedrive.h>
-#include "wmiblock.h"
-#include "wmiquery.h"
-
-namespace Solid
-{
-namespace Backends
-{
-namespace Wmi
-{
-class Storage : public Block, virtual public Solid::Ifaces::StorageDrive
-{
- Q_OBJECT
- Q_INTERFACES(Solid::Ifaces::StorageDrive)
-
-public:
- Storage(WmiDevice *device);
- virtual ~Storage();
-
- virtual Solid::StorageDrive::Bus bus() const;
- virtual Solid::StorageDrive::DriveType driveType() const;
-
- virtual bool isRemovable() const;
- virtual bool isHotpluggable() const;
- virtual qulonglong size() const;
-private:
- WmiQuery::Item m_logicalDisk;
-};
-}
-}
-}
-
-#endif // SOLID_BACKENDS_WMI_STORAGE_H
diff --git a/src/solid/backends/wmi/wmistorageaccess.cpp b/src/solid/backends/wmi/wmistorageaccess.cpp
deleted file mode 100644
index a09021c..0000000
--- a/src/solid/backends/wmi/wmistorageaccess.cpp
+++ /dev/null
@@ -1,203 +0,0 @@
-/*
- Copyright 2012 Patrick von Reth <vonreth at kde.org>
- Copyright 2006 Kevin Ottens <ervin at kde.org>
-
- 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 "wmistorageaccess.h"
-
-#include <QDebug>
-#include <QApplication>
-#include <QWidget>
-
-using namespace Solid::Backends::Wmi;
-
-StorageAccess::StorageAccess(WmiDevice *device)
- : DeviceInterface(device), m_setupInProgress(false), m_teardownInProgress(false),
- m_passphraseRequested(false)
-{
- connect(device, SIGNAL(propertyChanged(QMap<QString,int>)),
- this, SLOT(slotPropertyChanged(QMap<QString,int>)));
-// qDebug()<<"StorageAccess"<<m_device->type();
-
- m_logicalDisk = WmiDevice::win32LogicalDiskByDiskPartitionID(m_device->property("DeviceID").toString());
-}
-
-StorageAccess::~StorageAccess()
-{
-
-}
-
-bool StorageAccess::isAccessible() const
-{
- return !m_logicalDisk.isNull();
-}
-
-QString StorageAccess::filePath() const
-{
- QString path = m_logicalDisk.getProperty("DeviceID").toString();
- if (!path.isNull()) {
- path.append("\\");
- }
- return path;
-}
-
-bool Solid::Backends::Wmi::StorageAccess::isIgnored() const
-{
- return m_logicalDisk.isNull();
-}
-
-bool StorageAccess::setup()
-{
- if (m_teardownInProgress || m_setupInProgress) {
- return false;
- }
- m_setupInProgress = true;
-
- // if (m_device->property("info.interfaces").toStringList().contains("org.freedesktop.Wmi.Device.Volume.Crypto")) {
- // return requestPassphrase();
- // } else if (FstabHandling::isInFstab(m_device->property("block.device").toString())) {
- // return callSystemMount();
- // } else {
- // return callWmiVolumeMount();
- // }
- return false;
-}
-
-bool StorageAccess::teardown()
-{
- if (m_teardownInProgress || m_setupInProgress) {
- return false;
- }
- m_teardownInProgress = true;
-
- // if (m_device->property("info.interfaces").toStringList().contains("org.freedesktop.Wmi.Device.Volume.Crypto")) {
- // return callCryptoTeardown();
- // } else if (FstabHandling::isInFstab(m_device->property("block.device").toString())) {
- // return callSystemUnmount();
- // } else {
- // return callWmiVolumeUnmount();
- // }
- return false;
-}
-
-void StorageAccess::slotPropertyChanged(const QMap<QString, int> &changes)
-{
- if (changes.contains("volume.is_mounted")) {
- emit accessibilityChanged(isAccessible(), m_device->udi());
- }
-}
-
-void Solid::Backends::Wmi::StorageAccess::slotProcessFinished(int exitCode, QProcess::ExitStatus exitStatus)
-{
- /*
- Q_UNUSED(exitStatus);
- if (m_setupInProgress) {
- m_setupInProgress = false;
-
- if (exitCode==0) {
- emit setupDone(Solid::NoError, QVariant(), m_device->udi());
- } else {
- emit setupDone(Solid::UnauthorizedOperation,
- m_process->readAllStandardError(),
- m_device->udi());
- }
- } else if (m_teardownInProgress) {
- m_teardownInProgress = false;
- if (exitCode==0) {
- emit teardownDone(Solid::NoError, QVariant(), m_device->udi());
- } else {
- emit teardownDone(Solid::UnauthorizedOperation,
- m_process->readAllStandardError(),
- m_device->udi());
- }
- }
-
- delete m_process;
- */
-}
-
-QString generateReturnObjectPath()
-{
- static int number = 1;
-
- return "/org/kde/solid/WmiStorageAccess_" + QString::number(number++);
-}
-
-bool StorageAccess::callWmiVolumeMount()
-{
- // QDBusConnection c = QDBusConnection::systemBus();
- // QString udi = m_device->udi();
- // QDBusMessage msg = QDBusMessage::createMethodCall("org.freedesktop.Wmi", udi,
- // "org.freedesktop.Wmi.Device.Volume",
- // "Mount");
- // QStringList options;
- // QStringList wmiOptions = m_device->property("volume.mount.valid_options").toStringList();
-
- // if (wmiOptions.contains("uid=")) {
- // options << "uid="+QString::number(::getuid());
- // }
-
- // msg << "" << "" << options;
-
- // return c.callWithCallback(msg, this,
- // SLOT(slotDBusReply(QDBusMessage)),
- // SLOT(slotDBusError(QDBusError)));
- return false;
-}
-
-bool StorageAccess::callWmiVolumeUnmount()
-{
- // QDBusConnection c = QDBusConnection::systemBus();
- // QString udi = m_device->udi();
- // QDBusMessage msg = QDBusMessage::createMethodCall("org.freedesktop.Wmi", udi,
- // "org.freedesktop.Wmi.Device.Volume",
- // "Unmount");
-
- // msg << QStringList();
-
- // return c.callWithCallback(msg, this,
- // SLOT(slotDBusReply(QDBusMessage)),
- // SLOT(slotDBusError(QDBusError)));
- return false;
-}
-
-bool Solid::Backends::Wmi::StorageAccess::callSystemMount()
-{
- /*
- const QString device = m_device->property("block.device").toString();
- m_process = FstabHandling::callSystemCommand("mount", device,
- this, SLOT(slotProcessFinished(int,QProcess::ExitStatus)));
-
- return m_process!=0;
- */
- return 0;
-}
-
-bool Solid::Backends::Wmi::StorageAccess::callSystemUnmount()
-{
- /*
- const QString device = m_device->property("block.device").toString();
- m_process = FstabHandling::callSystemCommand("umount", device,
- this, SLOT(slotProcessFinished(int,QProcess::ExitStatus)));
-
- return m_process!=0;
- */
- return 0;
-}
-
diff --git a/src/solid/backends/wmi/wmistorageaccess.h b/src/solid/backends/wmi/wmistorageaccess.h
deleted file mode 100644
index 5d0a4f0..0000000
--- a/src/solid/backends/wmi/wmistorageaccess.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- Copyright 2012 Patrick von Reth <vonreth at kde.org>
- Copyright 2006 Kevin Ottens <ervin at kde.org>
-
- 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 SOLID_BACKENDS_WMI_STORAGEACCESS_H
-#define SOLID_BACKENDS_WMI_STORAGEACCESS_H
-
-#include <solid/ifaces/storageaccess.h>
-#include "wmideviceinterface.h"
-
-#include <QtCore/QProcess>
-
-namespace Solid
-{
-namespace Backends
-{
-namespace Wmi
-{
-class StorageAccess : public DeviceInterface, virtual public Solid::Ifaces::StorageAccess
-{
- Q_OBJECT
- Q_INTERFACES(Solid::Ifaces::StorageAccess)
-
-public:
- StorageAccess(WmiDevice *device);
- virtual ~StorageAccess();
-
- virtual bool isAccessible() const;
- virtual QString filePath() const;
- virtual bool isIgnored() const;
- virtual bool setup();
- virtual bool teardown();
-
-Q_SIGNALS:
- void accessibilityChanged(bool accessible, const QString &udi);
- void setupDone(Solid::ErrorType error, QVariant errorData, const QString &udi);
- void teardownDone(Solid::ErrorType error, QVariant errorData, const QString &udi);
- void setupRequested(const QString &udi);
- void teardownRequested(const QString &udi);
-
-private Q_SLOTS:
- void slotPropertyChanged(const QMap<QString, int> &changes);
- void slotProcessFinished(int exitCode, QProcess::ExitStatus exitStatus);
-
-private:
- bool callWmiVolumeMount();
- bool callWmiVolumeUnmount();
-
- bool callSystemMount();
- bool callSystemUnmount();
-
-private:
- bool m_setupInProgress;
- bool m_teardownInProgress;
- bool m_passphraseRequested;
- QString m_lastReturnObject;
- QProcess *m_process;
- WmiQuery::Item m_logicalDisk;
-};
-}
-}
-}
-
-#endif // SOLID_BACKENDS_WMI_STORAGEACCESS_H
diff --git a/src/solid/backends/wmi/wmivolume.cpp b/src/solid/backends/wmi/wmivolume.cpp
deleted file mode 100644
index 9db0185..0000000
--- a/src/solid/backends/wmi/wmivolume.cpp
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- Copyright 2012 Patrick von Reth <vonreth at kde.org>
- Copyright 2006 Kevin Ottens <ervin at kde.org>
-
- 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 "wmivolume.h"
-
-using namespace Solid::Backends::Wmi;
-
-Volume::Volume(WmiDevice *device)
- : Block(device)
-{
- if (m_device->type() == Solid::DeviceInterface::StorageVolume) {
- m_logicalDisk = WmiDevice::win32LogicalDiskByDiskPartitionID(m_device->property("DeviceID").toString());
- } else if (m_device->type() == Solid::DeviceInterface::OpticalDisc) {
- m_logicalDisk = WmiDevice::win32LogicalDiskByDriveLetter(m_device->property("Drive").toString());
- }
-}
-
-Volume::~Volume()
-{
-
-}
-
-bool Volume::isIgnored() const
-{
- return m_logicalDisk.isNull();
-}
-
-Solid::StorageVolume::UsageType Volume::usage() const
-{
- return Solid::StorageVolume::FileSystem;//TODO:???
-}
-
-QString Volume::fsType() const
-{
- return m_logicalDisk.getProperty("FileSystem").toString();
-}
-
-QString Volume::label() const
-{
- return m_logicalDisk.getProperty("VolumeName").toString();
-}
-
-QString Volume::uuid() const
-{
- return m_logicalDisk.getProperty("VolumeSerialNumber").toString();
-}
-
-qulonglong Volume::size() const
-{
- return m_device->property("Size").toULongLong();
-}
-
-QString Solid::Backends::Wmi::Volume::encryptedContainerUdi() const
-{
- return this->uuid();
-}
-
diff --git a/src/solid/backends/wmi/wmivolume.h b/src/solid/backends/wmi/wmivolume.h
deleted file mode 100644
index aef947b..0000000
--- a/src/solid/backends/wmi/wmivolume.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- Copyright 2012 Patrick von Reth <vonreth at kde.org>
- Copyright 2006 Kevin Ottens <ervin at kde.org>
-
- 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 SOLID_BACKENDS_WMI_VOLUME_H
-#define SOLID_BACKENDS_WMI_VOLUME_H
-
-#include <solid/ifaces/storagevolume.h>
-#include "wmiblock.h"
-
-namespace Solid
-{
-namespace Backends
-{
-namespace Wmi
-{
-class Volume : public Block, virtual public Solid::Ifaces::StorageVolume
-{
- Q_OBJECT
- Q_INTERFACES(Solid::Ifaces::StorageVolume)
-
-public:
- Volume(WmiDevice *device);
- virtual ~Volume();
-
- virtual bool isIgnored() const;
- virtual Solid::StorageVolume::UsageType usage() const;
- virtual QString fsType() const;
- virtual QString label() const;
- virtual QString uuid() const;
- virtual qulonglong size() const;
- virtual QString encryptedContainerUdi() const;
-
-private:
- WmiQuery::Item m_logicalDisk;
-};
-}
-}
-}
-
-#endif // SOLID_BACKENDS_WMI_VOLUME_H
diff --git a/src/solid/managerbase.cpp b/src/solid/managerbase.cpp
index 58bf71d..f2e06f2 100644
--- a/src/solid/managerbase.cpp
+++ b/src/solid/managerbase.cpp
@@ -42,9 +42,6 @@
#elif defined (Q_OS_WIN) && !defined(_WIN32_WCE)
#include "backends/win/windevicemanager.h"
-#ifdef WITH_SOLID_WMI
-#include "backends/wmi/wmimanager.h"
-#endif
#endif
Solid::ManagerBasePrivate::ManagerBasePrivate()
@@ -66,8 +63,6 @@ void Solid::ManagerBasePrivate::loadBackends()
# if defined(Q_OS_MAC)
m_backends << new Solid::Backends::IOKit::IOKitManager(0);
-# elif defined(Q_OS_WIN) && defined(WITH_SOLID_WMI) && !defined(_WIN32_WCE)
- m_backends << new Solid::Backends::Wmi::WmiManager(0);
# elif defined(Q_OS_WIN) && !defined(_WIN32_WCE)
m_backends << new Solid::Backends::Win::WinDeviceManager(0);
# elif defined(Q_OS_UNIX) && !defined(Q_OS_LINUX)
More information about the Kde-windows
mailing list