Commit 72621531 authored by Max Kellermann's avatar Max Kellermann

protocol/Result: convert to Client method

parent 0a48146e
......@@ -265,7 +265,6 @@ sources = [
version_cxx,
'src/Main.cxx',
'src/protocol/ArgParser.cxx',
'src/protocol/Result.cxx',
'src/command/CommandError.cxx',
'src/command/PositionArg.cxx',
'src/command/AllCommands.cxx',
......
......@@ -154,6 +154,10 @@ public:
return Write(s.data(), s.size());
}
bool WriteOK() noexcept {
return Write("OK\n");
}
/**
* returns the uid of the client process, or a negative value
* if the uid is unknown
......
......@@ -20,7 +20,6 @@
#include "Client.hxx"
#include "Config.hxx"
#include "Domain.hxx"
#include "protocol/Result.hxx"
#include "command/AllCommands.hxx"
#include "Log.hxx"
#include "util/StringAPI.hxx"
......@@ -72,7 +71,7 @@ Client::ProcessLine(char *line) noexcept
if (idle_waiting) {
/* send empty idle response and leave idle mode */
idle_waiting = false;
command_success(*this);
WriteOK();
}
/* do nothing if the client wasn't idling: the client
......@@ -108,7 +107,7 @@ Client::ProcessLine(char *line) noexcept
"list returned {}", id, unsigned(ret));
if (ret == CommandResult::OK)
command_success(*this);
WriteOK();
return ret;
} else {
......@@ -144,7 +143,7 @@ Client::ProcessLine(char *line) noexcept
return CommandResult::CLOSE;
if (ret == CommandResult::OK)
command_success(*this);
WriteOK();
return ret;
}
......
......@@ -21,7 +21,6 @@
#include "Client.hxx"
#include "Response.hxx"
#include "command/CommandError.hxx"
#include "protocol/Result.hxx"
ThreadBackgroundCommand::ThreadBackgroundCommand(Client &_client) noexcept
:thread(BIND_THIS_METHOD(_Run)),
......@@ -57,7 +56,7 @@ ThreadBackgroundCommand::DeferredFinish() noexcept
PrintError(response, error);
} else {
SendResponse(response);
command_success(client);
client.WriteOK();
}
/* delete this object */
......
/*
* Copyright 2003-2021 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 "Result.hxx"
#include "client/Client.hxx"
void
command_success(Client &client)
{
client.Write("OK\n");
}
/*
* Copyright 2003-2021 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_PROTOCOL_RESULT_HXX
#define MPD_PROTOCOL_RESULT_HXX
class Client;
void
command_success(Client &client);
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment