diff --git a/Makefile.am b/Makefile.am index 24e1a3948..72628ce9a 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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 \ diff --git a/src/command/AllCommands.cxx b/src/command/AllCommands.cxx index e9546b915..7d65898dd 100644 --- a/src/command/AllCommands.cxx +++ b/src/command/AllCommands.cxx @@ -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" diff --git a/src/command/ClientCommands.cxx b/src/command/ClientCommands.cxx new file mode 100644 index 000000000..3aa89b0e6 --- /dev/null +++ b/src/command/ClientCommands.cxx @@ -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; +} diff --git a/src/command/ClientCommands.hxx b/src/command/ClientCommands.hxx new file mode 100644 index 000000000..7813e8ad3 --- /dev/null +++ b/src/command/ClientCommands.hxx @@ -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 diff --git a/src/command/OtherCommands.cxx b/src/command/OtherCommands.cxx index 81a7cf94f..48487fe8e 100644 --- a/src/command/OtherCommands.cxx +++ b/src/command/OtherCommands.cxx @@ -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) { diff --git a/src/command/OtherCommands.hxx b/src/command/OtherCommands.hxx index bb6dbfd9e..94e51d4d0 100644 --- a/src/command/OtherCommands.hxx +++ b/src/command/OtherCommands.hxx @@ -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);