#ifndef KYLIN_PRINTER_COMMON_H
#define KYLIN_PRINTER_COMMON_H

#include <QString>
#include <QStringList>
#include <QMap>
#include <map>

#define QTC(x) (qstringTochar(x).data())

enum CheckRes{
    CHECK_FALSE = 0,
    MAINWINDOW,
    POPWINDOW,
    DEBUG,
};

enum class PopWinStatus : int
{
    HIDE = 0,
    INSTALLING,
    INSTALL_SUCCESS,
    INSTALL_FAIL,
};

CheckRes checkCommand(const QStringList &command);

QString getRetFromCommand(const QStringList &command);

void runCommand(const QStringList &command);

QByteArray qstringTochar(const QString &qstr);

QString getUserName();

bool isAdministratorUser();

const QMap<QString, QString> mfgConvertMap = {
    std::map<QString, QString>::value_type("Lenovo Image", "Lenovo"),
    std::map<QString, QString>::value_type("Fuji Xerox", "Fuji-Xerox"),
    std::map<QString, QString>::value_type("INDEX BRAILLE", "INDEX-BRAILLE"),
    std::map<QString, QString>::value_type("KONICA MINOLTA", "KONICA-MINOLTA"),
    std::map<QString, QString>::value_type("Hewlett-Packard", "HP")
};

void specialDeviceCheck(QString &vendor, QString &model);

extern QString devicePathCheck(const QString &path);

extern bool ipIsValid(const QString &ipAddr);

extern bool printerNameIsLegal(const QString &printerName);

enum class CommonStatusFlag : int
{
    NONE = 0,
    SUCCESS,
    FAIL,

    ERROR_EXIST_SAME_PRINTER,
};

struct CommonStatus {
    CommonStatusFlag status{CommonStatusFlag::NONE};
    QString message{QString()};
};

extern bool processCheck(const QString &processName);

QString getPackageVersion(const QString &packageName);

#endif // KYLIN_PRINTER_COMMON_H
