#ifndef DEVICE_INFORMATION_H
#define DEVICE_INFORMATION_H

#include <QDebug>
#include <QObject>
#include <QString>
#include <QStringList>
#include <map>

enum class ConnectType : int {
    InfoFrom_Invalid = 0,
    InfoFrom_USB,
    InfoFrom_NETWORK_DETECT,
    InfoFrom_PRINTER_IP,
    InfoFrom_REMOTE_IP
};

enum class ProtocolType : int {
    NONE = 0,
    LPD, // lpd://${打印机网络节点}/${打印机服务}
    IPP, // ipp://${IP}:${端口}/ipp/print
    HTTP, // http://${IP}
    SOCKET, // socket://${IP}:${端口}
    DNSSD, // dnssd://${打印机名称}._ipp._tcp.local/?uuid=${UUID}
    HTTPS,
};

const QMap<QString, ProtocolType> protocolMap = { std::map<QString, ProtocolType>::value_type("none", ProtocolType::NONE),
    std::map<QString, ProtocolType>::value_type("lpd", ProtocolType::LPD), std::map<QString, ProtocolType>::value_type("ipp", ProtocolType::IPP),
    std::map<QString, ProtocolType>::value_type("http", ProtocolType::HTTP), std::map<QString, ProtocolType>::value_type("socket", ProtocolType::SOCKET),
    std::map<QString, ProtocolType>::value_type("dnssd", ProtocolType::DNSSD), std::map<QString, ProtocolType>::value_type("https", ProtocolType::HTTPS) };

struct DeviceInformation {
    // 公有部分
    ConnectType connectType;
    ProtocolType protocolType;
    QString name; // 打印机的名字
    QString vendor; // 供应商
    QString model; // 型号
    QString serial; // 序列号
    QString uri; // 设备uri
    QStringList packagesName; // 包名
    QString makeAndModel; // make-and-model
    QString uuid;
    QString ppdName;

    // usb 部分
    QString sysPath; // sys下的目录
    QString devicePath; // dev下的目录 绝对路径
    QString deviceType; // 设备种类 打印机为07
    QString busNumber;
    QString deviceNumber;
    QString VID; // usb vid
    QString PID; // usb pid

    // 网络部分
    QString networkNode;
    QString host;
};

extern QString devInfoPrint(const DeviceInformation&);

extern QDebug operator<<(QDebug debug, const DeviceInformation&);

extern QStringList getPackagesNameFromHttp(DeviceInformation&);

Q_DECLARE_METATYPE(DeviceInformation)

#endif // DEVICE_INFORMATION_H