ibis/ibisctcpmessage.h

Tue, 29 Oct 2024 17:26:39 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Tue, 29 Oct 2024 17:26:39 -0500
changeset 136
55c73d296a5e
parent 94
65f90672c32a
permissions
-rw-r--r--

Fix the namespace in test_formatting

Not sure how this happened, but it's fixed now.

Testing Done:
Called in the turtles.

Reviewed at https://reviews.imfreedom.org/r/3616/

/*
 * 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:
 * @message: The instance.
 *
 * 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:
 * @message: The instance.
 * @command: The command to check.
 *
 * Checks if the command of @message matches @command.
 *
 * Returns: %TRUE if the command of @message matches @command, otherwise
 *          %FALSE.
 *
 * 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:
 * @message: The instance.
 *
 * 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:
 * @message: The instance.
 * @...: The 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):
 * @message: The instance.
 * @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,
 *          otherwise %NULL.
 *
 * Since: 0.5
 */
IBIS_AVAILABLE_IN_0_5
IbisCTCPMessage *ibis_ctcp_message_parse(const char *str);

/**
 * ibis_ctcp_message_serialize:
 * @message: The instance.
 *
 * 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 */

mercurial