Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
f37481f8
Commit
f37481f8
authored
Nov 18, 2014
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DatabaseCommands: add "window" parameter to "search"/"find"
parent
c3f6502b
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
54 additions
and
4 deletions
+54
-4
NEWS
NEWS
+1
-0
protocol.xml
doc/protocol.xml
+9
-0
DatabaseCommands.cxx
src/command/DatabaseCommands.cxx
+13
-1
DatabasePrint.cxx
src/db/DatabasePrint.cxx
+25
-3
DatabasePrint.hxx
src/db/DatabasePrint.hxx
+6
-0
No files found.
NEWS
View file @
f37481f8
ver 0.20 (not yet released)
* protocol
- "commands" returns playlist commands only if playlist_directory configured
- "search"/"find" have a "window" parameter
* output
- pulse: set channel map to WAVE-EX
...
...
doc/protocol.xml
View file @
f37481f8
...
...
@@ -1558,6 +1558,7 @@ OK
<arg
choice=
"req"
><replaceable>
TYPE
</replaceable></arg>
<arg
choice=
"req"
><replaceable>
WHAT
</replaceable></arg>
<arg
choice=
"opt"
><replaceable>
...
</replaceable></arg>
<arg
choice=
"opt"
>
window
<replaceable>
START
</replaceable>
:
<replaceable>
END
</replaceable></arg>
</cmdsynopsis>
</term>
<listitem>
...
...
@@ -1602,6 +1603,13 @@ OK
<para>
<varname>
WHAT
</varname>
is what to find.
</para>
<para>
<varname>
window
</varname>
can be used to query only a
portion of the real response. The parameter is two
zero-based record numbers; a start number and an end
number.
</para>
</listitem>
</varlistentry>
<varlistentry
id=
"command_findadd"
>
...
...
@@ -1794,6 +1802,7 @@ OK
<arg
choice=
"req"
><replaceable>
TYPE
</replaceable></arg>
<arg
choice=
"req"
><replaceable>
WHAT
</replaceable></arg>
<arg
choice=
"opt"
><replaceable>
...
</replaceable></arg>
<arg
choice=
"opt"
>
window
<replaceable>
START
</replaceable>
:
<replaceable>
END
</replaceable></arg>
</cmdsynopsis>
</term>
<listitem>
...
...
src/command/DatabaseCommands.cxx
View file @
f37481f8
...
...
@@ -32,6 +32,7 @@
#include "util/Error.hxx"
#include "SongFilter.hxx"
#include "protocol/Result.hxx"
#include "protocol/ArgParser.hxx"
#include "BulkEdit.hxx"
#include <string.h>
...
...
@@ -70,6 +71,16 @@ handle_match(Client &client, unsigned argc, char *argv[], bool fold_case)
{
ConstBuffer
<
const
char
*>
args
(
argv
+
1
,
argc
-
1
);
unsigned
window_start
=
0
,
window_end
=
std
::
numeric_limits
<
int
>::
max
();
if
(
args
.
size
>=
2
&&
strcmp
(
args
[
args
.
size
-
2
],
"window"
)
==
0
)
{
if
(
!
check_range
(
client
,
&
window_start
,
&
window_end
,
args
.
back
()))
return
CommandResult
::
ERROR
;
args
.
pop_back
();
args
.
pop_back
();
}
SongFilter
filter
;
if
(
!
filter
.
Parse
(
args
,
fold_case
))
{
command_error
(
client
,
ACK_ERROR_ARG
,
"incorrect arguments"
);
...
...
@@ -79,7 +90,8 @@ handle_match(Client &client, unsigned argc, char *argv[], bool fold_case)
const
DatabaseSelection
selection
(
""
,
true
,
&
filter
);
Error
error
;
return
db_selection_print
(
client
,
selection
,
true
,
false
,
error
)
return
db_selection_print
(
client
,
selection
,
true
,
false
,
window_start
,
window_end
,
error
)
?
CommandResult
::
OK
:
print_error
(
client
,
error
);
}
...
...
src/db/DatabasePrint.cxx
View file @
f37481f8
...
...
@@ -147,27 +147,49 @@ PrintPlaylistFull(Client &client, bool base,
bool
db_selection_print
(
Client
&
client
,
const
DatabaseSelection
&
selection
,
bool
full
,
bool
base
,
Error
&
error
)
bool
full
,
bool
base
,
unsigned
window_start
,
unsigned
window_end
,
Error
&
error
)
{
const
Database
*
db
=
client
.
GetDatabase
(
error
);
if
(
db
==
nullptr
)
return
false
;
unsigned
i
=
0
;
using
namespace
std
::
placeholders
;
const
auto
d
=
selection
.
filter
==
nullptr
?
std
::
bind
(
full
?
PrintDirectoryFull
:
PrintDirectoryBrief
,
std
::
ref
(
client
),
base
,
_1
)
:
VisitDirectory
();
const
auto
s
=
std
::
bind
(
full
?
PrintSongFull
:
PrintSongBrief
,
std
::
ref
(
client
),
base
,
_1
);
VisitSong
s
=
std
::
bind
(
full
?
PrintSongFull
:
PrintSongBrief
,
std
::
ref
(
client
),
base
,
_1
);
const
auto
p
=
selection
.
filter
==
nullptr
?
std
::
bind
(
full
?
PrintPlaylistFull
:
PrintPlaylistBrief
,
std
::
ref
(
client
),
base
,
_1
,
_2
)
:
VisitPlaylist
();
if
(
window_start
>
0
||
window_end
<
std
::
numeric_limits
<
int
>::
max
())
s
=
[
s
,
window_start
,
window_end
,
&
i
](
const
LightSong
&
song
,
Error
&
error2
){
const
bool
in_window
=
i
>=
window_start
&&
i
<
window_end
;
++
i
;
return
!
in_window
||
s
(
song
,
error2
);
};
return
db
->
Visit
(
selection
,
d
,
s
,
p
,
error
);
}
bool
db_selection_print
(
Client
&
client
,
const
DatabaseSelection
&
selection
,
bool
full
,
bool
base
,
Error
&
error
)
{
return
db_selection_print
(
client
,
selection
,
full
,
base
,
0
,
std
::
numeric_limits
<
int
>::
max
(),
error
);
}
static
bool
PrintSongURIVisitor
(
Client
&
client
,
const
LightSong
&
song
)
{
...
...
src/db/DatabasePrint.hxx
View file @
f37481f8
...
...
@@ -38,6 +38,12 @@ db_selection_print(Client &client, const DatabaseSelection &selection,
bool
full
,
bool
base
,
Error
&
error
);
bool
db_selection_print
(
Client
&
client
,
const
DatabaseSelection
&
selection
,
bool
full
,
bool
base
,
unsigned
window_start
,
unsigned
window_end
,
Error
&
error
);
bool
PrintUniqueTags
(
Client
&
client
,
unsigned
type
,
uint32_t
group_mask
,
const
SongFilter
*
filter
,
Error
&
error
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment