//
// Created by oubayasho on 2023/6/6.
//

#ifndef UNTITLED6_DEVICEFINDER_H
#define UNTITLED6_DEVICEFINDER_H

#include <QTimer>
#include "device_information.h"
//#include "network_device_detector.h"
#include <QThread>
#include <sane/sane.h>

class deviceFinder : public QObject
{
    Q_OBJECT
public:
    deviceFinder(QObject *parent = nullptr);
    ~deviceFinder();
    QList<DeviceInformation> getList();
Q_SIGNALS:
    void finished();
    void succeed();
    void failed();
public:
    void startWorker(){
        if(m_thread!=nullptr)
            m_thread->start();
    }
private:
    void dowork();
    void doPackageWork();
    bool infoCheck(DeviceInformation &deviceInformation);
    bool checkDeviceExistInSane(DeviceInformation &deviceInformation);
    void buriedDeviceInfomation(QList<DeviceInformation> list);
    QThread *m_thread{nullptr};
    QList<DeviceInformation> m_infoList;
    QList<DeviceInformation> m_saneInfoList;
    bool m_isServerAddressConnected{false};
};


#endif//UNTITLED6_DEVICEFINDER_H
