/*
 * Copyright (C) 2017 ~ 2017 Deepin Technology Co., Ltd.
 *
 * Author:     Iceyer <me@iceyer.net>
 *
 * Maintainer: Iceyer <me@iceyer.net>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef LICENSECHECKER_H
#define LICENSECHECKER_H

#include <QObject>
#include <QDateTime>

enum ActiveState {
    Unauthorized    = 0x0000,
    Authorized      = 0xF0FF,
};

class QDBusInterface;

class LicenseHelper : public QObject
{
    Q_OBJECT

public:
    explicit LicenseHelper(QObject *parent = 0);

    quint32 importLicenseFile(const QString &licenseFile);
    quint32 importSerialKey(const QString &key);
    void deactive();
    void quit();
    bool exportInformation(const QString &infoFile);

signals:
    void activeStateChanged(quint32);

public:
    quint32 licenseState();
    QString organization();
    QString product();
    QString copyright();
    QString edition();
    QString machineCode();
    QDateTime validityBegin();
    QDateTime validityEnd();

    int trialRemind();
    QString systemCopyright();
    QString systemEdition();
    QString systemMachinecode();
    QString systemVersion();

private:
    QDBusInterface  *licenseAgent = nullptr;
    QDBusInterface  *licenseInfo  = nullptr;
};

#endif // LICENSECHECKER_H
