view lib/irccd/command/server-mode.cpp @ 72:98ac3c79009f

Irccd: start making a library, #429
author David Demelier <markand@malikania.fr>
date Thu, 24 Mar 2016 14:07:30 +0100
parents
children 8ee1178f1219
line wrap: on
line source

/*
 * command-server-mode.cpp -- implementation of server-mode transport command
 *
 * Copyright (c) 2013-2016 David Demelier <markand@malikania.fr>
 *
 * Permission to use, copy, modify, and/or distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */

#include <irccd/irccd.h>

#include "server-mode.h"

namespace irccd {

namespace command {

ServerMode::ServerMode()
	: RemoteCommand("server-mode", "Server")
{
}

std::string ServerMode::help() const
{
	return "";
}

RemoteCommandArgs ServerMode::args() const
{
	return RemoteCommandArgs{
		{ "server", true },
		{ "mode", true }
	};
}

json::Value ServerMode::request(Irccdctl &, const RemoteCommandRequest &args) const
{
	return json::object({
		{ "server", args.arg(0) },
		{ "mode", args.arg(1) }
	});
}

json::Value ServerMode::exec(Irccd &irccd, const json::Value &request) const
{
	irccd.requireServer(request.at("server").toString())->mode(request.at("mode").toString());

	return nullptr;
}

} // !command

} // !irccd