Merge pull request #123 from chme/mpdprotocol

[mpd] add IPv6 support and a little cleanup in db upgrade v16
This commit is contained in:
ejurgensen 2015-03-20 23:47:34 +01:00
commit 1a96f651d2
2 changed files with 30 additions and 12 deletions

View File

@ -5674,11 +5674,11 @@ db_upgrade_v16(void)
char *title;
int id;
char *path;
int data_kind;
int type;
char virtual_path[PATH_MAX];
int ret;
query = "SELECT id, album_artist, album, title, path, data_kind FROM files;";
query = "SELECT id, album_artist, album, title, path FROM files;";
DPRINTF(E_DBG, L_DB, "Running query '%s'\n", query);
@ -5696,7 +5696,6 @@ db_upgrade_v16(void)
album = (char *)sqlite3_column_text(stmt, 2);
title = (char *)sqlite3_column_text(stmt, 3);
path = (char *)sqlite3_column_text(stmt, 4);
data_kind = sqlite3_column_int(stmt, 5);
if (strncmp(path, "http:", strlen("http:")) == 0)
{
@ -5741,9 +5740,9 @@ db_upgrade_v16(void)
id = sqlite3_column_int(stmt, 0);
title = (char *)sqlite3_column_text(stmt, 1);
path = (char *)sqlite3_column_text(stmt, 2);
data_kind = sqlite3_column_int(stmt, 3);
type = sqlite3_column_int(stmt, 3);
if (data_kind == 0) /* Excludes default playlists */
if (type == 0) /* Excludes default playlists */
{
if (strncmp(path, "spotify:", strlen("spotify:")) == 0)
{

View File

@ -3673,10 +3673,15 @@ mpd_accept_error_cb(struct evconnlistener *listener, void *ctx)
int mpd_init(void)
{
struct evconnlistener *listener;
struct sockaddr *saddr;
size_t saddr_length;
struct sockaddr_in sin;
struct sockaddr_in6 sin6;
unsigned short port;
int v6enabled;
int ret;
port = cfg_getint(cfg_getsec(cfg, "mpd"), "port");
if (port <= 0)
{
@ -3684,6 +3689,8 @@ int mpd_init(void)
return 0;
}
v6enabled = cfg_getbool(cfg_getsec(cfg, "general"), "ipv6");
# if defined(__linux__)
ret = pipe2(g_exit_pipe, O_CLOEXEC);
# else
@ -3711,11 +3718,23 @@ int mpd_init(void)
event_add(g_exitev, NULL);
//TODO ipv6
memset(&sin, 0, sizeof(sin));
sin.sin_family = AF_INET;
sin.sin_addr.s_addr = htonl(0);
sin.sin_port = htons(port);
if (v6enabled)
{
saddr_length = sizeof(sin6);
memset(&sin6, 0, saddr_length);
sin6.sin6_family = AF_INET6;
sin6.sin6_port = htons(port);
saddr = (struct sockaddr *)&sin6;
}
else
{
saddr_length = sizeof(struct sockaddr_in);
memset(&sin, 0, saddr_length);
sin.sin_family = AF_INET;
sin.sin_addr.s_addr = htonl(0);
sin.sin_port = htons(port);
saddr = (struct sockaddr *)&sin;
}
listener = evconnlistener_new_bind(
evbase_mpd,
@ -3723,8 +3742,8 @@ int mpd_init(void)
NULL,
LEV_OPT_CLOSE_ON_FREE | LEV_OPT_REUSEABLE,
-1,
(struct sockaddr*) &sin,
sizeof(sin));
saddr,
saddr_length);
if (!listener)
{