sticker: convert to C++
This commit is contained in:
parent
8331de424a
commit
9ceb8a717a
@ -162,12 +162,9 @@ mpd_headers = \
|
||||
src/sig_handlers.h \
|
||||
src/TimePrint.cxx src/TimePrint.hxx \
|
||||
src/song.h \
|
||||
src/song_sticker.h \
|
||||
src/song_sort.c src/song_sort.h \
|
||||
src/socket_util.h \
|
||||
src/stats.h \
|
||||
src/sticker.h \
|
||||
src/sticker_print.h \
|
||||
src/tag.h \
|
||||
src/tag_internal.h \
|
||||
src/tag_pool.h \
|
||||
@ -366,9 +363,9 @@ endif
|
||||
if ENABLE_SQLITE
|
||||
src_mpd_SOURCES += \
|
||||
src/StickerCommands.cxx src/StickerCommands.hxx \
|
||||
src/sticker.c \
|
||||
src/sticker_print.c \
|
||||
src/song_sticker.c
|
||||
src/StickerDatabase.cxx src/StickerDatabase.hxx \
|
||||
src/StickerPrint.cxx src/StickerPrint.hxx \
|
||||
src/SongSticker.cxx src/SongSticker.hxx
|
||||
endif
|
||||
|
||||
# Generic utility library
|
||||
|
@ -29,7 +29,6 @@ extern "C" {
|
||||
#include "PlaylistCommands.hxx"
|
||||
#include "DatabaseCommands.hxx"
|
||||
#include "OutputCommands.hxx"
|
||||
#include "StickerCommands.hxx"
|
||||
#include "MessageCommands.hxx"
|
||||
#include "OtherCommands.hxx"
|
||||
#include "permission.h"
|
||||
@ -39,11 +38,12 @@ extern "C" {
|
||||
#include "protocol/result.h"
|
||||
#include "tokenizer.h"
|
||||
#include "client.h"
|
||||
}
|
||||
|
||||
#ifdef ENABLE_SQLITE
|
||||
#include "sticker.h"
|
||||
#include "StickerCommands.hxx"
|
||||
#include "StickerDatabase.hxx"
|
||||
#endif
|
||||
}
|
||||
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
|
@ -63,16 +63,14 @@ extern "C" {
|
||||
#include "InotifyUpdate.hxx"
|
||||
#endif
|
||||
|
||||
extern "C" {
|
||||
|
||||
#ifdef ENABLE_SQLITE
|
||||
#include "sticker.h"
|
||||
#include "StickerDatabase.hxx"
|
||||
#endif
|
||||
|
||||
extern "C" {
|
||||
#ifdef ENABLE_ARCHIVE
|
||||
#include "archive_list.h"
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#include <glib.h>
|
||||
|
@ -50,7 +50,7 @@ extern "C" {
|
||||
}
|
||||
|
||||
#ifdef ENABLE_SQLITE
|
||||
#include "sticker.h"
|
||||
#include "StickerDatabase.hxx"
|
||||
#endif
|
||||
|
||||
#include <assert.h>
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2003-2011 The Music Player Daemon Project
|
||||
* Copyright (C) 2003-2013 The Music Player Daemon Project
|
||||
* http://www.musicpd.org
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@ -18,10 +18,10 @@
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "song_sticker.h"
|
||||
#include "SongSticker.hxx"
|
||||
#include "StickerDatabase.hxx"
|
||||
#include "song.h"
|
||||
#include "directory.h"
|
||||
#include "sticker.h"
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
@ -121,7 +121,8 @@ struct sticker_song_find_data {
|
||||
static void
|
||||
sticker_song_find_cb(const char *uri, const char *value, gpointer user_data)
|
||||
{
|
||||
struct sticker_song_find_data *data = user_data;
|
||||
struct sticker_song_find_data *data =
|
||||
(struct sticker_song_find_data *)user_data;
|
||||
struct song *song;
|
||||
|
||||
if (memcmp(uri, data->base_uri, data->base_uri_length) != 0)
|
||||
@ -140,14 +141,12 @@ sticker_song_find(struct directory *directory, const char *name,
|
||||
gpointer user_data),
|
||||
gpointer user_data)
|
||||
{
|
||||
struct sticker_song_find_data data = {
|
||||
.directory = directory,
|
||||
.func = func,
|
||||
.user_data = user_data,
|
||||
};
|
||||
char *allocated;
|
||||
bool success;
|
||||
struct sticker_song_find_data data;
|
||||
data.directory = directory;
|
||||
data.func = func;
|
||||
data.user_data = user_data;
|
||||
|
||||
char *allocated;
|
||||
data.base_uri = directory_get_path(directory);
|
||||
if (*data.base_uri != 0)
|
||||
/* append slash to base_uri */
|
||||
@ -159,8 +158,8 @@ sticker_song_find(struct directory *directory, const char *name,
|
||||
|
||||
data.base_uri_length = strlen(data.base_uri);
|
||||
|
||||
success = sticker_find("song", data.base_uri, name,
|
||||
sticker_song_find_cb, &data);
|
||||
bool success = sticker_find("song", data.base_uri, name,
|
||||
sticker_song_find_cb, &data);
|
||||
g_free(allocated);
|
||||
|
||||
return success;
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2003-2011 The Music Player Daemon Project
|
||||
* Copyright (C) 2003-2013 The Music Player Daemon Project
|
||||
* http://www.musicpd.org
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@ -17,10 +17,9 @@
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#ifndef SONG_STICKER_H
|
||||
#define SONG_STICKER_H
|
||||
#ifndef MPD_SONG_STICKER_HXX
|
||||
#define MPD_SONG_STICKER_HXX
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <glib.h>
|
||||
|
||||
struct song;
|
@ -21,12 +21,12 @@
|
||||
#include "StickerCommands.hxx"
|
||||
#include "SongPrint.hxx"
|
||||
#include "DatabaseLock.hxx"
|
||||
#include "SongSticker.hxx"
|
||||
#include "StickerPrint.hxx"
|
||||
#include "StickerDatabase.hxx"
|
||||
|
||||
extern "C" {
|
||||
#include "protocol/result.h"
|
||||
#include "sticker.h"
|
||||
#include "sticker_print.h"
|
||||
#include "song_sticker.h"
|
||||
#include "database.h"
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2003-2011 The Music Player Daemon Project
|
||||
* Copyright (C) 2003-2013 The Music Player Daemon Project
|
||||
* http://www.musicpd.org
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@ -18,8 +18,11 @@
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "sticker.h"
|
||||
#include "StickerDatabase.hxx"
|
||||
|
||||
extern "C" {
|
||||
#include "idle.h"
|
||||
}
|
||||
|
||||
#include <glib.h>
|
||||
#include <sqlite3.h>
|
||||
@ -47,19 +50,19 @@ enum sticker_sql {
|
||||
};
|
||||
|
||||
static const char *const sticker_sql[] = {
|
||||
[STICKER_SQL_GET] =
|
||||
//[STICKER_SQL_GET] =
|
||||
"SELECT value FROM sticker WHERE type=? AND uri=? AND name=?",
|
||||
[STICKER_SQL_LIST] =
|
||||
//[STICKER_SQL_LIST] =
|
||||
"SELECT name,value FROM sticker WHERE type=? AND uri=?",
|
||||
[STICKER_SQL_UPDATE] =
|
||||
//[STICKER_SQL_UPDATE] =
|
||||
"UPDATE sticker SET value=? WHERE type=? AND uri=? AND name=?",
|
||||
[STICKER_SQL_INSERT] =
|
||||
//[STICKER_SQL_INSERT] =
|
||||
"INSERT INTO sticker(type,uri,name,value) VALUES(?, ?, ?, ?)",
|
||||
[STICKER_SQL_DELETE] =
|
||||
//[STICKER_SQL_DELETE] =
|
||||
"DELETE FROM sticker WHERE type=? AND uri=?",
|
||||
[STICKER_SQL_DELETE_VALUE] =
|
||||
//[STICKER_SQL_DELETE_VALUE] =
|
||||
"DELETE FROM sticker WHERE type=? AND uri=? AND name=?",
|
||||
[STICKER_SQL_FIND] =
|
||||
//[STICKER_SQL_FIND] =
|
||||
"SELECT uri,value FROM sticker WHERE type=? AND uri LIKE (? || '%') AND name=?",
|
||||
};
|
||||
|
||||
@ -541,7 +544,7 @@ sticker_free(struct sticker *sticker)
|
||||
const char *
|
||||
sticker_get_value(const struct sticker *sticker, const char *name)
|
||||
{
|
||||
return g_hash_table_lookup(sticker->table, name);
|
||||
return (const char *)g_hash_table_lookup(sticker->table, name);
|
||||
}
|
||||
|
||||
struct sticker_foreach_data {
|
||||
@ -553,9 +556,10 @@ struct sticker_foreach_data {
|
||||
static void
|
||||
sticker_foreach_func(gpointer key, gpointer value, gpointer user_data)
|
||||
{
|
||||
struct sticker_foreach_data *data = user_data;
|
||||
struct sticker_foreach_data *data =
|
||||
(struct sticker_foreach_data *)user_data;
|
||||
|
||||
data->func(key, value, data->user_data);
|
||||
data->func((const char *)key, (const char *)value, data->user_data);
|
||||
}
|
||||
|
||||
void
|
||||
@ -564,10 +568,9 @@ sticker_foreach(const struct sticker *sticker,
|
||||
gpointer user_data),
|
||||
gpointer user_data)
|
||||
{
|
||||
struct sticker_foreach_data data = {
|
||||
.func = func,
|
||||
.user_data = user_data,
|
||||
};
|
||||
struct sticker_foreach_data data;
|
||||
data.func = func;
|
||||
data.user_data = user_data;
|
||||
|
||||
g_hash_table_foreach(sticker->table, sticker_foreach_func, &data);
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2003-2011 The Music Player Daemon Project
|
||||
* Copyright (C) 2003-2013 The Music Player Daemon Project
|
||||
* http://www.musicpd.org
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@ -39,13 +39,11 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef STICKER_H
|
||||
#define STICKER_H
|
||||
#ifndef MPD_STICKER_DATABASE_HXX
|
||||
#define MPD_STICKER_DATABASE_HXX
|
||||
|
||||
#include "gerror.h"
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
struct sticker;
|
||||
|
||||
/**
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2003-2011 The Music Player Daemon Project
|
||||
* Copyright (C) 2003-2013 The Music Player Daemon Project
|
||||
* http://www.musicpd.org
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@ -18,9 +18,12 @@
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "sticker_print.h"
|
||||
#include "sticker.h"
|
||||
#include "StickerPrint.hxx"
|
||||
#include "StickerDatabase.hxx"
|
||||
|
||||
extern "C" {
|
||||
#include "client.h"
|
||||
}
|
||||
|
||||
void
|
||||
sticker_print_value(struct client *client,
|
||||
@ -32,7 +35,7 @@ sticker_print_value(struct client *client,
|
||||
static void
|
||||
print_sticker_cb(const char *name, const char *value, void *data)
|
||||
{
|
||||
struct client *client = data;
|
||||
struct client *client = (struct client *)data;
|
||||
|
||||
sticker_print_value(client, name, value);
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2003-2011 The Music Player Daemon Project
|
||||
* Copyright (C) 2003-2013 The Music Player Daemon Project
|
||||
* http://www.musicpd.org
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@ -17,8 +17,8 @@
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#ifndef MPD_STICKER_PRINT_H
|
||||
#define MPD_STICKER_PRINT_H
|
||||
#ifndef MPD_STICKER_PRINT_HXX
|
||||
#define MPD_STICKER_PRINT_HXX
|
||||
|
||||
struct sticker;
|
||||
struct client;
|
@ -29,10 +29,8 @@ extern "C" {
|
||||
#include "Main.hxx"
|
||||
|
||||
#ifdef ENABLE_SQLITE
|
||||
extern "C" {
|
||||
#include "sticker.h"
|
||||
#include "song_sticker.h"
|
||||
}
|
||||
#include "StickerDatabase.hxx"
|
||||
#include "SongSticker.hxx"
|
||||
#endif
|
||||
|
||||
#include <glib.h>
|
||||
|
Loading…
Reference in New Issue
Block a user