command/database: support relative offsets for "searchadd"
Closes https://github.com/MusicPlayerDaemon/MPD/issues/1337
This commit is contained in:
parent
fd5b195879
commit
4682ae0898
1
NEWS
1
NEWS
|
@ -1,5 +1,6 @@
|
||||||
ver 0.23.5 (not yet released)
|
ver 0.23.5 (not yet released)
|
||||||
* protocol
|
* protocol
|
||||||
|
- support relative offsets for "searchadd"
|
||||||
- fix "searchaddpl" bug (bogus error "Bad position")
|
- fix "searchaddpl" bug (bogus error "Bad position")
|
||||||
* migrate to PCRE2
|
* migrate to PCRE2
|
||||||
* GCC 12 build fixes
|
* GCC 12 build fixes
|
||||||
|
|
|
@ -1222,6 +1222,8 @@ The music database
|
||||||
|
|
||||||
The ``position`` parameter specifies where the songs will be
|
The ``position`` parameter specifies where the songs will be
|
||||||
inserted. [#since_0_23]_
|
inserted. [#since_0_23]_
|
||||||
|
It can be relative to the current song as in :ref:`addid
|
||||||
|
<command_addid>`. [#since_0_23_5]_
|
||||||
|
|
||||||
.. _command_searchaddpl:
|
.. _command_searchaddpl:
|
||||||
|
|
||||||
|
@ -1659,3 +1661,4 @@ client-to-client messages are local to the current partition.
|
||||||
.. [#since_0_23_1] Since :program:`MPD` 0.23.1
|
.. [#since_0_23_1] Since :program:`MPD` 0.23.1
|
||||||
.. [#since_0_23_3] Since :program:`MPD` 0.23.3
|
.. [#since_0_23_3] Since :program:`MPD` 0.23.3
|
||||||
.. [#since_0_23_4] Since :program:`MPD` 0.23.4
|
.. [#since_0_23_4] Since :program:`MPD` 0.23.4
|
||||||
|
.. [#since_0_23_5] Since :program:`MPD` 0.23.5
|
||||||
|
|
|
@ -44,7 +44,7 @@ version_conf = configuration_data()
|
||||||
version_conf.set_quoted('PACKAGE', meson.project_name())
|
version_conf.set_quoted('PACKAGE', meson.project_name())
|
||||||
version_conf.set_quoted('PACKAGE_NAME', meson.project_name())
|
version_conf.set_quoted('PACKAGE_NAME', meson.project_name())
|
||||||
version_conf.set_quoted('VERSION', meson.project_version())
|
version_conf.set_quoted('VERSION', meson.project_version())
|
||||||
version_conf.set_quoted('PROTOCOL_VERSION', '0.23.4')
|
version_conf.set_quoted('PROTOCOL_VERSION', '0.23.5')
|
||||||
configure_file(output: 'Version.h', configuration: version_conf)
|
configure_file(output: 'Version.h', configuration: version_conf)
|
||||||
|
|
||||||
conf = configuration_data()
|
conf = configuration_data()
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "DatabaseCommands.hxx"
|
#include "DatabaseCommands.hxx"
|
||||||
|
#include "PositionArg.hxx"
|
||||||
#include "Request.hxx"
|
#include "Request.hxx"
|
||||||
#include "Partition.hxx"
|
#include "Partition.hxx"
|
||||||
#include "db/DatabaseQueue.hxx"
|
#include "db/DatabaseQueue.hxx"
|
||||||
|
@ -86,6 +87,20 @@ ParseQueuePosition(Request &args, unsigned queue_length)
|
||||||
return queue_length;
|
return queue_length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static unsigned
|
||||||
|
ParseInsertPosition(Request &args, const playlist &playlist)
|
||||||
|
{
|
||||||
|
if (args.size >= 2 && StringIsEqual(args[args.size - 2], "position")) {
|
||||||
|
unsigned position = ParseInsertPosition(args.back(), playlist);
|
||||||
|
args.pop_back();
|
||||||
|
args.pop_back();
|
||||||
|
return position;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* append to the end of the queue by default */
|
||||||
|
return playlist.queue.GetLength();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert all remaining arguments to a #DatabaseSelection.
|
* Convert all remaining arguments to a #DatabaseSelection.
|
||||||
*
|
*
|
||||||
|
@ -160,7 +175,8 @@ handle_match_add(Client &client, Request args, bool fold_case)
|
||||||
{
|
{
|
||||||
auto &partition = client.GetPartition();
|
auto &partition = client.GetPartition();
|
||||||
const auto queue_length = partition.playlist.queue.GetLength();
|
const auto queue_length = partition.playlist.queue.GetLength();
|
||||||
const unsigned position = ParseQueuePosition(args, queue_length);
|
const unsigned position =
|
||||||
|
ParseInsertPosition(args, partition.playlist);
|
||||||
|
|
||||||
SongFilter filter;
|
SongFilter filter;
|
||||||
const auto selection = ParseDatabaseSelection(args, fold_case, filter);
|
const auto selection = ParseDatabaseSelection(args, fold_case, filter);
|
||||||
|
|
Loading…
Reference in New Issue