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
21QT_BEGIN_NAMESPACE
22
23class QDeviceDiscoveryUDev : public QDeviceDiscovery
24{
25 Q_OBJECT
26
27public:
28 QDeviceDiscoveryUDev(QDeviceTypes types, struct udev *udev, QObject *parent = nullptr);
29 ~QDeviceDiscoveryUDev();
30 QStringList scanConnectedDevices() override;
31
32private slots:
33 void handleUDevNotification();
34
35protected:
36 struct udev *m_udev;
37
38private:
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
49QT_END_NAMESPACE
50
51#endif // QDEVICEDISCOVERY_UDEV_H
52

source code of qtbase/src/platformsupport/devicediscovery/qdevicediscovery_udev_p.h