#pragma once

#include <QScopedPointer>
#include "software/softwarefilter.h"
#include "systemdetectorinterface.h"

extern const char *OS_HISTORY_KEY;

class CommonSystemDetectorPrivate;
class CommonSystemDetector: public SystemDetectorInterface
{
public:
    explicit CommonSystemDetector(QObject *parent = Q_NULLPTR);
    virtual ~CommonSystemDetector() Q_DECL_OVERRIDE;

    virtual QString macAddress() const = 0;
    virtual QString version() const;
    virtual QString platform() const;

    virtual void saveOSHistory() = 0;

    virtual QSharedPointer<SystemInfo> fetchSystemInfo() Q_DECL_OVERRIDE;
    virtual void clearCache() Q_DECL_OVERRIDE;
    virtual QJsonArray getSoftwareInfo();

    QList<AdapterInfo> queryAdapterInfo() const;

    QList<SoftwareFilter> getSoftwareFilters() const;
    QJsonObject getSoftwareUsedHistory();
    void setSoftareUsedHistory(const QJsonObject &softwareTimes);

public Q_SLOTS:
    void onSoftwareStarted(int pid, const QString &cmd, const qint64 startup);
    void onSoftwareStoped(int pid, const QString &cmd, const qint64 shutdown);
    void clearSoftwareTimes();

private:
    QScopedPointer<CommonSystemDetectorPrivate> dd_ptr;
    Q_DECLARE_PRIVATE_D(qGetPtrHelper(dd_ptr), CommonSystemDetector)
};

