| 1 | // Copyright (C) 2016 The Qt Company Ltd. |
|---|---|
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
| 3 | |
| 4 | #ifndef QDEVICEDISCOVERY_UDEV_H |
| 5 | #define QDEVICEDISCOVERY_UDEV_H |
| 6 | |
| 7 | // |
| 8 | // W A R N I N G |
| 9 | // ------------- |
| 10 | // |
| 11 | // This file is not part of the Qt API. It exists purely as an |
| 12 | // implementation detail. This header file may change from version to |
| 13 | // version without notice, or even be removed. |
| 14 | // |
| 15 | // We mean it. |
| 16 | // |
| 17 | |
| 18 | #include "qdevicediscovery_p.h" |
| 19 | #include <libudev.h> |
| 20 | |
| 21 | QT_BEGIN_NAMESPACE |
| 22 | |
| 23 | class QDeviceDiscoveryUDev : public QDeviceDiscovery |
| 24 | { |
| 25 | Q_OBJECT |
| 26 | |
| 27 | public: |
| 28 | QDeviceDiscoveryUDev(QDeviceTypes types, struct udev *udev, QObject *parent = nullptr); |
| 29 | ~QDeviceDiscoveryUDev(); |
| 30 | QStringList scanConnectedDevices() override; |
| 31 | |
| 32 | private slots: |
| 33 | void handleUDevNotification(); |
| 34 | |
| 35 | protected: |
| 36 | struct udev *m_udev; |
| 37 | |
| 38 | private: |
| 39 | bool checkDeviceType(struct udev_device *dev); |
| 40 | |
| 41 | void startWatching(); |
| 42 | void stopWatching(); |
| 43 | |
| 44 | struct udev_monitor *m_udevMonitor = nullptr; |
| 45 | int m_udevMonitorFileDescriptor = -1; |
| 46 | QSocketNotifier *m_udevSocketNotifier = nullptr; |
| 47 | }; |
| 48 | |
| 49 | QT_END_NAMESPACE |
| 50 | |
| 51 | #endif // QDEVICEDISCOVERY_UDEV_H |
| 52 |
