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
a8e70f09
Commit
a8e70f09
authored
Sep 02, 2018
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
db/proxy: forward `sort` and `window` to server
parent
c7c32a3c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
135 additions
and
3 deletions
+135
-3
NEWS
NEWS
+1
-0
ProxyDatabasePlugin.cxx
src/db/plugins/ProxyDatabasePlugin.cxx
+134
-3
No files found.
NEWS
View file @
a8e70f09
...
...
@@ -12,6 +12,7 @@ ver 0.21 (not yet released)
* database
- simple: scan audio formats
- proxy: require libmpdclient 2.9
- proxy: forward `sort` and `window` to server
* player
- "one-shot" single mode
* input
...
...
src/db/plugins/ProxyDatabasePlugin.cxx
View file @
a8e70f09
...
...
@@ -367,6 +367,38 @@ SendConstraints(mpd_connection *connection, const DatabaseSelection &selection)
!
SendConstraints
(
connection
,
*
selection
.
filter
))
return
false
;
#if LIBMPDCLIENT_CHECK_VERSION(2, 11, 0)
if
(
selection
.
sort
!=
TAG_NUM_OF_ITEM_TYPES
&&
mpd_connection_cmp_server_version
(
connection
,
0
,
21
,
0
)
>=
0
)
{
#if LIBMPDCLIENT_CHECK_VERSION(2, 15, 0)
if
(
selection
.
sort
==
SORT_TAG_LAST_MODIFIED
)
{
if
(
!
mpd_search_add_sort_name
(
connection
,
"Last-Modified"
,
selection
.
descending
))
return
false
;
}
else
{
#endif
const
auto
sort
=
Convert
(
selection
.
sort
);
/* if this is an unsupported tag, the sort
will be done later by class
DatabaseVisitorHelper */
if
(
sort
!=
MPD_TAG_COUNT
&&
!
mpd_search_add_sort_tag
(
connection
,
sort
,
selection
.
descending
))
return
false
;
#if LIBMPDCLIENT_CHECK_VERSION(2, 15, 0)
}
#endif
}
#endif
#if LIBMPDCLIENT_CHECK_VERSION(2, 10, 0)
if
(
selection
.
window
!=
RangeArg
::
All
()
&&
mpd_connection_cmp_server_version
(
connection
,
0
,
20
,
0
)
>=
0
&&
!
mpd_search_add_window
(
connection
,
selection
.
window
.
start
,
selection
.
window
.
end
))
return
false
;
#endif
return
true
;
}
...
...
@@ -805,12 +837,110 @@ try {
throw
;
}
gcc_const
#if LIBMPDCLIENT_CHECK_VERSION(2, 10, 0)
gcc_pure
static
bool
IsFilterSupported
(
const
ISongFilter
&
f
)
noexcept
{
if
(
auto
t
=
dynamic_cast
<
const
TagSongFilter
*>
(
&
f
))
{
if
(
t
->
IsNegated
())
// TODO implement
return
false
;
if
(
t
->
GetTagType
()
==
TAG_NUM_OF_ITEM_TYPES
)
return
true
;
const
auto
tag
=
Convert
(
t
->
GetTagType
());
if
(
tag
==
MPD_TAG_COUNT
)
return
false
;
return
true
;
}
else
if
(
auto
u
=
dynamic_cast
<
const
UriSongFilter
*>
(
&
f
))
{
if
(
u
->
IsNegated
())
// TODO implement
return
false
;
return
false
;
}
else
if
(
dynamic_cast
<
const
BaseSongFilter
*>
(
&
f
))
{
return
true
;
}
else
return
false
;
}
gcc_pure
static
bool
IsFilterFullySupported
(
const
SongFilter
&
filter
)
noexcept
{
for
(
const
auto
&
i
:
filter
.
GetItems
())
if
(
!
IsFilterSupported
(
*
i
))
return
false
;
return
true
;
}
gcc_pure
static
bool
IsFilterFullySupported
(
const
SongFilter
*
filter
)
noexcept
{
return
filter
==
nullptr
||
IsFilterFullySupported
(
*
filter
);
}
#endif
#if LIBMPDCLIENT_CHECK_VERSION(2, 11, 0)
gcc_pure
static
bool
IsSortSupported
(
TagType
tag_type
,
const
struct
mpd_connection
*
connection
)
noexcept
{
if
(
mpd_connection_cmp_server_version
(
connection
,
0
,
21
,
0
)
<
0
)
/* sorting requires MPD 0.21 */
return
false
;
if
(
tag_type
==
TagType
(
SORT_TAG_LAST_MODIFIED
))
{
/* sort "Last-Modified" requires libmpdclient 2.15 for
mpd_search_add_sort_name() */
#if LIBMPDCLIENT_CHECK_VERSION(2, 15, 0)
return
true
;
#else
return
false
;
#endif
}
return
Convert
(
tag_type
)
!=
MPD_TAG_COUNT
;
}
#endif
gcc_pure
static
DatabaseSelection
CheckSelection
(
DatabaseSelection
selection
)
noexcept
CheckSelection
(
DatabaseSelection
selection
,
struct
mpd_connection
*
connection
)
noexcept
{
selection
.
uri
.
clear
();
selection
.
filter
=
nullptr
;
#if LIBMPDCLIENT_CHECK_VERSION(2, 11, 0)
if
(
selection
.
sort
!=
TAG_NUM_OF_ITEM_TYPES
&&
IsSortSupported
(
selection
.
sort
,
connection
))
/* we can forward the "sort" parameter to the other
MPD */
selection
.
sort
=
TAG_NUM_OF_ITEM_TYPES
;
#endif
#if LIBMPDCLIENT_CHECK_VERSION(2, 10, 0)
if
(
selection
.
window
!=
RangeArg
::
All
()
&&
IsFilterFullySupported
(
selection
.
filter
))
/* we can forward the "window" parameter to the other
MPD */
selection
.
window
=
RangeArg
::
All
();
#else
(
void
)
connection
;
#endif
return
selection
;
}
...
...
@@ -823,7 +953,8 @@ ProxyDatabase::Visit(const DatabaseSelection &selection,
// TODO: eliminate the const_cast
const_cast
<
ProxyDatabase
*>
(
this
)
->
EnsureConnected
();
DatabaseVisitorHelper
helper
(
CheckSelection
(
selection
),
visit_song
);
DatabaseVisitorHelper
helper
(
CheckSelection
(
selection
,
connection
),
visit_song
);
if
(
!
visit_directory
&&
!
visit_playlist
&&
selection
.
recursive
&&
!
selection
.
IsEmpty
())
{
...
...
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