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
6a147a17
Commit
6a147a17
authored
Oct 30, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
db/proxy: pass search/find to remote MPD
parent
2b7529e9
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
54 additions
and
1 deletion
+54
-1
SongFilter.hxx
src/SongFilter.hxx
+16
-0
ProxyDatabasePlugin.cxx
src/db/ProxyDatabasePlugin.cxx
+38
-1
No files found.
src/SongFilter.hxx
View file @
6a147a17
...
...
@@ -61,6 +61,10 @@ public:
return
tag
;
}
bool
GetFoldCase
()
const
{
return
fold_case
;
}
const
std
::
string
&
GetValue
()
const
{
return
value
;
}
...
...
@@ -106,6 +110,18 @@ public:
}
/**
* Is there at least one item with "fold case" enabled?
*/
gcc_pure
bool
HasFoldCase
()
const
{
for
(
const
auto
&
i
:
items
)
if
(
i
.
GetFoldCase
())
return
true
;
return
false
;
}
/**
* Returns the "base" specification (if there is one) or an
* empty string.
*/
...
...
src/db/ProxyDatabasePlugin.cxx
View file @
6a147a17
...
...
@@ -472,6 +472,38 @@ Visit(struct mpd_connection *connection, const char *uri,
return
CheckError
(
connection
,
error
);
}
static
bool
SearchSongs
(
struct
mpd_connection
*
connection
,
const
DatabaseSelection
&
selection
,
VisitSong
visit_song
,
Error
&
error
)
{
assert
(
selection
.
recursive
);
assert
(
visit_song
);
const
bool
exact
=
selection
.
filter
==
nullptr
||
!
selection
.
filter
->
HasFoldCase
();
if
(
!
mpd_search_db_songs
(
connection
,
exact
)
||
!
SendConstraints
(
connection
,
selection
)
||
!
mpd_search_commit
(
connection
))
return
CheckError
(
connection
,
error
);
bool
result
=
true
;
struct
mpd_song
*
song
;
while
(
result
&&
(
song
=
mpd_recv_song
(
connection
))
!=
nullptr
)
{
Song
*
song2
=
Convert
(
song
);
mpd_song_free
(
song
);
result
=
!
Match
(
selection
.
filter
,
*
song2
)
||
visit_song
(
*
song2
,
error
);
song2
->
Free
();
}
mpd_response_finish
(
connection
);
return
result
&&
CheckError
(
connection
,
error
);
}
bool
ProxyDatabase
::
Visit
(
const
DatabaseSelection
&
selection
,
VisitDirectory
visit_directory
,
...
...
@@ -479,9 +511,14 @@ ProxyDatabase::Visit(const DatabaseSelection &selection,
VisitPlaylist
visit_playlist
,
Error
&
error
)
const
{
// TODO: match
// TODO: auto-reconnect
if
(
!
visit_directory
&&
!
visit_playlist
&&
selection
.
recursive
)
/* this optimized code path can only be used under
certain conditions */
return
::
SearchSongs
(
connection
,
selection
,
visit_song
,
error
);
/* fall back to recursive walk (slow!) */
return
::
Visit
(
connection
,
selection
.
uri
.
c_str
(),
selection
.
recursive
,
selection
.
filter
,
visit_directory
,
visit_song
,
visit_playlist
,
...
...
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