#ifndef ABOUTINTERFACE_H
#define ABOUTINTERFACE_H

#include <QObject>
#include <QDBusArgument>
#include <QVariant>
#include <QDBusMetaType>
#include <QGSettings>
#include "../../universalinterface.h"
#include <kysdk/kysdk-system/libkysysinfo.h>

struct dnsInfo
{
    char *servname;
    pthread_t pid;
};

class AboutInterface : public QObject
{
    Q_OBJECT
    Q_CLASSINFO("D-Bus Interface", "org.ukui.ukcc.session.About")
    Q_PROPERTY(QStringList versionInfo READ getSystemVersion)
    Q_PROPERTY(QString themeMode READ getThemeMode)
    Q_PROPERTY(QStringList build READ getBuild)
    Q_PROPERTY(QString desktop READ getDesktopEnv)
    Q_PROPERTY(QString memory READ getTotalMemory)
    Q_PROPERTY(QString blockInfo READ getBlockInfo)
    Q_PROPERTY(QString diskInfo READ getDiskInfo)
    Q_PROPERTY(QString upgradeDate READ getUpgradeDate)
    Q_PROPERTY(QString netDate READ getNtpTime)
public:
    AboutInterface();

protected:
    QStringList getSystemVersion();
    QString getThemeMode();
    QStringList getBuild();
    QString getDesktopEnv();
    QString getTotalMemory();
    QString getBlockInfo();
    QString getDiskInfo();
    QString getUpgradeDate();
    QString getNtpTime();

public Q_SLOTS:
    bool openActivation();

private:
    QStringList readFile(QString filepath);
    int ntpGethostbyname(char *servname);
    char *ntpdate(char *hostname);
    static void *threadGetAddrInfo(void *arg);
    void getSystemVersionList();
    void getBuildList();
    void getDesktopEnvStr();
    void getTotalMemoryStr();
    void getBlockInfoStr();

private:
    QGSettings *mStyleGsettings = nullptr;
    QStringList mNtphostNameList;
    static QStringList ipList;
    QStringList mSystemVersion;
    QStringList mBuild;
    QString mDesktopEnv;
    QString mTotalMem;
    QString mBlockInfo;

};
//QStringList AboutInterface::ipList = QStringList();

#endif // ABOUTINTERFACE_H
