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
fed44e95
Commit
fed44e95
authored
Dec 12, 2014
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sticker/Song: add enum StickerOperator to sticker_song_find()
parent
71ece564
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
60 additions
and
5 deletions
+60
-5
Makefile.am
Makefile.am
+1
-0
StickerCommands.cxx
src/command/StickerCommands.cxx
+4
-0
Match.hxx
src/sticker/Match.hxx
+31
-0
SongSticker.cxx
src/sticker/SongSticker.cxx
+2
-1
SongSticker.hxx
src/sticker/SongSticker.hxx
+4
-1
StickerDatabase.cxx
src/sticker/StickerDatabase.cxx
+14
-3
StickerDatabase.hxx
src/sticker/StickerDatabase.hxx
+4
-0
No files found.
Makefile.am
View file @
fed44e95
...
...
@@ -356,6 +356,7 @@ libmpd_a_SOURCES += \
src/command/StickerCommands.cxx src/command/StickerCommands.hxx
\
src/lib/sqlite/Domain.cxx src/lib/sqlite/Domain.hxx
\
src/lib/sqlite/Util.hxx
\
src/sticker/Match.hxx
\
src/sticker/StickerDatabase.cxx src/sticker/StickerDatabase.hxx
\
src/sticker/StickerPrint.cxx src/sticker/StickerPrint.hxx
\
src/sticker/SongSticker.cxx src/sticker/SongSticker.hxx
...
...
src/command/StickerCommands.cxx
View file @
fed44e95
...
...
@@ -143,6 +143,9 @@ handle_sticker_song(Client &client, ConstBuffer<const char *> args)
const
char
*
const
base_uri
=
args
[
2
];
StickerOperator
op
=
StickerOperator
::
EXISTS
;
const
char
*
value
=
nullptr
;
bool
success
;
struct
sticker_song_find_data
data
=
{
client
,
...
...
@@ -150,6 +153,7 @@ handle_sticker_song(Client &client, ConstBuffer<const char *> args)
};
success
=
sticker_song_find
(
*
db
,
base_uri
,
data
.
name
,
op
,
value
,
sticker_song_find_print_cb
,
&
data
,
error
);
if
(
!
success
)
{
...
...
src/sticker/Match.hxx
0 → 100644
View file @
fed44e95
/*
* 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_STICKER_MATCH_HXX
#define MPD_STICKER_MATCH_HXX
enum
class
StickerOperator
{
/**
* Matches if a sticker with the specified name exists. The
* "value" parameter is ignored (must be nullptr).
*/
EXISTS
,
};
#endif
src/sticker/SongSticker.cxx
View file @
fed44e95
...
...
@@ -97,6 +97,7 @@ sticker_song_find_cb(const char *uri, const char *value, void *user_data)
bool
sticker_song_find
(
const
Database
&
db
,
const
char
*
base_uri
,
const
char
*
name
,
StickerOperator
op
,
const
char
*
value
,
void
(
*
func
)(
const
LightSong
&
song
,
const
char
*
value
,
void
*
user_data
),
void
*
user_data
,
...
...
@@ -119,7 +120,7 @@ sticker_song_find(const Database &db, const char *base_uri, const char *name,
data
.
base_uri_length
=
strlen
(
data
.
base_uri
);
bool
success
=
sticker_find
(
"song"
,
data
.
base_uri
,
name
,
bool
success
=
sticker_find
(
"song"
,
data
.
base_uri
,
name
,
op
,
value
,
sticker_song_find_cb
,
&
data
,
error
);
free
(
allocated
);
...
...
src/sticker/SongSticker.hxx
View file @
fed44e95
...
...
@@ -20,6 +20,7 @@
#ifndef MPD_SONG_STICKER_HXX
#define MPD_SONG_STICKER_HXX
#include "Match.hxx"
#include "Compiler.h"
#include <string>
...
...
@@ -30,7 +31,8 @@ class Database;
class
Error
;
/**
* Returns one value from a song's sticker record.
* Returns one value from a song's sticker record. The caller must
* free the return value with g_free().
*/
gcc_pure
std
::
string
...
...
@@ -81,6 +83,7 @@ sticker_song_get(const LightSong &song, Error &error);
*/
bool
sticker_song_find
(
const
Database
&
db
,
const
char
*
base_uri
,
const
char
*
name
,
StickerOperator
op
,
const
char
*
value
,
void
(
*
func
)(
const
LightSong
&
song
,
const
char
*
value
,
void
*
user_data
),
void
*
user_data
,
...
...
src/sticker/StickerDatabase.cxx
View file @
fed44e95
...
...
@@ -370,6 +370,7 @@ sticker_load(const char *type, const char *uri, Error &error)
static
sqlite3_stmt
*
BindFind
(
const
char
*
type
,
const
char
*
base_uri
,
const
char
*
name
,
StickerOperator
op
,
const
char
*
value
,
Error
&
error
)
{
assert
(
type
!=
nullptr
);
...
...
@@ -378,12 +379,21 @@ BindFind(const char *type, const char *base_uri, const char *name,
if
(
base_uri
==
nullptr
)
base_uri
=
""
;
return
BindAllOrNull
(
error
,
sticker_stmt
[
STICKER_SQL_FIND
],
type
,
base_uri
,
name
);
switch
(
op
)
{
case
StickerOperator
:
:
EXISTS
:
return
BindAllOrNull
(
error
,
sticker_stmt
[
STICKER_SQL_FIND
],
type
,
base_uri
,
name
);
}
(
void
)
value
;
assert
(
false
);
gcc_unreachable
();
}
bool
sticker_find
(
const
char
*
type
,
const
char
*
base_uri
,
const
char
*
name
,
StickerOperator
op
,
const
char
*
value
,
void
(
*
func
)(
const
char
*
uri
,
const
char
*
value
,
void
*
user_data
),
void
*
user_data
,
...
...
@@ -392,7 +402,8 @@ sticker_find(const char *type, const char *base_uri, const char *name,
assert
(
func
!=
nullptr
);
assert
(
sticker_enabled
());
sqlite3_stmt
*
const
stmt
=
BindFind
(
type
,
base_uri
,
name
,
error
);
sqlite3_stmt
*
const
stmt
=
BindFind
(
type
,
base_uri
,
name
,
op
,
value
,
error
);
if
(
stmt
==
nullptr
)
return
false
;
...
...
src/sticker/StickerDatabase.hxx
View file @
fed44e95
...
...
@@ -42,6 +42,7 @@
#ifndef MPD_STICKER_DATABASE_HXX
#define MPD_STICKER_DATABASE_HXX
#include "Match.hxx"
#include "Compiler.h"
#include <string>
...
...
@@ -154,11 +155,14 @@ sticker_load(const char *type, const char *uri,
* @param base_uri the URI prefix of the resources, or nullptr if all
* resources should be searched
* @param name the name of the sticker
* @param op the comparison operator
* @param value the operand
* @return true on success (even if no sticker was found), false on
* failure
*/
bool
sticker_find
(
const
char
*
type
,
const
char
*
base_uri
,
const
char
*
name
,
StickerOperator
op
,
const
char
*
value
,
void
(
*
func
)(
const
char
*
uri
,
const
char
*
value
,
void
*
user_data
),
void
*
user_data
,
...
...
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