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
5a915eb0
Commit
5a915eb0
authored
Apr 24, 2019
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sticker/Database: return Sticker by value
parent
7b48ae4f
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
13 additions
and
32 deletions
+13
-32
StickerCommands.cxx
src/command/StickerCommands.cxx
+3
-5
SongSticker.cxx
src/sticker/SongSticker.cxx
+3
-2
SongSticker.hxx
src/sticker/SongSticker.hxx
+3
-3
StickerDatabase.cxx
src/sticker/StickerDatabase.cxx
+2
-12
StickerDatabase.hxx
src/sticker/StickerDatabase.hxx
+2
-10
No files found.
src/command/StickerCommands.cxx
View file @
5a915eb0
...
...
@@ -21,6 +21,7 @@
#include "Request.hxx"
#include "SongPrint.hxx"
#include "db/Interface.hxx"
#include "sticker/Sticker.hxx"
#include "sticker/SongSticker.hxx"
#include "sticker/StickerPrint.hxx"
#include "sticker/StickerDatabase.hxx"
...
...
@@ -76,11 +77,8 @@ handle_sticker_song(Response &r, Partition &partition, Request args)
assert
(
song
!=
nullptr
);
AtScopeExit
(
&
db
,
song
)
{
db
.
ReturnSong
(
song
);
};
Sticker
*
sticker
=
sticker_song_get
(
*
song
);
if
(
sticker
)
{
sticker_print
(
r
,
*
sticker
);
sticker_free
(
sticker
);
}
const
auto
sticker
=
sticker_song_get
(
*
song
);
sticker_print
(
r
,
sticker
);
return
CommandResult
::
OK
;
/* set song song_id id key */
...
...
src/sticker/SongSticker.cxx
View file @
5a915eb0
/*
* Copyright 2003-201
8
The Music Player Daemon Project
* Copyright 2003-201
9
The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
...
...
@@ -18,6 +18,7 @@
*/
#include "SongSticker.hxx"
#include "Sticker.hxx"
#include "StickerDatabase.hxx"
#include "song/LightSong.hxx"
#include "db/Interface.hxx"
...
...
@@ -61,7 +62,7 @@ sticker_song_delete_value(const LightSong &song, const char *name)
return
sticker_delete_value
(
"song"
,
uri
.
c_str
(),
name
);
}
Sticker
*
Sticker
sticker_song_get
(
const
LightSong
&
song
)
{
const
auto
uri
=
song
.
GetURI
();
...
...
src/sticker/SongSticker.hxx
View file @
5a915eb0
/*
* Copyright 2003-201
8
The Music Player Daemon Project
* Copyright 2003-201
9
The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
...
...
@@ -72,9 +72,9 @@ sticker_song_delete_value(const LightSong &song, const char *name);
* Throws #SqliteError on error.
*
* @param song the song object
* @return a sticker object
, or nullptr if there is no sticker
* @return a sticker object
*/
Sticker
*
Sticker
sticker_song_get
(
const
LightSong
&
song
);
/**
...
...
src/sticker/StickerDatabase.cxx
View file @
5a915eb0
...
...
@@ -314,12 +314,6 @@ sticker_delete_value(const char *type, const char *uri, const char *name)
return
modified
;
}
void
sticker_free
(
Sticker
*
sticker
)
noexcept
{
delete
sticker
;
}
const
char
*
sticker_get_value
(
const
Sticker
&
sticker
,
const
char
*
name
)
noexcept
{
...
...
@@ -340,18 +334,14 @@ sticker_foreach(const Sticker &sticker,
func
(
i
.
first
.
c_str
(),
i
.
second
.
c_str
(),
user_data
);
}
Sticker
*
Sticker
sticker_load
(
const
char
*
type
,
const
char
*
uri
)
{
Sticker
s
;
sticker_list_values
(
s
.
table
,
type
,
uri
);
if
(
s
.
table
.
empty
())
/* don't return empty sticker objects */
return
nullptr
;
return
new
Sticker
(
std
::
move
(
s
));
return
s
;
}
static
sqlite3_stmt
*
...
...
src/sticker/StickerDatabase.hxx
View file @
5a915eb0
...
...
@@ -109,14 +109,6 @@ bool
sticker_delete_value
(
const
char
*
type
,
const
char
*
uri
,
const
char
*
name
);
/**
* Frees resources held by the sticker object.
*
* @param sticker the sticker object to be freed
*/
void
sticker_free
(
Sticker
*
sticker
)
noexcept
;
/**
* Determines a single value in a sticker.
*
* @param sticker the sticker object
...
...
@@ -147,9 +139,9 @@ sticker_foreach(const Sticker &sticker,
*
* @param type the resource type, e.g. "song"
* @param uri the URI of the resource, e.g. the song path
* @return a sticker object
, or nullptr if there is no sticker
* @return a sticker object
*/
Sticker
*
Sticker
sticker_load
(
const
char
*
type
,
const
char
*
uri
);
/**
...
...
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