command/Partition: add command "partition" to switch to another partition
This commit is contained in:
parent
e48ea5f23a
commit
e9e853b19a
@ -2368,6 +2368,20 @@ OK
|
|||||||
</para>
|
</para>
|
||||||
|
|
||||||
<variablelist>
|
<variablelist>
|
||||||
|
<varlistentry id="command_partition">
|
||||||
|
<term>
|
||||||
|
<cmdsynopsis>
|
||||||
|
<command>partition</command>
|
||||||
|
<arg choice="req"><replaceable>NAME</replaceable></arg>
|
||||||
|
</cmdsynopsis>
|
||||||
|
</term>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
Switch the client to a different partition.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
<varlistentry id="command_listpartitions">
|
<varlistentry id="command_listpartitions">
|
||||||
<term>
|
<term>
|
||||||
<cmdsynopsis>
|
<cmdsynopsis>
|
||||||
|
@ -137,6 +137,7 @@ static constexpr struct command commands[] = {
|
|||||||
{ "next", PERMISSION_CONTROL, 0, 0, handle_next },
|
{ "next", PERMISSION_CONTROL, 0, 0, handle_next },
|
||||||
{ "notcommands", PERMISSION_NONE, 0, 0, handle_not_commands },
|
{ "notcommands", PERMISSION_NONE, 0, 0, handle_not_commands },
|
||||||
{ "outputs", PERMISSION_READ, 0, 0, handle_devices },
|
{ "outputs", PERMISSION_READ, 0, 0, handle_devices },
|
||||||
|
{ "partition", PERMISSION_READ, 1, 1, handle_partition },
|
||||||
{ "password", PERMISSION_NONE, 1, 1, handle_password },
|
{ "password", PERMISSION_NONE, 1, 1, handle_password },
|
||||||
{ "pause", PERMISSION_CONTROL, 0, 1, handle_pause },
|
{ "pause", PERMISSION_CONTROL, 0, 1, handle_pause },
|
||||||
{ "ping", PERMISSION_NONE, 0, 0, handle_ping },
|
{ "ping", PERMISSION_NONE, 0, 0, handle_ping },
|
||||||
|
@ -28,6 +28,21 @@
|
|||||||
#include "player/Thread.hxx"
|
#include "player/Thread.hxx"
|
||||||
#include "util/CharUtil.hxx"
|
#include "util/CharUtil.hxx"
|
||||||
|
|
||||||
|
CommandResult
|
||||||
|
handle_partition(Client &client, Request request, Response &response)
|
||||||
|
{
|
||||||
|
const char *name = request.front();
|
||||||
|
auto &instance = client.GetInstance();
|
||||||
|
auto *partition = instance.FindPartition(name);
|
||||||
|
if (partition == nullptr) {
|
||||||
|
response.Error(ACK_ERROR_NO_EXIST, "partition does not exist");
|
||||||
|
return CommandResult::ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
client.SetPartition(*partition);
|
||||||
|
return CommandResult::OK;
|
||||||
|
}
|
||||||
|
|
||||||
CommandResult
|
CommandResult
|
||||||
handle_listpartitions(Client &client, Request, Response &r)
|
handle_listpartitions(Client &client, Request, Response &r)
|
||||||
{
|
{
|
||||||
|
@ -26,6 +26,9 @@ class Client;
|
|||||||
class Request;
|
class Request;
|
||||||
class Response;
|
class Response;
|
||||||
|
|
||||||
|
CommandResult
|
||||||
|
handle_partition(Client &client, Request request, Response &response);
|
||||||
|
|
||||||
CommandResult
|
CommandResult
|
||||||
handle_listpartitions(Client &client, Request request, Response &response);
|
handle_listpartitions(Client &client, Request request, Response &response);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user