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
8331de42
Commit
8331de42
authored
Jan 02, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PlaylistInfo: rename class, use std::string
parent
98dbdf72
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
53 additions
and
102 deletions
+53
-102
Makefile.am
Makefile.am
+2
-2
DatabasePrint.cxx
src/DatabasePrint.cxx
+4
-4
DatabaseVisitor.hxx
src/DatabaseVisitor.hxx
+2
-2
Directory.cxx
src/Directory.cxx
+1
-1
PlaylistDatabase.cxx
src/PlaylistDatabase.cxx
+4
-5
PlaylistInfo.cxx
src/PlaylistInfo.cxx
+0
-46
PlaylistInfo.hxx
src/PlaylistInfo.hxx
+10
-7
PlaylistVector.cxx
src/PlaylistVector.cxx
+14
-16
PlaylistVector.hxx
src/PlaylistVector.hxx
+3
-5
UpdateWalk.cxx
src/UpdateWalk.cxx
+8
-5
ProxyDatabasePlugin.cxx
src/db/ProxyDatabasePlugin.cxx
+3
-7
DumpDatabase.cxx
test/DumpDatabase.cxx
+2
-2
No files found.
Makefile.am
View file @
8331de42
...
...
@@ -303,7 +303,7 @@ src_mpd_SOURCES = \
src/PlaylistState.cxx src/PlaylistState.hxx
\
src/PlaylistQueue.cxx src/PlaylistQueue.hxx
\
src/PlaylistVector.cxx src/PlaylistVector.hxx
\
src/PlaylistInfo.
cxx src/PlaylistInfo.
hxx
\
src/PlaylistInfo.hxx
\
src/PlaylistDatabase.cxx
\
src/queue.c
\
src/QueuePrint.cxx src/QueuePrint.hxx
\
...
...
@@ -1072,7 +1072,7 @@ test_DumpDatabase_SOURCES = test/DumpDatabase.cxx \
src/DatabaseRegistry.cxx
\
src/DatabaseSelection.cxx
\
src/Directory.cxx src/DirectorySave.cxx
\
src/PlaylistVector.cxx src/Playlist
Info.cxx src/Playlist
Database.cxx
\
src/PlaylistVector.cxx src/PlaylistDatabase.cxx
\
src/DatabaseLock.cxx src/DatabaseSave.cxx
\
src/Song.cxx src/song_sort.c src/SongSave.cxx
\
src/tag.c src/tag_pool.c src/TagSave.cxx
\
...
...
src/DatabasePrint.cxx
View file @
8331de42
...
...
@@ -91,19 +91,19 @@ PrintSongFull(struct client *client, song &song)
static
bool
PrintPlaylistBrief
(
struct
client
*
client
,
const
playlist_metadata
&
playlist
,
const
PlaylistInfo
&
playlist
,
const
directory
&
directory
)
{
print_playlist_in_directory
(
client
,
directory
,
playlist
.
name
);
print_playlist_in_directory
(
client
,
directory
,
playlist
.
name
.
c_str
()
);
return
true
;
}
static
bool
PrintPlaylistFull
(
struct
client
*
client
,
const
playlist_metadata
&
playlist
,
const
PlaylistInfo
&
playlist
,
const
directory
&
directory
)
{
print_playlist_in_directory
(
client
,
directory
,
playlist
.
name
);
print_playlist_in_directory
(
client
,
directory
,
playlist
.
name
.
c_str
()
);
if
(
playlist
.
mtime
>
0
)
time_print
(
client
,
"Last-Modified"
,
playlist
.
mtime
);
...
...
src/DatabaseVisitor.hxx
View file @
8331de42
...
...
@@ -26,11 +26,11 @@
struct
directory
;
struct
song
;
struct
playlist_metadata
;
struct
PlaylistInfo
;
typedef
std
::
function
<
bool
(
const
directory
&
,
GError
**
)
>
VisitDirectory
;
typedef
std
::
function
<
bool
(
struct
song
&
,
GError
**
)
>
VisitSong
;
typedef
std
::
function
<
bool
(
const
playlist_metadata
&
,
const
directory
&
,
typedef
std
::
function
<
bool
(
const
PlaylistInfo
&
,
const
directory
&
,
GError
**
)
>
VisitPlaylist
;
typedef
std
::
function
<
bool
(
const
char
*
,
GError
**
)
>
VisitString
;
...
...
src/Directory.cxx
View file @
8331de42
...
...
@@ -307,7 +307,7 @@ directory::Walk(bool recursive, const SongFilter *filter,
}
if
(
visit_playlist
)
{
struct
playlist_metadata
*
i
;
PlaylistInfo
*
i
;
directory_for_each_playlist
(
i
,
this
)
if
(
!
visit_playlist
(
*
i
,
*
this
,
error_r
))
return
false
;
...
...
src/PlaylistDatabase.cxx
View file @
8331de42
...
...
@@ -38,20 +38,19 @@ playlist_database_quark(void)
void
playlist_vector_save
(
FILE
*
fp
,
const
struct
list_head
*
pv
)
{
struct
playlist_metadata
*
pm
;
PlaylistInfo
*
pm
;
playlist_vector_for_each
(
pm
,
pv
)
fprintf
(
fp
,
PLAYLIST_META_BEGIN
"%s
\n
"
"mtime: %li
\n
"
"playlist_end
\n
"
,
pm
->
name
,
(
long
)
pm
->
mtime
);
pm
->
name
.
c_str
()
,
(
long
)
pm
->
mtime
);
}
bool
playlist_metadata_load
(
FILE
*
fp
,
struct
list_head
*
pv
,
const
char
*
name
,
GString
*
buffer
,
GError
**
error_r
)
{
struct
playlist_metadata
pm
;
pm
.
mtime
=
0
;
PlaylistInfo
pm
(
name
,
0
);
char
*
line
,
*
colon
;
const
char
*
value
;
...
...
@@ -77,6 +76,6 @@ playlist_metadata_load(FILE *fp, struct list_head *pv, const char *name,
}
}
playlist_vector_update_or_add
(
pv
,
name
,
pm
.
mtime
);
playlist_vector_update_or_add
(
pv
,
std
::
move
(
pm
)
);
return
true
;
}
src/PlaylistInfo.cxx
deleted
100644 → 0
View file @
98dbdf72
/*
* Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "config.h"
#include "PlaylistInfo.hxx"
#include <glib.h>
#include <assert.h>
struct
playlist_metadata
*
playlist_metadata_new
(
const
char
*
name
,
time_t
mtime
)
{
assert
(
name
!=
NULL
);
struct
playlist_metadata
*
pm
=
g_slice_new
(
struct
playlist_metadata
);
pm
->
name
=
g_strdup
(
name
);
pm
->
mtime
=
mtime
;
return
pm
;
}
void
playlist_metadata_free
(
struct
playlist_metadata
*
pm
)
{
assert
(
pm
!=
NULL
);
assert
(
pm
->
name
!=
NULL
);
g_free
(
pm
->
name
);
g_slice_free
(
struct
playlist_metadata
,
pm
);
}
src/PlaylistInfo.hxx
View file @
8331de42
...
...
@@ -23,26 +23,29 @@
#include "check.h"
#include "util/list.h"
#include <string>
#include <sys/time.h>
/**
* A directory entry pointing to a playlist file.
*/
struct
playlist_metadata
{
struct
PlaylistInfo
{
struct
list_head
siblings
;
/**
* The UTF-8 encoded name of the playlist file.
*/
char
*
name
;
std
::
string
name
;
time_t
mtime
;
};
struct
playlist_metadata
*
playlist_metadata_new
(
const
char
*
name
,
time_t
mtime
);
template
<
typename
N
>
PlaylistInfo
(
N
&&
_name
,
time_t
_mtime
)
:
name
(
std
::
forward
<
N
>
(
_name
)),
mtime
(
_mtime
)
{}
void
playlist_metadata_free
(
struct
playlist_metadata
*
pm
);
PlaylistInfo
(
const
PlaylistInfo
&
other
)
=
delete
;
PlaylistInfo
(
PlaylistInfo
&&
)
=
default
;
};
#endif
src/PlaylistVector.cxx
View file @
8331de42
...
...
@@ -30,50 +30,48 @@ playlist_vector_deinit(struct list_head *pv)
{
assert
(
pv
!=
NULL
);
struct
playlist_metadata
*
pm
,
*
n
;
PlaylistInfo
*
pm
,
*
n
;
playlist_vector_for_each_safe
(
pm
,
n
,
pv
)
playlist_metadata_free
(
pm
)
;
delete
pm
;
}
struct
playlist_metadata
*
PlaylistInfo
*
playlist_vector_find
(
struct
list_head
*
pv
,
const
char
*
name
)
{
assert
(
holding_db_lock
());
assert
(
pv
!=
NULL
);
assert
(
name
!=
NULL
);
struct
playlist_metadata
*
pm
;
PlaylistInfo
*
pm
;
playlist_vector_for_each
(
pm
,
pv
)
if
(
strcmp
(
pm
->
name
,
name
)
==
0
)
if
(
pm
->
name
.
compare
(
name
)
==
0
)
return
pm
;
return
NULL
;
}
void
playlist_vector_add
(
struct
list_head
*
pv
,
const
char
*
name
,
time_t
mtime
)
playlist_vector_add
(
struct
list_head
*
pv
,
PlaylistInfo
&&
pi
)
{
assert
(
holding_db_lock
());
struct
playlist_metadata
*
pm
=
playlist_metadata_new
(
name
,
mtime
);
PlaylistInfo
*
pm
=
new
PlaylistInfo
(
std
::
move
(
pi
)
);
list_add_tail
(
&
pm
->
siblings
,
pv
);
}
bool
playlist_vector_update_or_add
(
struct
list_head
*
pv
,
const
char
*
name
,
time_t
mtime
)
playlist_vector_update_or_add
(
struct
list_head
*
pv
,
PlaylistInfo
&&
pi
)
{
assert
(
holding_db_lock
());
struct
playlist_metadata
*
pm
=
playlist_vector_find
(
pv
,
name
);
PlaylistInfo
*
pm
=
playlist_vector_find
(
pv
,
pi
.
name
.
c_str
()
);
if
(
pm
!=
NULL
)
{
if
(
mtime
==
pm
->
mtime
)
if
(
pi
.
mtime
==
pm
->
mtime
)
return
false
;
pm
->
mtime
=
mtime
;
pm
->
mtime
=
pi
.
mtime
;
}
else
playlist_vector_add
(
pv
,
name
,
mtime
);
playlist_vector_add
(
pv
,
std
::
move
(
pi
)
);
return
true
;
}
...
...
@@ -83,11 +81,11 @@ playlist_vector_remove(struct list_head *pv, const char *name)
{
assert
(
holding_db_lock
());
struct
playlist_metadata
*
pm
=
playlist_vector_find
(
pv
,
name
);
PlaylistInfo
*
pm
=
playlist_vector_find
(
pv
,
name
);
if
(
pm
==
NULL
)
return
false
;
list_del
(
&
pm
->
siblings
);
playlist_metadata_free
(
pm
)
;
delete
pm
;
return
true
;
}
src/PlaylistVector.hxx
View file @
8331de42
...
...
@@ -37,15 +37,14 @@ playlist_vector_deinit(struct list_head *pv);
/**
* Caller must lock the #db_mutex.
*/
struct
playlist_metadata
*
PlaylistInfo
*
playlist_vector_find
(
struct
list_head
*
pv
,
const
char
*
name
);
/**
* Caller must lock the #db_mutex.
*/
void
playlist_vector_add
(
struct
list_head
*
pv
,
const
char
*
name
,
time_t
mtime
);
playlist_vector_add
(
struct
list_head
*
pv
,
PlaylistInfo
&&
pi
);
/**
* Caller must lock the #db_mutex.
...
...
@@ -53,8 +52,7 @@ playlist_vector_add(struct list_head *pv,
* @return true if the vector or one of its items was modified
*/
bool
playlist_vector_update_or_add
(
struct
list_head
*
pv
,
const
char
*
name
,
time_t
mtime
);
playlist_vector_update_or_add
(
struct
list_head
*
pv
,
PlaylistInfo
&&
pi
);
/**
* Caller must lock the #db_mutex.
...
...
src/UpdateWalk.cxx
View file @
8331de42
...
...
@@ -159,11 +159,12 @@ purge_deleted_from_directory(struct directory *directory)
g_free
(
path
);
}
struct
playlist_metadata
*
pm
,
*
np
;
PlaylistInfo
*
pm
,
*
np
;
directory_for_each_playlist_safe
(
pm
,
np
,
directory
)
{
if
(
!
directory_child_is_regular
(
directory
,
pm
->
name
))
{
if
(
!
directory_child_is_regular
(
directory
,
pm
->
name
.
c_str
()
))
{
db_lock
();
playlist_vector_remove
(
&
directory
->
playlists
,
pm
->
name
);
playlist_vector_remove
(
&
directory
->
playlists
,
pm
->
name
.
c_str
());
db_unlock
();
}
}
...
...
@@ -214,9 +215,11 @@ update_playlist_file2(struct directory *directory,
if
(
!
playlist_suffix_supported
(
suffix
))
return
false
;
PlaylistInfo
pi
(
name
,
st
->
st_mtime
);
db_lock
();
if
(
playlist_vector_update_or_add
(
&
directory
->
playlists
,
name
,
st
->
st_mtime
))
if
(
playlist_vector_update_or_add
(
&
directory
->
playlists
,
st
d
::
move
(
pi
)
))
modified
=
true
;
db_unlock
();
return
true
;
...
...
src/db/ProxyDatabasePlugin.cxx
View file @
8331de42
...
...
@@ -314,14 +314,10 @@ Visit(const struct mpd_playlist *playlist,
if
(
!
visit_playlist
)
return
true
;
struct
playlist_metadata
p
;
p
.
name
=
g_strdup
(
mpd_playlist_get_path
(
playlist
));
p
.
mtime
=
mpd_playlist_get_last_modified
(
playlist
);
PlaylistInfo
p
(
mpd_playlist_get_path
(
playlist
),
mpd_playlist_get_last_modified
(
playlist
));
bool
success
=
visit_playlist
(
p
,
detached_root
,
error_r
);
g_free
(
p
.
name
);
return
success
;
return
visit_playlist
(
p
,
detached_root
,
error_r
);
}
class
ProxyEntity
{
...
...
test/DumpDatabase.cxx
View file @
8331de42
...
...
@@ -62,10 +62,10 @@ DumpSong(song &song, GError **)
}
static
bool
DumpPlaylist
(
const
playlist_metadata
&
playlist
,
DumpPlaylist
(
const
PlaylistInfo
&
playlist
,
const
directory
&
directory
,
GError
**
)
{
cout
<<
"P "
<<
directory
.
path
<<
"/"
<<
playlist
.
name
<<
endl
;
cout
<<
"P "
<<
directory
.
path
<<
"/"
<<
playlist
.
name
.
c_str
()
<<
endl
;
return
true
;
}
...
...
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