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
c81747dd
Commit
c81747dd
authored
Feb 28, 2016
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
queue/PlaylistTag: throw PlaylistError on error
parent
f8810d7c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
42 deletions
+18
-42
TagCommands.cxx
src/command/TagCommands.cxx
+2
-10
Playlist.hxx
src/queue/Playlist.hxx
+2
-3
PlaylistTag.cxx
src/queue/PlaylistTag.cxx
+14
-29
No files found.
src/command/TagCommands.cxx
View file @
c81747dd
...
@@ -41,11 +41,7 @@ handle_addtagid(Client &client, Request args, Response &r)
...
@@ -41,11 +41,7 @@ handle_addtagid(Client &client, Request args, Response &r)
const
char
*
const
value
=
args
[
2
];
const
char
*
const
value
=
args
[
2
];
Error
error
;
client
.
partition
.
playlist
.
AddSongIdTag
(
song_id
,
tag_type
,
value
);
if
(
!
client
.
partition
.
playlist
.
AddSongIdTag
(
song_id
,
tag_type
,
value
,
error
))
return
print_error
(
r
,
error
);
return
CommandResult
::
OK
;
return
CommandResult
::
OK
;
}
}
...
@@ -65,10 +61,6 @@ handle_cleartagid(Client &client, Request args, Response &r)
...
@@ -65,10 +61,6 @@ handle_cleartagid(Client &client, Request args, Response &r)
}
}
}
}
Error
error
;
client
.
partition
.
playlist
.
ClearSongIdTag
(
song_id
,
tag_type
);
if
(
!
client
.
partition
.
playlist
.
ClearSongIdTag
(
song_id
,
tag_type
,
error
))
return
print_error
(
r
,
error
);
return
CommandResult
::
OK
;
return
CommandResult
::
OK
;
}
}
src/queue/Playlist.hxx
View file @
c81747dd
...
@@ -258,9 +258,8 @@ public:
...
@@ -258,9 +258,8 @@ public:
SongTime
start
,
SongTime
end
,
SongTime
start
,
SongTime
end
,
Error
&
error
);
Error
&
error
);
bool
AddSongIdTag
(
unsigned
id
,
TagType
tag_type
,
const
char
*
value
,
void
AddSongIdTag
(
unsigned
id
,
TagType
tag_type
,
const
char
*
value
);
Error
&
error
);
void
ClearSongIdTag
(
unsigned
id
,
TagType
tag_type
);
bool
ClearSongIdTag
(
unsigned
id
,
TagType
tag_type
,
Error
&
error
);
void
Stop
(
PlayerControl
&
pc
);
void
Stop
(
PlayerControl
&
pc
);
...
...
src/queue/PlaylistTag.cxx
View file @
c81747dd
...
@@ -29,25 +29,18 @@
...
@@ -29,25 +29,18 @@
#include "DetachedSong.hxx"
#include "DetachedSong.hxx"
#include "tag/Tag.hxx"
#include "tag/Tag.hxx"
#include "tag/TagBuilder.hxx"
#include "tag/TagBuilder.hxx"
#include "util/Error.hxx"
bool
void
playlist
::
AddSongIdTag
(
unsigned
id
,
TagType
tag_type
,
const
char
*
value
,
playlist
::
AddSongIdTag
(
unsigned
id
,
TagType
tag_type
,
const
char
*
value
)
Error
&
error
)
{
{
const
int
position
=
queue
.
IdToPosition
(
id
);
const
int
position
=
queue
.
IdToPosition
(
id
);
if
(
position
<
0
)
{
if
(
position
<
0
)
error
.
Set
(
playlist_domain
,
int
(
PlaylistResult
::
NO_SUCH_SONG
),
throw
PlaylistError
::
NoSuchSong
();
"No such song"
);
return
false
;
}
DetachedSong
&
song
=
queue
.
Get
(
position
);
DetachedSong
&
song
=
queue
.
Get
(
position
);
if
(
song
.
IsFile
())
{
if
(
song
.
IsFile
())
error
.
Set
(
playlist_domain
,
int
(
PlaylistResult
::
DENIED
),
throw
PlaylistError
(
PlaylistResult
::
DENIED
,
"Cannot edit tags of local file"
);
"Cannot edit tags of local file"
);
return
false
;
}
{
{
TagBuilder
tag
(
std
::
move
(
song
.
WritableTag
()));
TagBuilder
tag
(
std
::
move
(
song
.
WritableTag
()));
...
@@ -57,26 +50,19 @@ playlist::AddSongIdTag(unsigned id, TagType tag_type, const char *value,
...
@@ -57,26 +50,19 @@ playlist::AddSongIdTag(unsigned id, TagType tag_type, const char *value,
queue
.
ModifyAtPosition
(
position
);
queue
.
ModifyAtPosition
(
position
);
OnModified
();
OnModified
();
return
true
;
}
}
bool
void
playlist
::
ClearSongIdTag
(
unsigned
id
,
TagType
tag_type
,
playlist
::
ClearSongIdTag
(
unsigned
id
,
TagType
tag_type
)
Error
&
error
)
{
{
const
int
position
=
queue
.
IdToPosition
(
id
);
const
int
position
=
queue
.
IdToPosition
(
id
);
if
(
position
<
0
)
{
if
(
position
<
0
)
error
.
Set
(
playlist_domain
,
int
(
PlaylistResult
::
NO_SUCH_SONG
),
throw
PlaylistError
::
NoSuchSong
();
"No such song"
);
return
false
;
}
DetachedSong
&
song
=
queue
.
Get
(
position
);
DetachedSong
&
song
=
queue
.
Get
(
position
);
if
(
song
.
IsFile
())
{
if
(
song
.
IsFile
())
error
.
Set
(
playlist_domain
,
int
(
PlaylistResult
::
DENIED
),
throw
PlaylistError
(
PlaylistResult
::
DENIED
,
"Cannot edit tags of local file"
);
"Cannot edit tags of local file"
);
return
false
;
}
{
{
TagBuilder
tag
(
std
::
move
(
song
.
WritableTag
()));
TagBuilder
tag
(
std
::
move
(
song
.
WritableTag
()));
...
@@ -89,5 +75,4 @@ playlist::ClearSongIdTag(unsigned id, TagType tag_type,
...
@@ -89,5 +75,4 @@ playlist::ClearSongIdTag(unsigned id, TagType tag_type,
queue
.
ModifyAtPosition
(
position
);
queue
.
ModifyAtPosition
(
position
);
OnModified
();
OnModified
();
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