/*
 * Copyright (C) 2018 Tianjin KYLIN Information Technology Co., Ltd.
 *
 * 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, or (at your option)
 * 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 SESSIONWATCHER_H
#define SESSIONWATCHER_H

#include <QObject>
#include <QDBusObjectPath>
#include <QGSettings>
#include <QString>
#include <QTimer>
#include <QSettings>

class SessionWatcher : public QObject
{
    Q_OBJECT
public:
    explicit SessionWatcher(QObject *parent = nullptr);
    void setValue(const QString &key, const QVariant &value);
    bool isSleepActivationEnable();
    bool isCloseActivationEnable();
    bool isLockEnable();
    int sleepActivationDelay();
    int closeActivationDelay();
    int idledelay();
    bool isLidCloseWithBlank();    // 合盖关屏
    int locktimeout();

Q_SIGNALS:
    void sessionIdle();
    void sessionLockIdle();
    void sessionIdleExit();
    void lidStateChanged(bool isClosed);

private Q_SLOTS:
    void onStatusChanged(unsigned int status);
    void onSessionRemoved(const QDBusObjectPath &objectPath);
    void onConfigurationTimeTpChanged(QString key);
    void onSSConfigChanged(QString strKey);
    void onLidWatcherMessage(void);

private:
    QString sessionPath;
    QGSettings *timegsettings = nullptr;
    QSettings *configSettings = nullptr;
    QGSettings *m_ssSettings = nullptr;
    QGSettings *m_pmSettings = nullptr;
    QGSettings *m_sdSettings = nullptr;
    QGSettings *stylesettings = nullptr;
    int idleDelay = -1;
    int idleLock = -1;
    int m_nLockTimeout = -1;
    QTimer *m_timer = nullptr;
    QTimer *m_timer2 = nullptr;
    bool m_lidState = false;
    double defaultFontSize;
};

#endif // SESSIONWATCHER_H
