/*
 * Ibis - IRCv3 Library
 * Copyright (C) 2022-2024 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_CTCP_MESSAGE_H
#define IBIS_CTCP_MESSAGE_H

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

#include "ibisversion.h"

G_BEGIN_DECLS

#define IBIS_TYPE_CTCP_MESSAGE (ibis_ctcp_message_get_type())

/**
 * IbisCTCPMessage:
 *
 * An object that represents a `CTCP` message.
 *
 * See the
 * [draft CTCP RFC](https://datatracker.ietf.org/doc/html/draft-oakley-irc-ctcp-02)
 * for more information.
 *
 * Since: 0.5
 */
IBIS_AVAILABLE_IN_0_5
G_DECLARE_FINAL_TYPE(IbisCTCPMessage, ibis_ctcp_message, IBIS, CTCP_MESSAGE,
                     GObject)

/**
 * ibis_ctcp_message_get_command:
 *
 * Gets the command from @message.
 *
 * Returns: The command.
 *
 * Since: 0.5
 */
IBIS_AVAILABLE_IN_0_5
const char *ibis_ctcp_message_get_command(IbisCTCPMessage *message);

/**
 * ibis_ctcp_message_is_command:
 * @command: the command to check
 *
 * Checks if the command of @message matches @command.
 *
 * Returns: true if the command of @message matches @command; false otherwise.
 *
 * Since: 0.7
 */
IBIS_AVAILABLE_IN_0_7
gboolean ibis_ctcp_message_is_command(IbisCTCPMessage *message, const char *command);

/**
 * ibis_ctcp_message_new:
 * @command: the command
 *
 * Creates a new `CTCP` message with @command as the command.
 *
 * @command will be normalized via [func@GLib.utf8_strup] since 0.6.0.
 *
 * Returns: (transfer full): The new message.
 *
 * Since: 0.5
 */
IBIS_AVAILABLE_IN_0_5
IbisCTCPMessage *ibis_ctcp_message_new(const char *command);

/**
 * ibis_ctcp_message_get_params:
 *
 * Gets the parameters from @message.
 *
 * Returns: (transfer none) (nullable): The parameters.
 *
 * Since: 0.5
 */
IBIS_AVAILABLE_IN_0_5
GStrv ibis_ctcp_message_get_params(IbisCTCPMessage *message);

/**
 * ibis_ctcp_message_set_params:
 * @...: a list of parameters to add followed by %NULL.
 *
 * Sets the parameters of @message.
 *
 * Since: 0.5
 */
IBIS_AVAILABLE_IN_0_5
void ibis_ctcp_message_set_params(IbisCTCPMessage *message, ...) G_GNUC_NULL_TERMINATED;

/**
 * ibis_ctcp_message_set_paramsv: (rename-to ibis_ctcp_message_set_params):
 * @params: (transfer none) (nullable): the new parameters
 *
 * Sets the parameters of @message to @params.
 *
 * Since: 0.5
 */
IBIS_AVAILABLE_IN_0_5
void ibis_ctcp_message_set_paramsv(IbisCTCPMessage *message, GStrv params);

/**
 * ibis_ctcp_message_parse:
 * @str: the string to parse
 *
 * Attempts to parse a `CTCP` message from @str.
 *
 * If @str is not a valid `CTCP` message, %NULL will be returned.
 *
 * Returns: (transfer full) (nullable): The `CTCP` message if successful.
 *
 * Since: 0.5
 */
IBIS_AVAILABLE_IN_0_5
IbisCTCPMessage *ibis_ctcp_message_parse(const char *str);

/**
 * ibis_ctcp_message_serialize:
 *
 * Serializes @message to a string.
 *
 * Returns: (transfer full): The serialized version of @message.
 *
 * Since: 0.5
 */
IBIS_AVAILABLE_IN_0_5
char *ibis_ctcp_message_serialize(IbisCTCPMessage *message);

G_END_DECLS

#endif /* IBIS_CTCP_MESSAGE_H */
