/*
 * Copyright (C) 2023, KylinSoft Co., Ltd.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 3 of the License, or (at your option) any later version.
 *
 * This library 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this library.  If not, see <https://www.gnu.org/licenses/>.
 *
 * Authors: tianshaoshuai <tianshaoshuai@kylinos.cn>
 *
 */

#ifndef KSETTINGSSCHEMA_H
#define KSETTINGSSCHEMA_H

#include <gio/gio.h>

#if __cplusplus
extern "C"
{
#endif
    typedef struct _AppData
    {
        char *name;
        char *default_version;
    } AppData;

    typedef struct _VersionData
    {
        char *name;
        char **compatible;
    } VersionData;

    typedef struct _SchemaData
    {
        GHashTable *values;
        GArray *children;
        char *id;
        char *version;
    } SchemaData;

    typedef struct _SchemaData KSettingsSchema;

    extern GHashTable *schemas_table;

    KSettingsSchema *kdk_conf2_schema_table_lookup(const char *id, const char *version);

    KSettingsSchema *kdk_conf2_schema_reload(const char *id, const char *version);

    void kdk_conf2_schema_destroy(KSettingsSchema *schema);

    char *kdk_conf2_schema_get_id(KSettingsSchema *schema);

    char *kdk_conf2_schema_get_version(KSettingsSchema *schema);

    GHashTable *kdk_conf2_schema_get_key(KSettingsSchema *schema, const char *key);

    int kdk_conf2_schema_has_key(KSettingsSchema *schema);

    char **kdk_conf2_schema_list_keys(KSettingsSchema *schema);

    char **kdk_conf2_schema_list_children(KSettingsSchema *schema);

    int kdk_conf2_schema_find_child(KSettingsSchema *schema, const char *name);

    char *kdk_conf2_schema_key_value_type(GHashTable *key);

    char *kdk_conf2_schema_key_get_value(GHashTable *key);

    char *kdk_conf2_schema_key_get_default_value(GHashTable *key);

    char *kdk_conf2_schema_key_get_range(GHashTable *key);

    int kdk_conf2_schema_key_range_check(GHashTable *key, const char *value);

    char *kdk_conf2_schema_key_get_name(GHashTable *key);

    char *kdk_conf2_schema_key_get_summary(GHashTable *key);

    char *kdk_conf2_schema_key_get_description(GHashTable *key);

    char *kdk_conf2_schema_key_get_permission(GHashTable *key);

    void kdk_conf2_schema_update_schemas_table();

#if __cplusplus
}
#endif

#endif // KSETTINGSSCHEMA_H
