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
1a75abff
Commit
1a75abff
authored
Aug 07, 2012
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Database{Plugin,Visitor}: pass references
parent
c6a0f5d3
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
95 additions
and
91 deletions
+95
-91
DatabasePlaylist.cxx
src/DatabasePlaylist.cxx
+13
-6
DatabasePlugin.hxx
src/DatabasePlugin.hxx
+3
-3
DatabasePrint.cxx
src/DatabasePrint.cxx
+43
-46
DatabaseQueue.cxx
src/DatabaseQueue.cxx
+9
-10
DatabaseVisitor.hxx
src/DatabaseVisitor.hxx
+4
-3
Directory.cxx
src/Directory.cxx
+3
-3
Stats.cxx
src/Stats.cxx
+4
-4
SimpleDatabasePlugin.cxx
src/db/SimpleDatabasePlugin.cxx
+7
-7
SimpleDatabasePlugin.hxx
src/db/SimpleDatabasePlugin.hxx
+1
-1
DumpDatabase.cxx
test/DumpDatabase.cxx
+8
-8
No files found.
src/DatabasePlaylist.cxx
View file @
1a75abff
...
@@ -31,6 +31,13 @@ extern "C" {
...
@@ -31,6 +31,13 @@ extern "C" {
#include <functional>
#include <functional>
static
bool
AddSong
(
const
char
*
playlist_path_utf8
,
song
&
song
,
GError
**
error_r
)
{
return
spl_append_song
(
playlist_path_utf8
,
&
song
,
error_r
);
}
bool
bool
addAllInToStoredPlaylist
(
const
char
*
uri_utf8
,
const
char
*
playlist_path_utf8
,
addAllInToStoredPlaylist
(
const
char
*
uri_utf8
,
const
char
*
playlist_path_utf8
,
GError
**
error_r
)
GError
**
error_r
)
...
@@ -39,17 +46,17 @@ addAllInToStoredPlaylist(const char *uri_utf8, const char *playlist_path_utf8,
...
@@ -39,17 +46,17 @@ addAllInToStoredPlaylist(const char *uri_utf8, const char *playlist_path_utf8,
db_selection_init
(
&
selection
,
uri_utf8
,
true
);
db_selection_init
(
&
selection
,
uri_utf8
,
true
);
using
namespace
std
::
placeholders
;
using
namespace
std
::
placeholders
;
const
auto
f
=
std
::
bind
(
spl_append_s
ong
,
playlist_path_utf8
,
_1
,
_2
);
const
auto
f
=
std
::
bind
(
AddS
ong
,
playlist_path_utf8
,
_1
,
_2
);
return
GetDatabase
()
->
Visit
(
&
selection
,
f
,
error_r
);
return
GetDatabase
()
->
Visit
(
selection
,
f
,
error_r
);
}
}
static
bool
static
bool
SearchAddSong
(
const
char
*
playlist_path_utf8
,
SearchAddSong
(
const
char
*
playlist_path_utf8
,
const
struct
locate_item_list
*
criteria
,
const
struct
locate_item_list
*
criteria
,
s
truct
song
*
song
,
GError
**
error_r
)
s
ong
&
song
,
GError
**
error_r
)
{
{
return
!
locate_song_search
(
song
,
criteria
)
||
return
!
locate_song_search
(
&
song
,
criteria
)
||
spl_append_song
(
playlist_path_utf8
,
song
,
error_r
);
spl_append_song
(
playlist_path_utf8
,
&
song
,
error_r
);
}
}
bool
bool
...
@@ -66,7 +73,7 @@ search_add_to_playlist(const char *uri, const char *playlist_path_utf8,
...
@@ -66,7 +73,7 @@ search_add_to_playlist(const char *uri, const char *playlist_path_utf8,
using
namespace
std
::
placeholders
;
using
namespace
std
::
placeholders
;
const
auto
f
=
std
::
bind
(
SearchAddSong
,
playlist_path_utf8
,
const
auto
f
=
std
::
bind
(
SearchAddSong
,
playlist_path_utf8
,
new_list
,
_1
,
_2
);
new_list
,
_1
,
_2
);
bool
success
=
GetDatabase
()
->
Visit
(
&
selection
,
f
,
error_r
);
bool
success
=
GetDatabase
()
->
Visit
(
selection
,
f
,
error_r
);
locate_item_list_free
(
new_list
);
locate_item_list_free
(
new_list
);
...
...
src/DatabasePlugin.hxx
View file @
1a75abff
...
@@ -64,13 +64,13 @@ public:
...
@@ -64,13 +64,13 @@ public:
/**
/**
* Visit the selected entities.
* Visit the selected entities.
*/
*/
virtual
bool
Visit
(
const
struct
db_selection
*
selection
,
virtual
bool
Visit
(
const
db_selection
&
selection
,
VisitDirectory
visit_directory
,
VisitDirectory
visit_directory
,
VisitSong
visit_song
,
VisitSong
visit_song
,
VisitPlaylist
visit_playlist
,
VisitPlaylist
visit_playlist
,
GError
**
error_r
)
const
=
0
;
GError
**
error_r
)
const
=
0
;
bool
Visit
(
const
struct
db_selection
*
selection
,
bool
Visit
(
const
db_selection
&
selection
,
VisitDirectory
visit_directory
,
VisitDirectory
visit_directory
,
VisitSong
visit_song
,
VisitSong
visit_song
,
GError
**
error_r
)
const
{
GError
**
error_r
)
const
{
...
@@ -78,7 +78,7 @@ public:
...
@@ -78,7 +78,7 @@ public:
VisitPlaylist
(),
error_r
);
VisitPlaylist
(),
error_r
);
}
}
bool
Visit
(
const
struct
db_selection
*
selection
,
VisitSong
visit_song
,
bool
Visit
(
const
db_selection
&
selection
,
VisitSong
visit_song
,
GError
**
error_r
)
const
{
GError
**
error_r
)
const
{
return
Visit
(
selection
,
VisitDirectory
(),
visit_song
,
error_r
);
return
Visit
(
selection
,
VisitDirectory
(),
visit_song
,
error_r
);
}
}
...
...
src/DatabasePrint.cxx
View file @
1a75abff
...
@@ -40,79 +40,76 @@ extern "C" {
...
@@ -40,79 +40,76 @@ extern "C" {
#include <set>
#include <set>
static
bool
static
bool
PrintDirectory
(
struct
client
*
client
,
const
struct
directory
*
directory
)
PrintDirectory
(
struct
client
*
client
,
const
directory
&
directory
)
{
{
if
(
!
directory_is_root
(
directory
))
if
(
!
directory_is_root
(
&
directory
))
client_printf
(
client
,
"directory: %s
\n
"
,
directory_get_path
(
directory
));
client_printf
(
client
,
"directory: %s
\n
"
,
directory_get_path
(
&
directory
));
return
true
;
return
true
;
}
}
static
void
static
void
print_playlist_in_directory
(
struct
client
*
client
,
print_playlist_in_directory
(
struct
client
*
client
,
const
struct
directory
*
directory
,
const
directory
&
directory
,
const
char
*
name_utf8
)
const
char
*
name_utf8
)
{
{
if
(
directory_is_root
(
directory
))
if
(
directory_is_root
(
&
directory
))
client_printf
(
client
,
"playlist: %s
\n
"
,
name_utf8
);
client_printf
(
client
,
"playlist: %s
\n
"
,
name_utf8
);
else
else
client_printf
(
client
,
"playlist: %s/%s
\n
"
,
client_printf
(
client
,
"playlist: %s/%s
\n
"
,
directory_get_path
(
directory
),
name_utf8
);
directory_get_path
(
&
directory
),
name_utf8
);
}
}
static
bool
static
bool
PrintSongBrief
(
struct
client
*
client
,
s
truct
song
*
song
)
PrintSongBrief
(
struct
client
*
client
,
s
ong
&
song
)
{
{
assert
(
song
!=
NULL
);
assert
(
song
.
parent
!=
NULL
);
assert
(
song
->
parent
!=
NULL
);
song_print_uri
(
client
,
song
);
song_print_uri
(
client
,
&
song
);
if
(
song
->
tag
!=
NULL
&&
song
->
tag
->
has_playlist
)
if
(
song
.
tag
!=
NULL
&&
song
.
tag
->
has_playlist
)
/* this song file has an embedded CUE sheet */
/* this song file has an embedded CUE sheet */
print_playlist_in_directory
(
client
,
song
->
parent
,
print_playlist_in_directory
(
client
,
*
song
.
parent
,
song
.
uri
);
song
->
uri
);
return
true
;
return
true
;
}
}
static
bool
static
bool
PrintSongFull
(
struct
client
*
client
,
s
truct
song
*
song
)
PrintSongFull
(
struct
client
*
client
,
s
ong
&
song
)
{
{
assert
(
song
!=
NULL
);
assert
(
song
.
parent
!=
NULL
);
assert
(
song
->
parent
!=
NULL
);
song_print_info
(
client
,
song
);
song_print_info
(
client
,
&
song
);
if
(
song
->
tag
!=
NULL
&&
song
->
tag
->
has_playlist
)
if
(
song
.
tag
!=
NULL
&&
song
.
tag
->
has_playlist
)
/* this song file has an embedded CUE sheet */
/* this song file has an embedded CUE sheet */
print_playlist_in_directory
(
client
,
song
->
parent
,
print_playlist_in_directory
(
client
,
*
song
.
parent
,
song
.
uri
);
song
->
uri
);
return
true
;
return
true
;
}
}
static
bool
static
bool
PrintPlaylistBrief
(
struct
client
*
client
,
PrintPlaylistBrief
(
struct
client
*
client
,
const
struct
playlist_metadata
*
playlist
,
const
playlist_metadata
&
playlist
,
const
struct
directory
*
directory
)
const
directory
&
directory
)
{
{
print_playlist_in_directory
(
client
,
directory
,
playlist
->
name
);
print_playlist_in_directory
(
client
,
directory
,
playlist
.
name
);
return
true
;
return
true
;
}
}
static
bool
static
bool
PrintPlaylistFull
(
struct
client
*
client
,
PrintPlaylistFull
(
struct
client
*
client
,
const
struct
playlist_metadata
*
playlist
,
const
playlist_metadata
&
playlist
,
const
struct
directory
*
directory
)
const
directory
&
directory
)
{
{
print_playlist_in_directory
(
client
,
directory
,
playlist
->
name
);
print_playlist_in_directory
(
client
,
directory
,
playlist
.
name
);
#ifndef G_OS_WIN32
#ifndef G_OS_WIN32
struct
tm
tm
;
struct
tm
tm
;
#endif
#endif
char
timestamp
[
32
];
char
timestamp
[
32
];
time_t
t
=
playlist
->
mtime
;
time_t
t
=
playlist
.
mtime
;
strftime
(
timestamp
,
sizeof
(
timestamp
),
strftime
(
timestamp
,
sizeof
(
timestamp
),
#ifdef G_OS_WIN32
#ifdef G_OS_WIN32
"%Y-%m-%dT%H:%M:%SZ"
,
"%Y-%m-%dT%H:%M:%SZ"
,
...
@@ -138,15 +135,15 @@ db_selection_print(struct client *client, const struct db_selection *selection,
...
@@ -138,15 +135,15 @@ db_selection_print(struct client *client, const struct db_selection *selection,
const
auto
p
=
std
::
bind
(
full
?
PrintPlaylistFull
:
PrintPlaylistBrief
,
const
auto
p
=
std
::
bind
(
full
?
PrintPlaylistFull
:
PrintPlaylistBrief
,
client
,
_1
,
_2
);
client
,
_1
,
_2
);
return
GetDatabase
()
->
Visit
(
selection
,
d
,
s
,
p
,
error_r
);
return
GetDatabase
()
->
Visit
(
*
selection
,
d
,
s
,
p
,
error_r
);
}
}
static
bool
static
bool
SearchPrintSong
(
struct
client
*
client
,
const
struct
locate_item_list
*
criteria
,
SearchPrintSong
(
struct
client
*
client
,
const
struct
locate_item_list
*
criteria
,
s
truct
song
*
song
)
s
ong
&
song
)
{
{
if
(
locate_song_search
(
song
,
criteria
))
if
(
locate_song_search
(
&
song
,
criteria
))
song_print_info
(
client
,
song
);
song_print_info
(
client
,
&
song
);
return
true
;
return
true
;
}
}
...
@@ -164,7 +161,7 @@ searchForSongsIn(struct client *client, const char *uri,
...
@@ -164,7 +161,7 @@ searchForSongsIn(struct client *client, const char *uri,
using
namespace
std
::
placeholders
;
using
namespace
std
::
placeholders
;
const
auto
f
=
std
::
bind
(
SearchPrintSong
,
client
,
new_list
,
_1
);
const
auto
f
=
std
::
bind
(
SearchPrintSong
,
client
,
new_list
,
_1
);
bool
success
=
GetDatabase
()
->
Visit
(
&
selection
,
f
,
error_r
);
bool
success
=
GetDatabase
()
->
Visit
(
selection
,
f
,
error_r
);
locate_item_list_free
(
new_list
);
locate_item_list_free
(
new_list
);
...
@@ -173,10 +170,10 @@ searchForSongsIn(struct client *client, const char *uri,
...
@@ -173,10 +170,10 @@ searchForSongsIn(struct client *client, const char *uri,
static
bool
static
bool
MatchPrintSong
(
struct
client
*
client
,
const
struct
locate_item_list
*
criteria
,
MatchPrintSong
(
struct
client
*
client
,
const
struct
locate_item_list
*
criteria
,
s
truct
song
*
song
)
s
ong
&
song
)
{
{
if
(
locate_song_match
(
song
,
criteria
))
if
(
locate_song_match
(
&
song
,
criteria
))
song_print_info
(
client
,
song
);
song_print_info
(
client
,
&
song
);
return
true
;
return
true
;
}
}
...
@@ -191,7 +188,7 @@ findSongsIn(struct client *client, const char *uri,
...
@@ -191,7 +188,7 @@ findSongsIn(struct client *client, const char *uri,
using
namespace
std
::
placeholders
;
using
namespace
std
::
placeholders
;
const
auto
f
=
std
::
bind
(
MatchPrintSong
,
client
,
criteria
,
_1
);
const
auto
f
=
std
::
bind
(
MatchPrintSong
,
client
,
criteria
,
_1
);
return
GetDatabase
()
->
Visit
(
&
selection
,
f
,
error_r
);
return
GetDatabase
()
->
Visit
(
selection
,
f
,
error_r
);
}
}
struct
SearchStats
{
struct
SearchStats
{
...
@@ -207,11 +204,11 @@ static void printSearchStats(struct client *client, SearchStats *stats)
...
@@ -207,11 +204,11 @@ static void printSearchStats(struct client *client, SearchStats *stats)
static
bool
static
bool
stats_visitor_song
(
SearchStats
&
stats
,
const
struct
locate_item_list
*
criteria
,
stats_visitor_song
(
SearchStats
&
stats
,
const
struct
locate_item_list
*
criteria
,
s
truct
song
*
song
)
s
ong
&
song
)
{
{
if
(
locate_song_match
(
song
,
criteria
))
{
if
(
locate_song_match
(
&
song
,
criteria
))
{
stats
.
numberOfSongs
++
;
stats
.
numberOfSongs
++
;
stats
.
playTime
+=
song_get_duration
(
song
);
stats
.
playTime
+=
song_get_duration
(
&
song
);
}
}
return
true
;
return
true
;
...
@@ -232,7 +229,7 @@ searchStatsForSongsIn(struct client *client, const char *name,
...
@@ -232,7 +229,7 @@ searchStatsForSongsIn(struct client *client, const char *name,
using
namespace
std
::
placeholders
;
using
namespace
std
::
placeholders
;
const
auto
f
=
std
::
bind
(
stats_visitor_song
,
std
::
ref
(
stats
),
criteria
,
const
auto
f
=
std
::
bind
(
stats_visitor_song
,
std
::
ref
(
stats
),
criteria
,
_1
);
_1
);
if
(
!
GetDatabase
()
->
Visit
(
&
selection
,
f
,
error_r
))
if
(
!
GetDatabase
()
->
Visit
(
selection
,
f
,
error_r
))
return
false
;
return
false
;
printSearchStats
(
client
,
&
stats
);
printSearchStats
(
client
,
&
stats
);
...
@@ -267,13 +264,13 @@ typedef std::set<const char *, StringLess> StringSet;
...
@@ -267,13 +264,13 @@ typedef std::set<const char *, StringLess> StringSet;
static
void
static
void
visitTag
(
struct
client
*
client
,
StringSet
&
set
,
visitTag
(
struct
client
*
client
,
StringSet
&
set
,
s
truct
song
*
song
,
enum
tag_type
tagType
)
s
ong
&
song
,
enum
tag_type
tagType
)
{
{
struct
tag
*
tag
=
song
->
tag
;
struct
tag
*
tag
=
song
.
tag
;
bool
found
=
false
;
bool
found
=
false
;
if
(
tagType
==
LOCATE_TAG_FILE_TYPE
)
{
if
(
tagType
==
LOCATE_TAG_FILE_TYPE
)
{
song_print_uri
(
client
,
song
);
song_print_uri
(
client
,
&
song
);
return
;
return
;
}
}
...
@@ -295,9 +292,9 @@ static bool
...
@@ -295,9 +292,9 @@ static bool
unique_tags_visitor_song
(
struct
client
*
client
,
unique_tags_visitor_song
(
struct
client
*
client
,
enum
tag_type
tag_type
,
enum
tag_type
tag_type
,
const
struct
locate_item_list
*
criteria
,
const
struct
locate_item_list
*
criteria
,
StringSet
&
set
,
s
truct
song
*
song
)
StringSet
&
set
,
s
ong
&
song
)
{
{
if
(
locate_song_match
(
song
,
criteria
))
if
(
locate_song_match
(
&
song
,
criteria
))
visitTag
(
client
,
set
,
song
,
tag_type
);
visitTag
(
client
,
set
,
song
,
tag_type
);
return
true
;
return
true
;
...
@@ -317,7 +314,7 @@ listAllUniqueTags(struct client *client, int type,
...
@@ -317,7 +314,7 @@ listAllUniqueTags(struct client *client, int type,
const
auto
f
=
std
::
bind
(
unique_tags_visitor_song
,
client
,
const
auto
f
=
std
::
bind
(
unique_tags_visitor_song
,
client
,
(
enum
tag_type
)
type
,
criteria
,
std
::
ref
(
set
),
(
enum
tag_type
)
type
,
criteria
,
std
::
ref
(
set
),
_1
);
_1
);
if
(
!
GetDatabase
()
->
Visit
(
&
selection
,
f
,
error_r
))
if
(
!
GetDatabase
()
->
Visit
(
selection
,
f
,
error_r
))
return
false
;
return
false
;
if
(
type
>=
0
&&
type
<=
TAG_NUM_OF_ITEM_TYPES
)
if
(
type
>=
0
&&
type
<=
TAG_NUM_OF_ITEM_TYPES
)
...
...
src/DatabaseQueue.cxx
View file @
1a75abff
...
@@ -32,11 +32,10 @@ extern "C" {
...
@@ -32,11 +32,10 @@ extern "C" {
#include <functional>
#include <functional>
static
bool
static
bool
AddToQueue
(
struct
player_control
*
pc
,
struct
song
*
song
,
AddToQueue
(
struct
player_control
*
pc
,
song
&
song
,
GError
**
error_r
)
GError
**
error_r
)
{
{
enum
playlist_result
result
=
enum
playlist_result
result
=
playlist_append_song
(
&
g_playlist
,
pc
,
song
,
NULL
);
playlist_append_song
(
&
g_playlist
,
pc
,
&
song
,
NULL
);
if
(
result
!=
PLAYLIST_RESULT_SUCCESS
)
{
if
(
result
!=
PLAYLIST_RESULT_SUCCESS
)
{
g_set_error
(
error_r
,
playlist_quark
(),
result
,
g_set_error
(
error_r
,
playlist_quark
(),
result
,
"Playlist error"
);
"Playlist error"
);
...
@@ -54,15 +53,15 @@ addAllIn(struct player_control *pc, const char *uri, GError **error_r)
...
@@ -54,15 +53,15 @@ addAllIn(struct player_control *pc, const char *uri, GError **error_r)
using
namespace
std
::
placeholders
;
using
namespace
std
::
placeholders
;
const
auto
f
=
std
::
bind
(
AddToQueue
,
pc
,
_1
,
_2
);
const
auto
f
=
std
::
bind
(
AddToQueue
,
pc
,
_1
,
_2
);
return
GetDatabase
()
->
Visit
(
&
selection
,
f
,
error_r
);
return
GetDatabase
()
->
Visit
(
selection
,
f
,
error_r
);
}
}
static
bool
static
bool
MatchAddSong
(
struct
player_control
*
pc
,
MatchAddSong
(
struct
player_control
*
pc
,
const
struct
locate_item_list
*
criteria
,
const
struct
locate_item_list
*
criteria
,
s
truct
song
*
song
,
GError
**
error_r
)
s
ong
&
song
,
GError
**
error_r
)
{
{
return
!
locate_song_match
(
song
,
criteria
)
||
return
!
locate_song_match
(
&
song
,
criteria
)
||
AddToQueue
(
pc
,
song
,
error_r
);
AddToQueue
(
pc
,
song
,
error_r
);
}
}
...
@@ -75,15 +74,15 @@ findAddIn(struct player_control *pc, const char *uri,
...
@@ -75,15 +74,15 @@ findAddIn(struct player_control *pc, const char *uri,
using
namespace
std
::
placeholders
;
using
namespace
std
::
placeholders
;
const
auto
f
=
std
::
bind
(
MatchAddSong
,
pc
,
criteria
,
_1
,
_2
);
const
auto
f
=
std
::
bind
(
MatchAddSong
,
pc
,
criteria
,
_1
,
_2
);
return
GetDatabase
()
->
Visit
(
&
selection
,
f
,
error_r
);
return
GetDatabase
()
->
Visit
(
selection
,
f
,
error_r
);
}
}
static
bool
static
bool
SearchAddSong
(
struct
player_control
*
pc
,
SearchAddSong
(
struct
player_control
*
pc
,
const
struct
locate_item_list
*
criteria
,
const
struct
locate_item_list
*
criteria
,
s
truct
song
*
song
,
GError
**
error_r
)
s
ong
&
song
,
GError
**
error_r
)
{
{
return
!
locate_song_search
(
song
,
criteria
)
||
return
!
locate_song_search
(
&
song
,
criteria
)
||
AddToQueue
(
pc
,
song
,
error_r
);
AddToQueue
(
pc
,
song
,
error_r
);
}
}
...
@@ -100,7 +99,7 @@ search_add_songs(struct player_control *pc, const char *uri,
...
@@ -100,7 +99,7 @@ search_add_songs(struct player_control *pc, const char *uri,
using
namespace
std
::
placeholders
;
using
namespace
std
::
placeholders
;
const
auto
f
=
std
::
bind
(
SearchAddSong
,
pc
,
new_list
,
_1
,
_2
);
const
auto
f
=
std
::
bind
(
SearchAddSong
,
pc
,
new_list
,
_1
,
_2
);
bool
success
=
GetDatabase
()
->
Visit
(
&
selection
,
f
,
error_r
);
bool
success
=
GetDatabase
()
->
Visit
(
selection
,
f
,
error_r
);
locate_item_list_free
(
new_list
);
locate_item_list_free
(
new_list
);
...
...
src/DatabaseVisitor.hxx
View file @
1a75abff
...
@@ -28,8 +28,9 @@ struct directory;
...
@@ -28,8 +28,9 @@ struct directory;
struct
song
;
struct
song
;
struct
playlist_metadata
;
struct
playlist_metadata
;
typedef
std
::
function
<
bool
(
const
struct
directory
*
,
GError
**
)
>
VisitDirectory
;
typedef
std
::
function
<
bool
(
const
directory
&
,
GError
**
)
>
VisitDirectory
;
typedef
std
::
function
<
bool
(
struct
song
*
,
GError
**
)
>
VisitSong
;
typedef
std
::
function
<
bool
(
struct
song
&
,
GError
**
)
>
VisitSong
;
typedef
std
::
function
<
bool
(
const
struct
playlist_metadata
*
,
const
struct
directory
*
,
GError
**
)
>
VisitPlaylist
;
typedef
std
::
function
<
bool
(
const
playlist_metadata
&
,
const
directory
&
,
GError
**
)
>
VisitPlaylist
;
#endif
#endif
src/Directory.cxx
View file @
1a75abff
...
@@ -291,21 +291,21 @@ directory::Walk(bool recursive,
...
@@ -291,21 +291,21 @@ directory::Walk(bool recursive,
if
(
visit_song
)
{
if
(
visit_song
)
{
struct
song
*
song
;
struct
song
*
song
;
directory_for_each_song
(
song
,
this
)
directory_for_each_song
(
song
,
this
)
if
(
!
visit_song
(
song
,
error_r
))
if
(
!
visit_song
(
*
song
,
error_r
))
return
false
;
return
false
;
}
}
if
(
visit_playlist
)
{
if
(
visit_playlist
)
{
struct
playlist_metadata
*
i
;
struct
playlist_metadata
*
i
;
directory_for_each_playlist
(
i
,
this
)
directory_for_each_playlist
(
i
,
this
)
if
(
!
visit_playlist
(
i
,
this
,
error_r
))
if
(
!
visit_playlist
(
*
i
,
*
this
,
error_r
))
return
false
;
return
false
;
}
}
struct
directory
*
child
;
struct
directory
*
child
;
directory_for_each_child
(
child
,
this
)
{
directory_for_each_child
(
child
,
this
)
{
if
(
visit_directory
&&
if
(
visit_directory
&&
!
visit_directory
(
child
,
error_r
))
!
visit_directory
(
*
child
,
error_r
))
return
false
;
return
false
;
if
(
recursive
&&
if
(
recursive
&&
...
...
src/Stats.cxx
View file @
1a75abff
...
@@ -83,12 +83,12 @@ visit_tag(StringSet &artists, StringSet &albums, const struct tag *tag)
...
@@ -83,12 +83,12 @@ visit_tag(StringSet &artists, StringSet &albums, const struct tag *tag)
}
}
static
bool
static
bool
collect_stats_song
(
StringSet
&
artists
,
StringSet
&
albums
,
s
truct
song
*
song
)
collect_stats_song
(
StringSet
&
artists
,
StringSet
&
albums
,
s
ong
&
song
)
{
{
++
stats
.
song_count
;
++
stats
.
song_count
;
if
(
song
->
tag
!=
NULL
)
if
(
song
.
tag
!=
NULL
)
visit_tag
(
artists
,
albums
,
song
->
tag
);
visit_tag
(
artists
,
albums
,
song
.
tag
);
return
true
;
return
true
;
}
}
...
@@ -106,7 +106,7 @@ void stats_update(void)
...
@@ -106,7 +106,7 @@ void stats_update(void)
using
namespace
std
::
placeholders
;
using
namespace
std
::
placeholders
;
const
auto
f
=
std
::
bind
(
collect_stats_song
,
const
auto
f
=
std
::
bind
(
collect_stats_song
,
std
::
ref
(
artists
),
std
::
ref
(
albums
),
_1
);
std
::
ref
(
artists
),
std
::
ref
(
albums
),
_1
);
GetDatabase
()
->
Visit
(
&
selection
,
f
,
NULL
);
GetDatabase
()
->
Visit
(
selection
,
f
,
NULL
);
stats
.
artist_count
=
artists
.
size
();
stats
.
artist_count
=
artists
.
size
();
stats
.
album_count
=
albums
.
size
();
stats
.
album_count
=
albums
.
size
();
...
...
src/db/SimpleDatabasePlugin.cxx
View file @
1a75abff
...
@@ -237,30 +237,30 @@ SimpleDatabase::LookupDirectory(const char *uri) const
...
@@ -237,30 +237,30 @@ SimpleDatabase::LookupDirectory(const char *uri) const
}
}
bool
bool
SimpleDatabase
::
Visit
(
const
struct
db_selection
*
selection
,
SimpleDatabase
::
Visit
(
const
db_selection
&
selection
,
VisitDirectory
visit_directory
,
VisitDirectory
visit_directory
,
VisitSong
visit_song
,
VisitSong
visit_song
,
VisitPlaylist
visit_playlist
,
VisitPlaylist
visit_playlist
,
GError
**
error_r
)
const
GError
**
error_r
)
const
{
{
const
struct
directory
*
directory
=
LookupDirectory
(
selection
->
uri
);
const
struct
directory
*
directory
=
LookupDirectory
(
selection
.
uri
);
if
(
directory
==
NULL
)
{
if
(
directory
==
NULL
)
{
struct
song
*
song
;
struct
song
*
song
;
if
(
visit_song
&&
if
(
visit_song
&&
(
song
=
GetSong
(
selection
->
uri
,
NULL
))
!=
NULL
)
(
song
=
GetSong
(
selection
.
uri
,
NULL
))
!=
NULL
)
return
visit_song
(
song
,
error_r
);
return
visit_song
(
*
song
,
error_r
);
g_set_error
(
error_r
,
db_quark
(),
DB_NOT_FOUND
,
g_set_error
(
error_r
,
db_quark
(),
DB_NOT_FOUND
,
"No such directory"
);
"No such directory"
);
return
false
;
return
false
;
}
}
if
(
selection
->
recursive
&&
visit_directory
&&
if
(
selection
.
recursive
&&
visit_directory
&&
!
visit_directory
(
directory
,
error_r
))
!
visit_directory
(
*
directory
,
error_r
))
return
false
;
return
false
;
db_lock
();
db_lock
();
bool
ret
=
directory
->
Walk
(
selection
->
recursive
,
bool
ret
=
directory
->
Walk
(
selection
.
recursive
,
visit_directory
,
visit_song
,
visit_playlist
,
visit_directory
,
visit_song
,
visit_playlist
,
error_r
);
error_r
);
db_unlock
();
db_unlock
();
...
...
src/db/SimpleDatabasePlugin.hxx
View file @
1a75abff
...
@@ -60,7 +60,7 @@ public:
...
@@ -60,7 +60,7 @@ public:
virtual
void
Close
()
override
;
virtual
void
Close
()
override
;
virtual
struct
song
*
GetSong
(
const
char
*
uri_utf8
,
virtual
struct
song
*
GetSong
(
const
char
*
uri_utf8
,
GError
**
error_r
)
const
override
;
GError
**
error_r
)
const
override
;
virtual
bool
Visit
(
const
struct
db_selection
*
selection
,
virtual
bool
Visit
(
const
db_selection
&
selection
,
VisitDirectory
visit_directory
,
VisitDirectory
visit_directory
,
VisitSong
visit_song
,
VisitSong
visit_song
,
VisitPlaylist
visit_playlist
,
VisitPlaylist
visit_playlist
,
...
...
test/DumpDatabase.cxx
View file @
1a75abff
...
@@ -48,24 +48,24 @@ my_log_func(const gchar *log_domain, G_GNUC_UNUSED GLogLevelFlags log_level,
...
@@ -48,24 +48,24 @@ my_log_func(const gchar *log_domain, G_GNUC_UNUSED GLogLevelFlags log_level,
}
}
static
bool
static
bool
DumpDirectory
(
const
struct
directory
*
directory
,
GError
**
)
DumpDirectory
(
const
directory
&
directory
,
GError
**
)
{
{
cout
<<
"D "
<<
directory
->
path
<<
endl
;
cout
<<
"D "
<<
directory
.
path
<<
endl
;
return
true
;
return
true
;
}
}
static
bool
static
bool
DumpSong
(
s
truct
song
*
song
,
GError
**
)
DumpSong
(
s
ong
&
song
,
GError
**
)
{
{
cout
<<
"S "
<<
song
->
parent
->
path
<<
"/"
<<
song
->
uri
<<
endl
;
cout
<<
"S "
<<
song
.
parent
->
path
<<
"/"
<<
song
.
uri
<<
endl
;
return
true
;
return
true
;
}
}
static
bool
static
bool
DumpPlaylist
(
const
struct
playlist_metadata
*
playlist
,
DumpPlaylist
(
const
playlist_metadata
&
playlist
,
const
struct
directory
*
directory
,
GError
**
)
const
directory
&
directory
,
GError
**
)
{
{
cout
<<
"P "
<<
directory
->
path
<<
"/"
<<
playlist
->
name
<<
endl
;
cout
<<
"P "
<<
directory
.
path
<<
"/"
<<
playlist
.
name
<<
endl
;
return
true
;
return
true
;
}
}
...
@@ -133,7 +133,7 @@ main(int argc, char **argv)
...
@@ -133,7 +133,7 @@ main(int argc, char **argv)
db_selection
selection
;
db_selection
selection
;
db_selection_init
(
&
selection
,
""
,
true
);
db_selection_init
(
&
selection
,
""
,
true
);
if
(
!
db
->
Visit
(
&
selection
,
DumpDirectory
,
DumpSong
,
DumpPlaylist
,
if
(
!
db
->
Visit
(
selection
,
DumpDirectory
,
DumpSong
,
DumpPlaylist
,
&
error
))
{
&
error
))
{
db
->
Close
();
db
->
Close
();
delete
db
;
delete
db
;
...
...
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