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
610940a0
Commit
610940a0
authored
Apr 28, 2009
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sticker: added sticker_delete_value()
sticker_delete_value() deletes only one value in a sticker, while the old function sticker_delete() deletes all values.
parent
7d9316a5
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
85 additions
and
0 deletions
+85
-0
song_sticker.c
src/song_sticker.c
+16
-0
song_sticker.h
src/song_sticker.h
+7
-0
sticker.c
src/sticker.c
+55
-0
sticker.h
src/sticker.h
+7
-0
No files found.
src/song_sticker.c
View file @
610940a0
...
...
@@ -75,6 +75,22 @@ sticker_song_delete(const struct song *song)
return
ret
;
}
bool
sticker_song_delete_value
(
const
struct
song
*
song
,
const
char
*
name
)
{
char
*
uri
;
bool
success
;
assert
(
song
!=
NULL
);
assert
(
song_in_database
(
song
));
uri
=
song_get_uri
(
song
);
success
=
sticker_delete_value
(
"song"
,
uri
,
name
);
g_free
(
uri
);
return
success
;
}
struct
sticker
*
sticker_song_get
(
const
struct
song
*
song
)
{
...
...
src/song_sticker.h
View file @
610940a0
...
...
@@ -49,6 +49,13 @@ bool
sticker_song_delete
(
const
struct
song
*
song
);
/**
* Deletes a sticker value. Does nothing if the sticker did not
* exist.
*/
bool
sticker_song_delete_value
(
const
struct
song
*
song
,
const
char
*
name
);
/**
* Loads the sticker for the specified song.
*
* @param song the song object
...
...
src/sticker.c
View file @
610940a0
...
...
@@ -37,6 +37,7 @@ enum sticker_sql {
STICKER_SQL_UPDATE
,
STICKER_SQL_INSERT
,
STICKER_SQL_DELETE
,
STICKER_SQL_DELETE_VALUE
,
STICKER_SQL_FIND
,
};
...
...
@@ -51,6 +52,8 @@ static const char *const sticker_sql[] = {
"INSERT INTO sticker(type,uri,name,value) VALUES(?, ?, ?, ?)"
,
[
STICKER_SQL_DELETE
]
=
"DELETE FROM sticker WHERE type=? AND uri=?"
,
[
STICKER_SQL_DELETE_VALUE
]
=
"DELETE FROM sticker WHERE type=? AND uri=? AND name=?"
,
[
STICKER_SQL_FIND
]
=
"SELECT uri,value FROM sticker WHERE type=? AND uri LIKE (? || '%') AND name=?"
,
};
...
...
@@ -439,6 +442,58 @@ sticker_delete(const char *type, const char *uri)
return
true
;
}
bool
sticker_delete_value
(
const
char
*
type
,
const
char
*
uri
,
const
char
*
name
)
{
sqlite3_stmt
*
const
stmt
=
sticker_stmt
[
STICKER_SQL_DELETE_VALUE
];
int
ret
;
assert
(
sticker_enabled
());
assert
(
type
!=
NULL
);
assert
(
uri
!=
NULL
);
sqlite3_reset
(
stmt
);
ret
=
sqlite3_bind_text
(
stmt
,
1
,
type
,
-
1
,
NULL
);
if
(
ret
!=
SQLITE_OK
)
{
g_warning
(
"sqlite3_bind_text() failed: %s"
,
sqlite3_errmsg
(
sticker_db
));
return
false
;
}
ret
=
sqlite3_bind_text
(
stmt
,
2
,
uri
,
-
1
,
NULL
);
if
(
ret
!=
SQLITE_OK
)
{
g_warning
(
"sqlite3_bind_text() failed: %s"
,
sqlite3_errmsg
(
sticker_db
));
return
false
;
}
ret
=
sqlite3_bind_text
(
stmt
,
3
,
name
,
-
1
,
NULL
);
if
(
ret
!=
SQLITE_OK
)
{
g_warning
(
"sqlite3_bind_text() failed: %s"
,
sqlite3_errmsg
(
sticker_db
));
return
false
;
}
do
{
ret
=
sqlite3_step
(
stmt
);
}
while
(
ret
==
SQLITE_BUSY
);
if
(
ret
!=
SQLITE_DONE
)
{
g_warning
(
"sqlite3_step() failed: %s"
,
sqlite3_errmsg
(
sticker_db
));
return
false
;
}
ret
=
sqlite3_changes
(
sticker_db
);
sqlite3_reset
(
stmt
);
sqlite3_clear_bindings
(
stmt
);
idle_add
(
IDLE_STICKER
);
return
ret
>
0
;
}
static
struct
sticker
*
sticker_new
(
void
)
{
...
...
src/sticker.h
View file @
610940a0
...
...
@@ -89,6 +89,13 @@ bool
sticker_delete
(
const
char
*
type
,
const
char
*
uri
);
/**
* Deletes a sticker value. Fails if no sticker with this name
* exists.
*/
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
...
...
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