/* -*- Mode: C++; indent-tabs-mode: nil; tab-width: 4 -*-
 * -*- coding: utf-8 -*-
 *
 * Copyright (C) 2025 KylinSoft 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
 * 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 SOUNDTHEME_H
#define SOUNDTHEME_H

#include <string>
#include <list>
#include <vector>

#include <gio/gio.h>
#include <libxml/tree.h>
#include <glib-object.h>
#include <glib.h>
#include <glib/gi18n.h>
#include <gobject/gparamspecs.h>
#include <glib/gstdio.h>

namespace UkuiAudioFramwork
{
typedef struct SoundThemeInfo {
    std::string name;           // 音效主题的名称
    std::string description;    // 音效主题的描述

    std::string toString() const;
} SoundThemeInfo;

typedef struct SoundEffectFileInfo {
    std::string name;
    std::string description;

    std::string toString() const;
} SoundEffectFileInfo;

class SoundThemeModule
{
public:
    static SoundThemeModule& getInstance();

public:
    std::list<SoundThemeInfo> getSoundThemeList();

    std::list<SoundEffectFileInfo> getSoundEffectFileList(const std::string&);

private:
    std::string getIndexThemeName(const std::string&);

    void soundThemeInDir(GHashTable*, const std::string&);

    void setupThemeSelector();

    std::vector<std::string> getSoundThemeXmlFiles(const std::vector<std::string>& soundDirs);

    std::vector<SoundEffectFileInfo> getSoundListFromXml(const std::string& xmlFilePath);

    bool isExistDirPath(const std::string&);

private:
    SoundThemeModule() = default;
    SoundThemeModule(const SoundThemeModule&) = delete;
    SoundThemeModule(SoundThemeModule&&) = delete;
    SoundThemeModule operator=(const SoundThemeModule&) = delete;
    SoundThemeModule operator=(SoundThemeModule&&) = delete;
    virtual ~SoundThemeModule() = default;

private:
    std::list<SoundThemeInfo> m_soundThemeList {};
};
}
#endif // SOUNDTHEME_H
