1 /* 2 Copyright 2012 Patrick von Reth <vonreth@kde.org> 3 Copyright 2005,2006 Kevin Ottens <ervin@kde.org> 4 5 This library is free software; you can redistribute it and/or 6 modify it under the terms of the GNU Lesser General Public 7 License as published by the Free Software Foundation; either 8 version 2.1 of the License, or (at your option) version 3, or any 9 later version accepted by the membership of KDE e.V. (or its 10 successor approved by the membership of KDE e.V.), which shall 11 act as a proxy defined in Section 6 of version 3 of the license. 12 13 This library is distributed in the hope that it will be useful, 14 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 Lesser General Public License for more details. 17 18 You should have received a copy of the GNU Lesser General Public 19 License along with this library. If not, see <http://www.gnu.org/licenses/>. 20 */ 21 22 #ifndef SOLID_BACKENDS_WMI_WMIMANAGER_H 23 #define SOLID_BACKENDS_WMI_WMIMANAGER_H 24 25 #include <solid-lite/ifaces/devicemanager.h> 26 #include <solid-lite/deviceinterface.h> 27 28 #include <QVariant> 29 #include <QStringList> 30 31 #include <Wbemidl.h> 32 33 namespace Solid 34 { 35 namespace Backends 36 { 37 namespace Wmi 38 { 39 class WmiManagerPrivate; 40 41 class WmiManager : public Solid::Ifaces::DeviceManager 42 { 43 Q_OBJECT 44 45 public: 46 47 class WmiEventSink : public IWbemObjectSink 48 { 49 public: 50 WmiEventSink(class WmiManager* parent,const QString &query,const QList<Solid::DeviceInterface::Type> &types); 51 ~WmiEventSink(); 52 53 virtual ulong STDMETHODCALLTYPE AddRef(); 54 virtual ulong STDMETHODCALLTYPE Release(); 55 56 virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppv); 57 58 virtual HRESULT STDMETHODCALLTYPE Indicate(long lObjectCount,IWbemClassObject **apObjArray); 59 60 virtual HRESULT STDMETHODCALLTYPE SetStatus(long lFlags,HRESULT hResult,BSTR strParam,IWbemClassObject *pObjParam); 61 62 const QString& query() const; 63 64 private: 65 WmiManager *m_parent; 66 QString m_query; 67 QList<Solid::DeviceInterface::Type> m_types; 68 long m_count; 69 70 }; 71 72 WmiManager(QObject *parent=0); 73 virtual ~WmiManager(); 74 75 virtual QString udiPrefix() const ; 76 virtual QSet<Solid::DeviceInterface::Type> supportedInterfaces() const; 77 78 virtual QStringList allDevices(); 79 virtual bool deviceExists(const QString &udi); 80 81 virtual QStringList devicesFromQuery(const QString &parentUdi, 82 Solid::DeviceInterface::Type type); 83 84 virtual QObject *createDevice(const QString &udi); 85 86 87 private Q_SLOTS: 88 void slotDeviceAdded(const QString &udi); 89 void slotDeviceRemoved(const QString &udi); 90 91 private: 92 QStringList findDeviceStringMatch(const QString &key, const QString &value); 93 QStringList findDeviceByDeviceInterface(Solid::DeviceInterface::Type type); 94 95 WmiManagerPrivate *d; 96 friend class WmiManagerPrivate; 97 }; 98 } 99 } 100 } 101 102 #endif // SOLID_BACKENDS_WMI_WMIMANAGER_H 103