File indexing completed on 2024-05-19 05:37:50
0001 /* 0002 SPDX-FileCopyrightText: 2007 Menard Alexis <darktears31@gmail.com> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #pragma once 0008 0009 #include <QObject> 0010 0011 #include <Plasma5Support/DataEngine> 0012 #include <Plasma5Support/Service> 0013 0014 #include <Solid/Predicate> 0015 0016 class KDirWatch; 0017 0018 /** 0019 * This class is connected with solid, filter devices and provide signal with source for applet in Plasma 0020 */ 0021 class HotplugEngine : public Plasma5Support::DataEngine 0022 { 0023 Q_OBJECT 0024 0025 public: 0026 HotplugEngine(QObject *parent); 0027 ~HotplugEngine() override; 0028 void init(); 0029 Plasma5Support::Service *serviceForSource(const QString &source) override; 0030 0031 protected Q_SLOTS: 0032 void onDeviceAdded(const QString &udi); 0033 void onDeviceRemoved(const QString &udi); 0034 0035 private: 0036 void handleDeviceAdded(Solid::Device &dev, bool added = true); 0037 void findPredicates(); 0038 QStringList predicatesForDevice(Solid::Device &device) const; 0039 QVariantList actionsForPredicates(const QStringList &predicates) const; 0040 0041 private Q_SLOTS: 0042 void processNextStartupDevice(); 0043 void updatePredicates(const QString &path); 0044 0045 private: 0046 QHash<QString, Solid::Predicate> m_predicates; 0047 QHash<QString, Solid::Device> m_startList; 0048 QHash<QString, Solid::Device> m_devices; 0049 Solid::Predicate m_encryptedPredicate; 0050 KDirWatch *m_dirWatch; 0051 };