/*
 * Ibis - IRCv3 Library
 * Copyright (C) Ibis Developers
 *
 * Ibis is the legal property of its developers, whose names are too numerous to
 * list here. Please refer to the COPYRIGHT file distributed with this source
 * distribution.
 *
 * This library 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 2 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 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/>.
 */

#if !defined(IBIS_GLOBAL_HEADER_INSIDE) && !defined(IBIS_COMPILATION)
# error "only <ibis.h> may be included directly"
#endif

#ifndef IBIS_CHANMODES_H
#define IBIS_CHANMODES_H

#include <glib.h>
#include <glib-object.h>

#include "ibisversion.h"

G_BEGIN_DECLS

/**
 * IbisChanmodeType:
 * @IBIS_CHANMODE_TYPE_UNKNOWN: the chanmode is unknown
 * @IBIS_CHANMODE_TYPE_A: the chanmode modifies a list
 * @IBIS_CHANMODE_TYPE_B: the chanmode always has a parameter
 * @IBIS_CHANMODE_TYPE_C: the chanmode only has a parameter when setting
 * @IBIS_CHANMODE_TYPE_D: the chanmode never has a parameter
 *
 * A type of a specific chanmode.
 *
 * See https://modern.ircdocs.horse/#channel-mode for more information.
 *
 * Since: 0.12
 */
IBIS_AVAILABLE_TYPE_IN_0_12
typedef enum {
	IBIS_CHANMODE_TYPE_UNKNOWN IBIS_AVAILABLE_ENUMERATOR_IN_0_12,
	IBIS_CHANMODE_TYPE_A IBIS_AVAILABLE_ENUMERATOR_IN_0_12,
	IBIS_CHANMODE_TYPE_B IBIS_AVAILABLE_ENUMERATOR_IN_0_12,
	IBIS_CHANMODE_TYPE_C IBIS_AVAILABLE_ENUMERATOR_IN_0_12,
	IBIS_CHANMODE_TYPE_D IBIS_AVAILABLE_ENUMERATOR_IN_0_12,
} IbisChanmodeType;

#define IBIS_TYPE_CHANMODES (ibis_chanmodes_get_type())

/**
 * IbisChanmodes:
 *
 * A helper for handling channel modes.
 *
 * Each specific channel mode has its own rules when it comes to whether or not
 * it has a parameter. This object helps you determine when a channel mode
 * requires a parameter or not.
 *
 * Since: 0.12
 */
IBIS_AVAILABLE_IN_0_12
G_DECLARE_FINAL_TYPE(IbisChanmodes, ibis_chanmodes, IBIS, CHANMODES, GObject)

/**
 * ibis_chanmodes_new:
 *
 * Creates a new instance based on the values from RFCs 1459 and 2811.
 *
 * Returns: (transfer full): The new instance.
 *
 * Since: 0.12
 */
IBIS_AVAILABLE_IN_0_12
IbisChanmodes *ibis_chanmodes_new(void);

/**
 * ibis_chanmodes_parse:
 * @chanmodes: the chanmodes value from the ISUPPORT reply
 * @prefix_modes: the modes from the PREFIX
 * Parses a CHANMODES string.
 *
 * This will parse @chanmodes and create a new lookup for it.
 *
 * Returns: (transfer full): The new instance.
 *
 * Since: 0.12
 */
IBIS_AVAILABLE_IN_0_12
IbisChanmodes *ibis_chanmodes_parse(const char *chanmodes, const char *prefix_modes);

/**
 * ibis_chanmodes_get_chanmode_type:
 * @mode: the mode to check
 *
 * Gets the chanmode type for the given mode.
 *
 * Returns: The type of the mode.
 *
 * Since: 0.12
 */
IBIS_AVAILABLE_IN_0_12
IbisChanmodeType ibis_chanmodes_get_chanmode_type(IbisChanmodes *chanmodes, char mode);

G_END_DECLS

#endif /* IBIS_CHANMODES_H */
