#ifndef UKCCSESSIONSERVER_H
#define UKCCSESSIONSERVER_H

#include <QObject>
#include <QFile>
#include <QTextStream>
#include <QDir>
#include <QDebug>
#include <QVariantMap>
#include <QCoreApplication>
#include <QDBusContext>
#include <QScopedPointer>
#include <QDBusVariant>
#include <QFileSystemWatcher>
#include <QXmlStreamReader>
#include <QPluginLoader>
#include <QSettings>
#include <kysdk/kysdk-system/libkysysinfo.h>

#include "json.h"
#include "screenStruct.h"

#include "../shell/interface.h"

using QtJson::JsonObject;
using QtJson::JsonArray;

const QString XML_Source       = "source";
const QString XML_Title        = "translation";
const QString XML_Numerusform  = "numerusform";
const QString XML_Explain_Path = "extra-contents_path";

extern "C" {
#include <glib.h>
}

class ukccSessionServer : public QObject
{
    Q_OBJECT
    Q_CLASSINFO("D-Bus Interface", "org.ukui.ukcc.session.interface")
public:
    explicit ukccSessionServer();

private:
    QMap<QString, QVariant> getJsonInfo(const  QString &confFile);
    void monitoFileChanged();
    void clearSearchData();
    bool isOpenkylin();
    bool isCommunity();
    bool isSupportsEffect();
    void addModulesName(QString moduleName, QString searchName, QString translation, int type);
    QString getModulesName(QString name, bool state = true);
    QString getModuleType(QString name);
    void LoadPlugin();
    void determinePlugin(const QString &fileName, const QDir &dir);

private:
    QString mScreenMode;
    QVariantList mPreScreenCfg;
    QString mFilePath;
    struct SearchBoxStruct {
        QString translateContent;
        QString actualModuleName;
        QString childPageName;
        QString fullPagePath;
    };
    SearchBoxStruct m_searchBoxStruct;
    QString m_xmlExplain;
    QString m_lang;
    QList<QPair<QPair<QString, QString>, int>> m_moduleNameList;
    QSet<QString> m_xmlFilePath;
    QStringList filterPathList = {"/Display/Auto Brightness", "/Display/Dynamic light"};


Q_SIGNALS:
    void configChanged();
    void screenChanged(QString status);
    void searchItemsAdd(QVariantMap addItems);
    void searchItemsDelete(QVariantMap deleteItems);

public Q_SLOTS:
    void exitService();
    void        ReloadSecurityConfig();
    QVariantMap getModuleHideStatus();
    QVariantMap getSearchItems();
    QString     GetSecurityConfigPath();
    QString getScreenMode();
    void setScreenMode(QString screenMode);
    void setPreScreenCfg(QVariantList preScreenCfg);
    QVariantList getPreScreenCfg();
};

#endif // UKCCSESSIONSERVER_H
