#pragma once

#include <QObject>
#include <QScopedPointer>
#include <QSharedPointer>

class UserInfo
{
public:
    QString uuid;
    QString orgcode;
    QString orgname;
    QString department;
    QString roomNumber;
    QString ownner;

    static UserInfo fromObject(const QJsonObject &json);
    static UserInfo fromJson(const QByteArray &json);
    QJsonObject toObject() const;
    QByteArray toJson() const;
};

class DiskInfo
{
public:
    QString name;
    QString model;
    QString serial_no;
};

class ExternInfo
{
public:
    QString machineID;
    QString deepinVersion;
    QString deepinCopyright;
    QString deepinEdition;
    QString dmi_board_serial;
    QString dmi_product_uuid;

    QJsonObject toObject() const;
};

//QNetworkInterface(name = "enp2s0", hardware address = "40:8D:5C:29:15:64", flags = IsUp IsRunning CanBroadcast CanMulticast , entries = ((address = QHostAddress("10.0.12.189"), netmask = QHostAddress("255.255.254.0"), broadcast = QHostAddress("10.0.13.255")), (address = QHostAddress("fe80::a6e4:10fd:d76f:8a3e%enp2s0"), netmask = QHostAddress("ffff:ffff:ffff:ffff::"))))
class AdapterInfo
{
public:
    QString name;
    QString description;
    QString humanReadableName;
    QString hardwareAddress;
    QString flags;
    QStringList addressList;
};

class SystemInfoPrivate;
class SystemInfo : public QObject
{
    Q_OBJECT
public:
    explicit SystemInfo(QObject *parent = Q_NULLPTR);
    ~SystemInfo();

    QByteArray briefV1() const;
    QByteArray briefV2() const;
    QByteArray full() const;

    QByteArray toJson() const;
    void loadJson(const QByteArray &jsonData);
    QString getMacAddress();

public Q_SLOTS:
    void setUUID(const QString &uuid);
    void setMacAddress(const QString &addr);
    void setDiskInfo(const QList<DiskInfo> &disks);
    void setExternInfo(const ExternInfo &info);
    void setAdapterInfo(const QList<AdapterInfo> &adapterInfo);
//    void setOSInfo(const QJsonObject &osInfo);
//    void setOfficeInfo(const QJsonObject &osInfo);
    void setAreaCode(const QString &areaCode);
    void setUserInfo(const UserInfo &userInfo);
    void setSoftInfo(const QJsonArray &softInfo);

private:
    QScopedPointer<SystemInfoPrivate> dd_ptr;
    Q_DECLARE_PRIVATE_D(qGetPtrHelper(dd_ptr), SystemInfo)
};

