#ifndef DEVICE_MONITOR_H
#define DEVICE_MONITOR_H

#include <QObject>
#include <QMap>
#include <QTimer>
#include <QThread>
#include <QDebug>

#include "device_information.h"
// 设置是否需要只需要打印机 默认为true
// 如果修改为false 则会识别所有接入的usb设备
#define setFindPrinterOnly true
class DeviceMonitor : public QObject
{
    Q_OBJECT
public:
    static QList<DeviceInformation> getAllPrinterWithPDD(const bool usbConnectOnly);
    static QList<DeviceInformation> getAllPrinterConnected();
    static DeviceMonitor *getInstance();
    ~DeviceMonitor();
    void getarg(QStringList arg);
private:
    QMap<QString, DeviceInformation> m_mpDeviceInformationMap;
    DeviceMonitor();
    bool usbDeviceAdd      (const QString &);
    bool usbDeviceRemove   (const QString &);

signals:
    void findUsbConnect    (DeviceInformation &);
    void findUsbDisconnect (QString &);
};



class DeviceMonitorBackend : public QObject
{
    Q_OBJECT

private:
    DeviceMonitorBackend();
public:
    static DeviceMonitorBackend *getInstance();
    ~DeviceMonitorBackend();

private:
    void detectStart ();
    bool usbDeviceIdentify (const QString &);

signals:
    void start();
    bool usbDeviceAdd      (const QString &);
    bool usbDeviceRemove   (const QString &);
};

#endif // DEVICE_MONITOR_H
