/*
 * 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/>.
 */

#include "ibismodechange.h"

G_DEFINE_BOXED_TYPE(IbisModeChange,
                    ibis_mode_change,
                    ibis_mode_change_copy,
                    ibis_mode_change_free);

/******************************************************************************
 * Public API
 *****************************************************************************/
IbisModeChange *
ibis_mode_change_copy(IbisModeChange *mode_change) {
	if(mode_change == NULL) {
		return NULL;
	}

	return ibis_mode_change_new(mode_change->mode, mode_change->add,
	                            mode_change->parameter);
}

void
ibis_mode_change_free(IbisModeChange *mode_change) {
	g_return_if_fail(mode_change != NULL);

	g_free(mode_change->parameter);
	g_free(mode_change);
}

IbisModeChange *
ibis_mode_change_new(const char mode, gboolean add, const char *parameter) {
	IbisModeChange *mode_change = NULL;

	mode_change = g_new(IbisModeChange, 1);

	mode_change->mode = mode;
	mode_change->add = add;
	mode_change->parameter = g_strdup(parameter);

	return mode_change;
}
