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