command/Other: move some functions to ClientCommands.cxx
handle_tagtypes() is also being moved to ClientCommands.cxx, because that command will be extended to access client-specific settings.
This commit is contained in:
parent
2f3f075e4f
commit
09d87d5ef1
@ -90,6 +90,7 @@ libmpd_a_SOURCES = \
|
||||
src/command/FileCommands.cxx src/command/FileCommands.hxx \
|
||||
src/command/OutputCommands.cxx src/command/OutputCommands.hxx \
|
||||
src/command/MessageCommands.cxx src/command/MessageCommands.hxx \
|
||||
src/command/ClientCommands.cxx src/command/ClientCommands.hxx \
|
||||
src/command/OtherCommands.cxx src/command/OtherCommands.hxx \
|
||||
src/command/CommandListBuilder.cxx src/command/CommandListBuilder.hxx \
|
||||
src/Idle.cxx src/Idle.hxx \
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include "OutputCommands.hxx"
|
||||
#include "MessageCommands.hxx"
|
||||
#include "NeighborCommands.hxx"
|
||||
#include "ClientCommands.hxx"
|
||||
#include "OtherCommands.hxx"
|
||||
#include "Permission.hxx"
|
||||
#include "tag/Type.h"
|
||||
|
62
src/command/ClientCommands.cxx
Normal file
62
src/command/ClientCommands.cxx
Normal file
@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Copyright 2003-2017 The Music Player Daemon Project
|
||||
* http://www.musicpd.org
|
||||
*
|
||||
* This program 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 program 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 program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "ClientCommands.hxx"
|
||||
#include "Request.hxx"
|
||||
#include "Permission.hxx"
|
||||
#include "client/Client.hxx"
|
||||
#include "client/Response.hxx"
|
||||
#include "TagPrint.hxx"
|
||||
|
||||
CommandResult
|
||||
handle_close(gcc_unused Client &client, gcc_unused Request args,
|
||||
gcc_unused Response &r)
|
||||
{
|
||||
return CommandResult::FINISH;
|
||||
}
|
||||
|
||||
CommandResult
|
||||
handle_ping(gcc_unused Client &client, gcc_unused Request args,
|
||||
gcc_unused Response &r)
|
||||
{
|
||||
return CommandResult::OK;
|
||||
}
|
||||
|
||||
CommandResult
|
||||
handle_password(Client &client, Request args, Response &r)
|
||||
{
|
||||
unsigned permission = 0;
|
||||
if (getPermissionFromPassword(args.front(), &permission) < 0) {
|
||||
r.Error(ACK_ERROR_PASSWORD, "incorrect password");
|
||||
return CommandResult::ERROR;
|
||||
}
|
||||
|
||||
client.SetPermission(permission);
|
||||
|
||||
return CommandResult::OK;
|
||||
}
|
||||
|
||||
CommandResult
|
||||
handle_tagtypes(gcc_unused Client &client, gcc_unused Request request,
|
||||
Response &r)
|
||||
{
|
||||
tag_print_types(r);
|
||||
return CommandResult::OK;
|
||||
}
|
41
src/command/ClientCommands.hxx
Normal file
41
src/command/ClientCommands.hxx
Normal file
@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright 2003-2017 The Music Player Daemon Project
|
||||
* http://www.musicpd.org
|
||||
*
|
||||
* This program 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 program 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 program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#ifndef MPD_CLIENT_COMMANDS_HXX
|
||||
#define MPD_CLIENT_COMMANDS_HXX
|
||||
|
||||
#include "CommandResult.hxx"
|
||||
|
||||
class Client;
|
||||
class Request;
|
||||
class Response;
|
||||
|
||||
CommandResult
|
||||
handle_close(Client &client, Request request, Response &response);
|
||||
|
||||
CommandResult
|
||||
handle_ping(Client &client, Request request, Response &response);
|
||||
|
||||
CommandResult
|
||||
handle_password(Client &client, Request request, Response &response);
|
||||
|
||||
CommandResult
|
||||
handle_tagtypes(Client &client, Request request, Response &response);
|
||||
|
||||
#endif
|
@ -39,7 +39,6 @@
|
||||
#include "util/StringAPI.hxx"
|
||||
#include "fs/AllocatedPath.hxx"
|
||||
#include "Stats.hxx"
|
||||
#include "Permission.hxx"
|
||||
#include "PlaylistFile.hxx"
|
||||
#include "db/PlaylistVector.hxx"
|
||||
#include "client/Client.hxx"
|
||||
@ -86,14 +85,6 @@ handle_decoders(gcc_unused Client &client, gcc_unused Request args,
|
||||
return CommandResult::OK;
|
||||
}
|
||||
|
||||
CommandResult
|
||||
handle_tagtypes(gcc_unused Client &client, gcc_unused Request request,
|
||||
Response &r)
|
||||
{
|
||||
tag_print_types(r);
|
||||
return CommandResult::OK;
|
||||
}
|
||||
|
||||
CommandResult
|
||||
handle_kill(gcc_unused Client &client, gcc_unused Request request,
|
||||
gcc_unused Response &r)
|
||||
@ -101,13 +92,6 @@ handle_kill(gcc_unused Client &client, gcc_unused Request request,
|
||||
return CommandResult::KILL;
|
||||
}
|
||||
|
||||
CommandResult
|
||||
handle_close(gcc_unused Client &client, gcc_unused Request args,
|
||||
gcc_unused Response &r)
|
||||
{
|
||||
return CommandResult::FINISH;
|
||||
}
|
||||
|
||||
static void
|
||||
print_tag(TagType type, const char *value, void *ctx)
|
||||
{
|
||||
@ -384,27 +368,6 @@ handle_stats(Client &client, gcc_unused Request args, Response &r)
|
||||
return CommandResult::OK;
|
||||
}
|
||||
|
||||
CommandResult
|
||||
handle_ping(gcc_unused Client &client, gcc_unused Request args,
|
||||
gcc_unused Response &r)
|
||||
{
|
||||
return CommandResult::OK;
|
||||
}
|
||||
|
||||
CommandResult
|
||||
handle_password(Client &client, Request args, Response &r)
|
||||
{
|
||||
unsigned permission = 0;
|
||||
if (getPermissionFromPassword(args.front(), &permission) < 0) {
|
||||
r.Error(ACK_ERROR_PASSWORD, "incorrect password");
|
||||
return CommandResult::ERROR;
|
||||
}
|
||||
|
||||
client.SetPermission(permission);
|
||||
|
||||
return CommandResult::OK;
|
||||
}
|
||||
|
||||
CommandResult
|
||||
handle_config(Client &client, gcc_unused Request args, Response &r)
|
||||
{
|
||||
|
@ -32,15 +32,9 @@ handle_urlhandlers(Client &client, Request request, Response &response);
|
||||
CommandResult
|
||||
handle_decoders(Client &client, Request request, Response &response);
|
||||
|
||||
CommandResult
|
||||
handle_tagtypes(Client &client, Request request, Response &response);
|
||||
|
||||
CommandResult
|
||||
handle_kill(Client &client, Request request, Response &response);
|
||||
|
||||
CommandResult
|
||||
handle_close(Client &client, Request request, Response &response);
|
||||
|
||||
CommandResult
|
||||
handle_listfiles(Client &client, Request request, Response &response);
|
||||
|
||||
@ -62,12 +56,6 @@ handle_volume(Client &client, Request request, Response &response);
|
||||
CommandResult
|
||||
handle_stats(Client &client, Request request, Response &response);
|
||||
|
||||
CommandResult
|
||||
handle_ping(Client &client, Request request, Response &response);
|
||||
|
||||
CommandResult
|
||||
handle_password(Client &client, Request request, Response &response);
|
||||
|
||||
CommandResult
|
||||
handle_config(Client &client, Request request, Response &response);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user