-
Notifications
You must be signed in to change notification settings - Fork 1
/
usbdevicemonitor.h
42 lines (30 loc) · 1.03 KB
/
usbdevicemonitor.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#ifndef USBDEVICEMONITOR_H
#define USBDEVICEMONITOR_H
////////////////////////////////////////////////////////////////////////////////
// Class implementing monitoring for inserting/removing USB devices
#include <QObject>
#include <QAbstractNativeEventFilter>
#include <QSocketNotifier>
#include "common.h"
class UsbDeviceMonitorPrivate;
class UsbDeviceMonitor : public QObject, public QAbstractNativeEventFilter
{
Q_OBJECT
protected:
UsbDeviceMonitorPrivate* const d_ptr;
public:
explicit UsbDeviceMonitor(QObject *parent = 0);
~UsbDeviceMonitor();
// Implements QAbstractNativeEventFilter interface for processing WM_DEVICECHANGE messages (Windows)
bool nativeEventFilter(const QByteArray& eventType, void* message, qintptr* result);
protected:
// Closes handles and frees resources
void cleanup();
signals:
// Emitted when device change notification arrives
void deviceChanged();
public slots:
// Initializes monitoring for USB devices
bool startMonitoring();
};
#endif // USBDEVICEMONITOR_H