1
0
mirror of https://github.com/SuperBFG7/ympd synced 2024-11-05 22:36:16 +00:00

Feat: disable playlists and browse database feature if not enabled in mpd #68 #69

This commit is contained in:
jcorporation 2018-10-25 21:03:33 +01:00
parent c5856c0cbd
commit 58d1782cf7
4 changed files with 178 additions and 80 deletions

View File

@ -28,7 +28,7 @@
<div class="collapse" id="menu-dbupdate">
<a class="dropdown-item text-light bg-dark" href="#" data-href='{"cmd": "updateDB", "options": []}'>Update Database</a>
<a class="dropdown-item text-light bg-dark" href="#" data-href='{"cmd": "rescanDB", "options": []}'>Rescan Database</a>
<a class="dropdown-item text-light bg-dark" href="#" data-href='{"cmd": "updateSmartPlaylists", "options": []}'>Update Smart Playlists</a>
<a class="dropdown-item text-light bg-dark featSmartpls" href="#" data-href='{"cmd": "updateSmartPlaylists", "options": []}'>Update Smart Playlists</a>
</div>
<a class="dropdown-item text-light bg-dark" href="#" data-href='{"cmd": "openLocalPlayer", "options": []}'>Local Player</a>
<a class="dropdown-item text-light bg-dark" href="#" data-toggle="modal" data-target="#modalSettings">Settings</a>
@ -81,7 +81,7 @@
<div class="card" id="cardPlayback">
<div class="card-header">Playback
<div class="btn-group btn-group-sm stickers pull-right">
<div class="btn-group btn-group-sm featStickers pull-right">
<button title="Dislike song" id="btnVoteDown" data-href='{"cmd": "voteSong", "options": [0]}' class="btn btn-sm btn-light material-icons">thumb_down</button>
<button title="Like song" id="btnVoteUp" data-href='{"cmd": "voteSong", "options": [2]}' class="btn btn-sm btn-light material-icons">thumb_up</button>
</div>
@ -90,10 +90,12 @@
<div class="album-cover" id="currentCover"></div>
<div class="album-desc">
<h2 id="currentTrack" data-href='{"cmd": "songClick", "options": []}'></h2>
<small>Artist</small>
<h4 id="currentArtist" data-href='{"cmd": "artistClick", "options": []}'></h4>
<small>Album</small>
<h4 id="currentAlbum" data-href='{"cmd": "albumClick", "options": []}'></h4>
<div class="featTags">
<small>Artist</small>
<h4 id="currentArtist" data-href='{"cmd": "artistClick", "options": []}'></h4>
<small>Album</small>
<h4 id="currentAlbum" data-href='{"cmd": "albumClick", "options": []}'></h4>
</div>
</div>
</div>
<div class="card-footer card-footer-playback">
@ -111,7 +113,7 @@
</div>
<div class="card-body">
<div class="btn-toolbar card-toolbar" id="queue-buttons">
<div class="btn-group mr-2">
<div class="btn-group mr-2 featPlaylists">
<button type="button" class="btn btn-secondary material-icons" data-toggle="modal" data-target="#modalSaveQueue" title="Save queue">
save
</button>
@ -199,10 +201,10 @@
<div class="card hide" id="cardBrowse">
<div class="card-header" id="panel-heading-browse">
<ul class="nav nav-tabs card-header-tabs">
<li class="nav-item">
<li class="nav-item featTags">
<a data-href='{"cmd": "appGoto", "options": ["Browse", "Database"]}' class="nav-link text-dark" href="#" id="cardBrowseNavDatabase">Database</a>
</li>
<li class="nav-item">
<li class="nav-item featPlaylists">
<a data-href='{"cmd": "appGoto", "options": ["Browse", "Playlists"]}' class="nav-link text-dark" href="#" id="cardBrowseNavPlaylists">Playlists</a>
</li>
<li class="nav-item">
@ -310,7 +312,7 @@
<button id="BrowseDatabaseAddAllSongsBtn" class="btn btn-secondary dropdown-toggle dropdown-toggle-split rounded-right" type="button" data-toggle="dropdown"></button>
<div class="dropdown-menu bg-dark dropdown-menu-right px-2" id="BrowseDatabaseAddAllSongsDropdown">
<button type="button" class="btn btn-secondary btn-sm btn-block">Add all to queue</button>
<button type="button" class="btn btn-secondary btn-sm btn-block">Add all to playlist</button>
<button type="button" class="btn btn-secondary btn-sm btn-block featPlaylists">Add all to playlist</button>
</div>
</div>
</div>
@ -375,7 +377,7 @@
<button id="BrowseFilesystemAddAllSongsBtn" class="btn btn-secondary dropdown-toggle dropdown-toggle-split rounded-right" type="button" data-toggle="dropdown"></button>
<div class="dropdown-menu bg-dark dropdown-menu-right px-2" id="BrowseFilesystemAddAllSongsDropdown">
<button type="button" class="btn btn-secondary btn-sm btn-block">Add all to queue</button>
<button type="button" class="btn btn-secondary btn-sm btn-block">Add all to playlist</button>
<button type="button" class="btn btn-secondary btn-sm btn-block featPlaylists">Add all to playlist</button>
</div>
</div>
</div>
@ -460,8 +462,8 @@
<button id="searchAddAllSongsBtn" class="btn btn-secondary dropdown-toggle dropdown-toggle-split rounded-right" type="button" data-toggle="dropdown"></button>
<div class="dropdown-menu bg-dark dropdown-menu-right px-2" id="searchAddAllSongsDropdown">
<button type="button" class="btn btn-secondary btn-sm btn-block">Add all to queue</button>
<button type="button" class="btn btn-secondary btn-sm btn-block">Add all to playlist</button>
<button type="button" class="btn btn-secondary btn-sm btn-block smartpls">Save as smart playlist</button>
<button type="button" class="btn btn-secondary btn-sm btn-block featPlaylists">Add all to playlist</button>
<button type="button" class="btn btn-secondary btn-sm btn-block featSmartpls">Save as smart playlist</button>
</div>
</div>
</div>
@ -580,7 +582,7 @@
<div class="invalid-feedback">Invalid uri</div>
</div>
</div>
<div class="row">
<div class="row featPlaylists">
<div class="form-group col-md-12">
<button id="toggleAddToPlaylistBtn" class="btn btn-secondary" data-href='{"cmd": "toggleAddToPlaylistFrm", "options":[]}'>Add to playlist</button>
</div>

View File

@ -943,6 +943,24 @@ function toggleBtn(btn, state) {
b.classList.remove('active');
}
function filterCols(x) {
var tags = settings.tags.slice();
if (settings.featTags == false)
tags.push('Title');
tags.push('Duration');
if (x == 'colsQueue' || x == 'colsBrowsePlaylistsDetail')
tags.push('Pos');
if (x == 'colsBrowseFilesystem')
tags.push('Type');
var cols = [];
for (var i = 0; i < settings[x].length; i++) {
if (tags.includes(settings[x][i]))
cols.push(settings[x][i]);
}
settings[x] = cols;
}
function parseSettings(obj) {
toggleBtn('btnRandom', obj.data.random);
toggleBtn('btnConsume', obj.data.consume);
@ -995,18 +1013,21 @@ function parseSettings(obj) {
toggleBtn('btnnotifyPage', obj.data.notificationPage);
var stickerEls = document.getElementsByClassName('stickers');
var stickerElsLen = stickerEls.length;
var displayStickers = obj.data.stickers == true ? '' : 'none';
for (var i = 0; i < stickerElsLen; i++)
stickerEls[i].style.display = displayStickers;
var smartplsEls = document.getElementsByClassName('smartpls');
var smartplsElsLen = smartplsEls.length;
var displaySmartpls = obj.data.smartpls == true ? '' : 'none';
for (var i = 0; i < smartplsElsLen; i++)
smartplsEls[i].style.display = displaySmartpls;
var features = ["featStickers", "featSmartpls", "featPlaylists", "featTags"];
for (var j = 0; j < features.length; j++) {
var Els = document.getElementsByClassName(features[j]);
var ElsLen = Els.length;
var displayEl = obj.data[features[j]] == true ? '' : 'none';
for (var i = 0; i < ElsLen; i++)
Els[i].style.display = displayEl;
}
if (obj.data.featTags == false) {
app.apps.Browse.active = 'Filesystem';
app.apps.Search.state = '0/filename/';
}
if (obj.data.mixramp == true)
document.getElementsByClassName('mixramp')[0].style.display = '';
else
@ -1025,8 +1046,17 @@ function parseSettings(obj) {
settings = obj.data;
playlistEl = 'selectJukeboxPlaylist';
sendAPI({"cmd": "MPD_API_PLAYLIST_LIST", "data": {"offset": 0, "filter": "-"}}, getAllPlaylists);
if (obj.data.featPlaylists) {
playlistEl = 'selectJukeboxPlaylist';
sendAPI({"cmd": "MPD_API_PLAYLIST_LIST", "data": {"offset": 0, "filter": "-"}}, getAllPlaylists);
} else {
document.getElementById('selectJukeboxPlaylist').innerHTML = '<option>Database</option>';
}
filterCols('colsSearch');
filterCols('colsQueue');
filterCols('colsBrowsePlaylistsDetail');
filterCols('colsBrowseFilesystem');
settings.mpdstream = 'http://';
if (settings.mpdhost == '127.0.0.1' || settings.mpdhost == 'localhost')
@ -1069,9 +1099,13 @@ function parseSettings(obj) {
function setCols(table) {
var tagChks = '';
var tags = settings.tags.slice();
if (settings.featTags == false)
tags.push('Title');
tags.push('Duration');
if (table == 'Queue' || table == 'BrowsePlaylistsDetail')
tags.push('Pos');
if (table == 'BrowseFilesystem')
tags.push('Type');
for (var i = 0; i < tags.length; i++) {
tagChks += '<div class="form-check">' +
@ -1086,11 +1120,13 @@ function setCols(table) {
var heading = '';
for (var i = 0; i < settings['cols' + table].length; i++) {
var h = settings['cols' + table][i];
heading += '<th draggable="true" data-col="' + h + '">';
if (h == 'Track' || h == 'Pos')
h = '#';
heading += h + '</th>';
// if (tags.includes(settings['cols' + table][i])) {
var h = settings['cols' + table][i];
heading += '<th draggable="true" data-col="' + h + '">';
if (h == 'Track' || h == 'Pos')
h = '#';
heading += h + '</th>';
// }
}
heading += '<th></th>';
document.getElementById(table + 'List').getElementsByTagName('tr')[0].innerHTML = heading;
@ -1183,7 +1219,6 @@ function setCounter(currentSongId, totalTime, elapsedTime) {
if (!posTd.classList.contains('material-icons')) {
posTd.classList.add('material-icons');
posTd.innerText = 'play_arrow';
console.log('A');
}
}
tr.classList.add('font-weight-bold');
@ -1377,9 +1412,23 @@ function parseFilesystem(obj) {
switch(obj.data[i].Type) {
case 'dir':
row.innerHTML = '<td><span class="material-icons">folder_open</span></td>' +
'<td colspan="' + colspan + '">' + obj.data[i].name + '</td>' +
'<td><a href="#" class="material-icons color-darkgrey">playlist_add</a></td>';
case 'smartpls':
case 'plist':
var tds = '';
for (var c = 0; c < settings['cols' + list].length; c++) {
tds += '<td data-col="' + settings['cols' + list][c] + '">';
if (settings['cols' + list][c] == 'Type') {
if (obj.data[i].Type == 'dir')
tds += '<span class="material-icons">folder_open</span>';
else
tds += '<span class="material-icons">list</span>';
}
else if (settings['cols' + list][c] == 'Title')
tds += obj.data[i].name;
tds += '</td>';
}
tds += '<td data-col="Action"><a href="#" class="material-icons color-darkgrey">playlist_add</a></td>';
row.innerHTML = tds;
break;
case 'song':
var minutes = Math.floor(obj.data[i].Duration / 60);
@ -1397,12 +1446,6 @@ function parseFilesystem(obj) {
tds += '<td data-col="Action"><a href="#" class="material-icons color-darkgrey">playlist_add</a></td>';
row.innerHTML = tds;
break;
case 'smartpls':
case 'plist':
row.innerHTML = '<td data-col="Type"><span class="material-icons">list</span></td>' +
'<td colspan="' + colspan + '">' + obj.data[i].name + '</td>' +
'<td data-col="Action"><a href="#" class="material-icons color-darkgrey">playlist_add</a></td>';
break;
}
if (i < tr.length)
tr[i].replaceWith(row);
@ -1801,7 +1844,7 @@ function parseSongDetails(obj) {
songDetails += '<tr><th>Uri</th><td><a class="text-success" href="/library/' + obj.data.uri + '">' + obj.data.uri + '</a></td></tr>';
if (settings.stickers == true) {
if (settings.featStickers == true) {
var like = 'not voted';
if (obj.data.like == 0)
like = '<span class="material-icons">thumb_down_alt</span>';
@ -1943,7 +1986,7 @@ function parseSmartPlaylist(obj) {
}
else if (obj.data.type == 'sticker') {
document.getElementById('saveSmartPlaylistSticker').classList.remove('hide');
document.getElementById('selectSaveSmartPlaylistSticker').value = obj.data.sticker;
document.getElementById('selectSaveSmartPlaylistSticker').value = obj.data.feat_sticker;
document.getElementById('inputSaveSmartPlaylistStickerMaxentries').value = obj.data.maxentries;
}
else if (obj.data.type == 'newest') {
@ -2033,8 +2076,10 @@ function showAddToPlaylist(uri) {
document.getElementById('addToPlaylistLabel').innerText = 'Add Stream';
}
modalAddToPlaylist.show();
playlistEl = 'addToPlaylistPlaylist';
sendAPI({"cmd": "MPD_API_PLAYLIST_LIST","data": {"offset": 0, "filter": "-"}}, getAllPlaylists);
if (settings.featPlaylists) {
playlistEl = 'addToPlaylistPlaylist';
sendAPI({"cmd": "MPD_API_PLAYLIST_LIST","data": {"offset": 0, "filter": "-"}}, getAllPlaylists);
}
}
function addToPlaylist() {
@ -2172,7 +2217,7 @@ function showMenu(el, event) {
menu += addMenuItem({"cmd": "appendQueue", "options": [type, uri, name]}, 'Append to queue') +
(type == 'song' ? addMenuItem({"cmd": "appendAfterQueue", "options": [type, uri, nextsongpos, name]}, 'Add after current playing song') : '') +
addMenuItem({"cmd": "replaceQueue", "options": [type, uri, name]}, 'Replace queue') +
(type != 'plist' && type != 'smartpls' ? addMenuItem({"cmd": "showAddToPlaylist", "options": [uri]}, 'Add to playlist') : '') +
(type != 'plist' && type != 'smartpls' && settings.featPlaylists ? addMenuItem({"cmd": "showAddToPlaylist", "options": [uri]}, 'Add to playlist') : '') +
(type == 'song' ? addMenuItem({"cmd": "songDetails", "options": [uri]}, 'Songdetails') : '') +
(type == 'plist' || type == 'smartpls' ? addMenuItem({"cmd": "playlistDetails", "options": [uri]}, 'View playlist') : '');
if (app.current.app == 'Search') {
@ -2183,7 +2228,7 @@ function showMenu(el, event) {
addMenuItem({"cmd": "appendQueue", "options": [type, baseuri, name]}, 'Append to queue') +
addMenuItem({"cmd": "appendAfterQueue", "options": [type, baseuri, nextsongpos, name]}, 'Add after current playing song') +
addMenuItem({"cmd": "replaceQueue", "options": [type, baseuri, name]}, 'Replace queue') +
addMenuItem({"cmd": "showAddToPlaylist", "options": [baseuri]}, 'Add to playlist') +
(settings.featPlaylists ? addMenuItem({"cmd": "showAddToPlaylist", "options": [baseuri]}, 'Add to playlist') : '') +
'</div>';
}
}
@ -2582,7 +2627,7 @@ function songChange(obj) {
document.title = pageTitle;
if (settings.stickers == true) {
if (settings.featStickers == true) {
setVoteSongBtns(obj.data.like, obj.data.uri);
}
@ -2656,8 +2701,12 @@ function selectTag(btnsEl, desc, setTo) {
function addTagList(x, any) {
var tagList = '';
var tagBlacklist = ["Title", "MUSICBRAINZ_TRACKID", "Count", "Disc", "Comment", "Name"];
if (any == true)
tagList += '<button type="button" class="btn btn-secondary btn-sm btn-block" data-tag="any">Any Tag</button>';
if (any == true) {
if (settings.featTags == true)
tagList += '<button type="button" class="btn btn-secondary btn-sm btn-block" data-tag="any">Any Tag</button>';
else
tagList += '<button type="button" class="btn btn-secondary btn-sm btn-block" data-tag="filename">Filename</button>';
}
for (var i = 0; i < settings.tags.length; i++) {
if (settings.tags[i] == 'Track')
continue;

View File

@ -726,11 +726,15 @@ void mympd_mpd_features() {
// Defaults
mpd.feat_sticker = false;
mpd.feat_playlists = false;
mpd.feat_tags = false;
mpd_send_allowed_commands(mpd.conn);
while ((pair = mpd_recv_command_pair(mpd.conn)) != NULL) {
if (strcmp(pair->value, "sticker") == 0)
mpd.feat_sticker = true;
if (strcmp(pair->value, "listplaylists") == 0)
mpd.feat_playlists = true;
mpd_return_pair(mpd.conn, pair);
}
mpd_response_finish(mpd.conn);
@ -743,7 +747,11 @@ void mympd_mpd_features() {
printf("Stickers are disabled, disabling smartplaylists\n");
config.smartpls = false;
}
if (mpd.feat_playlists == false && config.smartpls == true) {
printf("Playlists are disabled, disabling smartplaylists\n");
config.smartpls = false;
}
printf("MPD supported tags: ");
list_free(&mpd_tags);
mpd_send_list_tag_types(mpd.conn);
@ -753,19 +761,25 @@ void mympd_mpd_features() {
mpd_return_pair(mpd.conn, pair);
}
mpd_response_finish(mpd.conn);
printf("\nmyMPD enabled tags: ");
list_free(&mympd_tags);
token = strtok(str, s);
while (token != NULL) {
if (list_get_value(&mpd_tags, token) == 1) {
list_push(&mympd_tags, token, 1);
printf("%s ", token);
if (mpd_tags.length == 0) {
printf("none\nTags are disabled\n");
mpd.feat_tags = false;
}
else {
mpd.feat_tags = true;
printf("\nmyMPD enabled tags: ");
token = strtok(str, s);
while (token != NULL) {
if (list_get_value(&mpd_tags, token) == 1) {
list_push(&mympd_tags, token, 1);
printf("%s ", token);
}
token = strtok(NULL, s);
}
token = strtok(NULL, s);
}
printf("\n");
free(str);
printf("\n");
}
free(str);
}
void mympd_idle(struct mg_mgr *s, int timeout) {
@ -1015,6 +1029,11 @@ void mympd_jukebox() {
if (addSongs < 1)
return;
if (mpd.feat_playlists == false && strcmp(mympd_state.jukeboxPlaylist, "Database") != 0) {
printf("Jukebox: Playlists are disabled\n");
return;
}
srand((unsigned int)time(NULL));
@ -1025,7 +1044,7 @@ void mympd_jukebox() {
//add songs
if (strcmp(mympd_state.jukeboxPlaylist, "Database") == 0) {
if (!mpd_send_list_all(mpd.conn, "/")) {
LOG_ERROR_AND_RECOVER("mpd_send_list_playlist");
LOG_ERROR_AND_RECOVER("mpd_send_list_all");
list_free(&add_list);
return;
}
@ -1067,12 +1086,12 @@ void mympd_jukebox() {
else if (mympd_state.jukeboxMode == 2) {
//add album
if (!mpd_search_db_tags(mpd.conn, MPD_TAG_ALBUM)) {
LOG_ERROR_AND_RECOVER("mpd_send_list_playlist");
LOG_ERROR_AND_RECOVER("mpd_search_db_tags");
list_free(&add_list);
return;
}
if (!mpd_search_commit(mpd.conn)) {
LOG_ERROR_AND_RECOVER("mpd_send_list_playlist");
LOG_ERROR_AND_RECOVER("mpd_search_commit");
list_free(&add_list);
return;
}
@ -1305,8 +1324,8 @@ int mympd_put_settings(char *buffer) {
len = json_printf(&out, "{type: settings, data: {"
"repeat: %d, single: %d, crossfade: %d, consume: %d, random: %d, "
"mixrampdb: %f, mixrampdelay: %f, mpdhost: %Q, mpdport: %d, passwort_set: %B, "
"streamport: %d, coverimage: %Q, stickers: %B, mixramp: %B, smartpls: %B, maxElementsPerPage: %d, "
"mixrampdb: %f, mixrampdelay: %f, mpdhost: %Q, mpdport: %d, passwort_set: %B, featPlaylists: %B, featTags: %B, "
"streamport: %d, coverimage: %Q, featStickers: %B, mixramp: %B, featSmartpls: %B, maxElementsPerPage: %d, "
"replaygain: %Q, notificationWeb: %B, notificationPage: %B, jukeboxMode: %d, jukeboxPlaylist: %Q, jukeboxQueueLength: %d, "
"tags: [",
mpd_status_get_repeat(status),
@ -1319,6 +1338,8 @@ int mympd_put_settings(char *buffer) {
config.mpdhost,
config.mpdport,
config.mpdpass ? "true" : "false",
mpd.feat_playlists,
mpd.feat_tags,
config.streamport,
config.coverimage,
config.stickers,
@ -1457,7 +1478,10 @@ int mympd_put_current_song(char *buffer) {
mpd.song_id,
cover
);
PUT_SONG_TAGS();
if (mpd.feat_tags == true)
PUT_SONG_TAGS();
else
PUT_MIN_SONG_TAGS();
mpd_response_finish(mpd.conn);
@ -1493,7 +1517,10 @@ int mympd_put_songdetails(char *buffer, char *uri) {
song = mpd_entity_get_song(entity);
mympd_get_cover(uri, cover, 500);
len += json_printf(&out, "cover: %Q, ", cover);
PUT_SONG_TAGS();
if (mpd.feat_tags == true)
PUT_SONG_TAGS();
else
PUT_MIN_SONG_TAGS();
mpd_entity_free(entity);
}
mpd_response_finish(mpd.conn);
@ -1546,7 +1573,10 @@ int mympd_put_queue(char *buffer, unsigned int offset, unsigned *queue_version,
mpd_song_get_id(song),
mpd_song_get_pos(song)
);
PUT_SONG_TAGS();
if (mpd.feat_tags == true)
PUT_SONG_TAGS();
else
PUT_MIN_SONG_TAGS();
len += json_printf(&out, "}");
}
mpd_entity_free(entity);
@ -1602,7 +1632,11 @@ int mympd_put_browse(char *buffer, char *path, unsigned int offset, char *filter
if (entities_returned++)
len += json_printf(&out, ",");
len += json_printf(&out, "{Type: song, ");
PUT_SONG_TAGS();
if (mpd.feat_tags == true)
PUT_SONG_TAGS();
else
PUT_MIN_SONG_TAGS();
len += json_printf(&out, "}");
} else {
entity_count--;
@ -1876,7 +1910,10 @@ int mympd_put_playlist_list(char *buffer, char *uri, unsigned int offset, char *
if (entities_returned++)
len += json_printf(&out, ",");
len += json_printf(&out, "{Type: song, ");
PUT_SONG_TAGS();
if (mpd.feat_tags == true)
PUT_SONG_TAGS();
else
PUT_MIN_SONG_TAGS();
len += json_printf(&out, ", Pos: %d", entity_count);
len += json_printf(&out, "}");
} else {
@ -1931,7 +1968,10 @@ int mympd_search(char *buffer, char *searchstr, char *filter, char *plist, unsig
if (entities_returned++)
len += json_printf(&out, ", ");
len += json_printf(&out, "{Type: song, ");
PUT_SONG_TAGS();
if (mpd.feat_tags == true)
PUT_SONG_TAGS();
else
PUT_MIN_SONG_TAGS();
len += json_printf(&out, "}");
}
mpd_song_free(song);
@ -2017,7 +2057,10 @@ int mympd_search_queue(char *buffer, char *mpdtagtype, unsigned int offset, char
mpd_song_get_id(song),
mpd_song_get_pos(song)
);
PUT_SONG_TAGS();
if (mpd.feat_tags == true)
PUT_SONG_TAGS();
else
PUT_MIN_SONG_TAGS();
len += json_printf(&out, "}");
mpd_song_free(song);
}

View File

@ -29,17 +29,15 @@
#include "list.h"
#define RETURN_ERROR_AND_RECOVER(X) do { \
printf("MPD X: %s\n", mpd_connection_get_error_message(mpd.conn)); \
len = json_printf(&out, "{ type:error, data : %Q }", \
mpd_connection_get_error_message(mpd.conn) \
); \
printf("MPD %s: %s\n", X, mpd_connection_get_error_message(mpd.conn)); \
len = json_printf(&out, "{ type:error, data : %Q }", mpd_connection_get_error_message(mpd.conn)); \
if (!mpd_connection_clear_error(mpd.conn)) \
mpd.conn_state = MPD_FAILURE; \
return len; \
} while (0)
#define LOG_ERROR_AND_RECOVER(X) do { \
printf("MPD X: %s\n", mpd_connection_get_error_message(mpd.conn)); \
printf("MPD %s: %s\n", X, mpd_connection_get_error_message(mpd.conn)); \
if (!mpd_connection_clear_error(mpd.conn)) \
mpd.conn_state = MPD_FAILURE; \
} while (0)
@ -62,6 +60,10 @@
len += json_printf(&out, ", Duration: %d, uri: %Q", mpd_song_get_duration(song), mpd_song_get_uri(song)); \
} while (0)
#define PUT_MIN_SONG_TAGS() do { \
len += json_printf(&out, "Title: %Q, Duration: %d, uri: %Q", mympd_get_tag(song, MPD_TAG_TITLE), mpd_song_get_duration(song), mpd_song_get_uri(song)); \
} while (0)
#define MAX_SIZE 2048 * 400
#define MAX_ELEMENTS_PER_PAGE 400
@ -160,6 +162,8 @@ struct t_mpd {
const unsigned* protocol;
// Supported tags
bool feat_sticker;
bool feat_playlists;
bool feat_tags;
} mpd;
struct list mpd_tags;