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
32ec6723
Commit
32ec6723
authored
Jan 15, 2014
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DatabaseSong: new library merging duplicate code
parent
e2812f72
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
91 additions
and
35 deletions
+91
-35
Makefile.am
Makefile.am
+1
-0
DatabaseSong.cxx
src/DatabaseSong.cxx
+40
-0
DatabaseSong.hxx
src/DatabaseSong.hxx
+38
-0
PlaylistEdit.cxx
src/PlaylistEdit.cxx
+3
-11
PlaylistFile.cxx
src/PlaylistFile.cxx
+6
-12
PlaylistSong.cxx
src/PlaylistSong.cxx
+3
-12
No files found.
Makefile.am
View file @
32ec6723
...
...
@@ -107,6 +107,7 @@ src_mpd_SOURCES = \
src/DirectorySave.cxx src/DirectorySave.hxx
\
src/DatabaseSimple.hxx
\
src/DatabaseGlue.cxx src/DatabaseGlue.hxx
\
src/DatabaseSong.cxx src/DatabaseSong.hxx
\
src/DatabasePrint.cxx src/DatabasePrint.hxx
\
src/DatabaseQueue.cxx src/DatabaseQueue.hxx
\
src/DatabasePlaylist.cxx src/DatabasePlaylist.hxx
\
...
...
src/DatabaseSong.cxx
0 → 100644
View file @
32ec6723
/*
* Copyright (C) 2003-2014 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 "DatabaseSong.hxx"
#include "DatabaseGlue.hxx"
#include "DatabasePlugin.hxx"
#include "DetachedSong.hxx"
DetachedSong
*
DatabaseDetachSong
(
const
char
*
uri
,
Error
&
error
)
{
const
Database
*
db
=
GetDatabase
(
error
);
if
(
db
==
nullptr
)
return
nullptr
;
Song
*
tmp
=
db
->
GetSong
(
uri
,
error
);
if
(
tmp
==
nullptr
)
return
nullptr
;
DetachedSong
*
song
=
new
DetachedSong
(
*
tmp
);
db
->
ReturnSong
(
tmp
);
return
song
;
}
src/DatabaseSong.hxx
0 → 100644
View file @
32ec6723
/*
* Copyright (C) 2003-2014 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.
*/
#ifndef MPD_DATABASE_SONG_HXX
#define MPD_DATABASE_SONG_HXX
#include "Compiler.h"
class
DetachedSong
;
class
Error
;
/**
* Look up a song in the database and convert it to a #DetachedSong
* instance. The caller is responsible for freeing it.
*
* @return nullptr on error
*/
gcc_malloc
gcc_nonnull_all
DetachedSong
*
DatabaseDetachSong
(
const
char
*
uri
,
Error
&
error
);
#endif
src/PlaylistEdit.cxx
View file @
32ec6723
...
...
@@ -32,8 +32,7 @@
#include "Song.hxx"
#include "DetachedSong.hxx"
#include "Idle.hxx"
#include "DatabaseGlue.hxx"
#include "DatabasePlugin.hxx"
#include "DatabaseSong.hxx"
#include "Log.hxx"
#include <stdlib.h>
...
...
@@ -113,16 +112,9 @@ playlist::AppendURI(PlayerControl &pc,
if
(
uri_has_scheme
(
uri
))
{
song
=
new
DetachedSong
(
uri
);
}
else
{
const
Database
*
db
=
GetDatabase
(
);
if
(
db
==
nullptr
)
song
=
DatabaseDetachSong
(
uri
,
IgnoreError
()
);
if
(
song
==
nullptr
)
return
PlaylistResult
::
NO_SUCH_SONG
;
Song
*
tmp
=
db
->
GetSong
(
uri
,
IgnoreError
());
if
(
tmp
==
nullptr
)
return
PlaylistResult
::
NO_SUCH_SONG
;
song
=
new
DetachedSong
(
*
tmp
);
db
->
ReturnSong
(
tmp
);
}
PlaylistResult
result
=
AppendSong
(
pc
,
std
::
move
(
*
song
),
added_id
);
...
...
src/PlaylistFile.cxx
View file @
32ec6723
...
...
@@ -22,8 +22,7 @@
#include "PlaylistSave.hxx"
#include "PlaylistInfo.hxx"
#include "PlaylistVector.hxx"
#include "DatabasePlugin.hxx"
#include "DatabaseGlue.hxx"
#include "DatabaseSong.hxx"
#include "DetachedSong.hxx"
#include "Mapper.hxx"
#include "fs/TextFile.hxx"
...
...
@@ -405,18 +404,13 @@ spl_append_uri(const char *url, const char *utf8file, Error &error)
return
spl_append_song
(
utf8file
,
DetachedSong
(
url
),
error
);
}
else
{
const
Database
*
db
=
GetDatabase
(
error
);
if
(
db
==
nullptr
)
DetachedSong
*
song
=
DatabaseDetachSong
(
url
,
error
);
if
(
song
==
nullptr
)
return
false
;
Song
*
tmp
=
db
->
GetSong
(
url
,
error
);
if
(
tmp
==
nullptr
)
return
false
;
const
DetachedSong
song
(
*
tmp
);
db
->
ReturnSong
(
tmp
);
return
spl_append_song
(
utf8file
,
song
,
error
);
bool
success
=
spl_append_song
(
utf8file
,
*
song
,
error
);
delete
song
;
return
success
;
}
}
...
...
src/PlaylistSong.cxx
View file @
32ec6723
...
...
@@ -20,8 +20,7 @@
#include "config.h"
#include "PlaylistSong.hxx"
#include "Mapper.hxx"
#include "DatabasePlugin.hxx"
#include "DatabaseGlue.hxx"
#include "DatabaseSong.hxx"
#include "ls.hxx"
#include "tag/Tag.hxx"
#include "tag/TagBuilder.hxx"
...
...
@@ -106,17 +105,9 @@ playlist_check_load_song(const DetachedSong *song, const char *uri, bool secure)
return
nullptr
;
}
}
else
{
const
Database
*
db
=
GetDatabase
(
);
if
(
d
b
==
nullptr
)
dest
=
DatabaseDetachSong
(
uri
,
IgnoreError
()
);
if
(
d
est
==
nullptr
)
return
nullptr
;
Song
*
tmp
=
db
->
GetSong
(
uri
,
IgnoreError
());
if
(
tmp
==
nullptr
)
/* not found in database */
return
nullptr
;
dest
=
new
DetachedSong
(
*
tmp
);
db
->
ReturnSong
(
tmp
);
}
return
apply_song_metadata
(
dest
,
song
);
...
...
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