mirror of
https://github.com/SuperBFG7/ympd
synced 2025-02-05 13:40:11 +00:00
Implement jsonrpc api
This commit is contained in:
parent
e6fa1206ca
commit
df91c33705
138
htdocs/js/mpd.js
138
htdocs/js/mpd.js
@ -120,9 +120,8 @@ app.route=function() {
|
|||||||
|
|
||||||
app.prepare();
|
app.prepare();
|
||||||
if (app.current.app == 'Playback') {
|
if (app.current.app == 'Playback') {
|
||||||
$.ajax({url: "/api", mimeType: "text/plain", contentType:"text/plain", method: "POST",
|
$.ajax({url: "/api", contentType:"application/json", method: "POST",
|
||||||
data: "MPD_API_GET_CURRENT_SONG"}).done(function( data ) {
|
data: JSON.stringify({"cmd":"MPD_API_GET_CURRENT_SONG"})}).done(function( obj ) {
|
||||||
var obj = JSON.parse(data);
|
|
||||||
songChange(obj.data.title, obj.data.artist, obj.data.album, obj.data.uri, obj.data.currentsongid);
|
songChange(obj.data.title, obj.data.artist, obj.data.album, obj.data.uri, obj.data.currentsongid);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -142,34 +141,30 @@ app.route=function() {
|
|||||||
getQueue();
|
getQueue();
|
||||||
}
|
}
|
||||||
else if (app.current.app == 'Browse' && app.current.tab == 'Playlists') {
|
else if (app.current.app == 'Browse' && app.current.tab == 'Playlists') {
|
||||||
$.ajax({url: "/api", mimeType: "text/plain", contentType:"text/plain", method: "POST",
|
$.ajax({url: "/api", contentType:"application/json", method: "POST",
|
||||||
data: "MPD_API_GET_PLAYLISTS," + app.current.page + ","+app.current.filter}).done(function( data ) {
|
data: JSON.stringify({"cmd":"MPD_API_GET_PLAYLISTS","data": { "offset": app.current.page, "filter": app.current.filter}})}).done(function( obj ) {
|
||||||
var obj = JSON.parse(data);
|
|
||||||
parsePlaylists(obj);
|
parsePlaylists(obj);
|
||||||
doSetFilterLetter('#browsePlaylistsFilter');
|
doSetFilterLetter('#browsePlaylistsFilter');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else if (app.current.app == 'Browse' && app.current.tab == 'Database' && app.current.view == 'Artist') {
|
else if (app.current.app == 'Browse' && app.current.tab == 'Database' && app.current.view == 'Artist') {
|
||||||
$.ajax({url: "/api", mimeType: "text/plain", contentType:"text/plain", method: "POST",
|
$.ajax({url: "/api", contentType:"application/json", method: "POST",
|
||||||
data: "MPD_API_GET_ARTISTS," + app.current.page + ","+app.current.filter}).done(function( data ) {
|
data: JSON.stringify({"cmd":"MPD_API_GET_ARTISTS","data": { "offset": app.current.page, "filter": app.current.filter}})}).done(function( obj ) {
|
||||||
var obj = JSON.parse(data);
|
|
||||||
parseListDBtags(obj);
|
parseListDBtags(obj);
|
||||||
doSetFilterLetter('#BrowseDatabaseFilter');
|
doSetFilterLetter('#BrowseDatabaseFilter');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else if (app.current.app == 'Browse' && app.current.tab == 'Database' && app.current.view == 'Album') {
|
else if (app.current.app == 'Browse' && app.current.tab == 'Database' && app.current.view == 'Album') {
|
||||||
$.ajax({url: "/api", mimeType: "text/plain", contentType:"text/plain", method: "POST",
|
$.ajax({url: "/api", contentType:"application/json", method: "POST",
|
||||||
data: "MPD_API_GET_ARTISTALBUMS," + app.current.page + ","+app.current.filter + "," + app.current.search}).done(function( data ) {
|
data: JSON.stringify({"cmd":"MPD_API_GET_ARTISTALBUMS","data": { "offset": app.current.page, "filter": app.current.filter, "albumartist": app.current.search}})}).done(function( obj ) {
|
||||||
var obj = JSON.parse(data);
|
|
||||||
parseListDBtags(obj);
|
parseListDBtags(obj);
|
||||||
doSetFilterLetter('#BrowseDatabaseFilter');
|
doSetFilterLetter('#BrowseDatabaseFilter');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else if (app.current.app == 'Browse' && app.current.tab == 'Filesystem') {
|
else if (app.current.app == 'Browse' && app.current.tab == 'Filesystem') {
|
||||||
$('#BrowseBreadcrumb').empty().append('<li class="breadcrumb-item"><a uri="">root</a></li>');
|
$('#BrowseBreadcrumb').empty().append('<li class="breadcrumb-item"><a uri="">root</a></li>');
|
||||||
$.ajax({url: "/api", mimeType: "text/plain", contentType:"text/plain", method: "POST",
|
$.ajax({url: "/api", contentType:"application/json", method: "POST",
|
||||||
data: "MPD_API_GET_FILESYSTEM," + app.current.page + ","+(app.current.search ? app.current.search : "/")+","+app.current.filter}).done(function( data ) {
|
data: JSON.stringify({"cmd":"MPD_API_GET_FILESYSTEM","data": { "offset": app.current.page,"path":(app.current.search ? app.current.search : "/"),"filter": app.current.filter}})}).done(function( obj ) {
|
||||||
var obj = JSON.parse(data);
|
|
||||||
parseFilesystem(obj);
|
parseFilesystem(obj);
|
||||||
doSetFilterLetter('#BrowseFilesystemFilter');
|
doSetFilterLetter('#BrowseFilesystemFilter');
|
||||||
});
|
});
|
||||||
@ -178,7 +173,7 @@ app.route=function() {
|
|||||||
if (app.current.search) {
|
if (app.current.search) {
|
||||||
add_all_songs.off(); // remove previous binds
|
add_all_songs.off(); // remove previous binds
|
||||||
add_all_songs.on('click', function() {
|
add_all_songs.on('click', function() {
|
||||||
sendAPI('MPD_API_ADD_TRACK,'+app.current.search);
|
sendAPI(JSON.stringify({"cmd":"MPD_API_ADD_TRACK", "data": { "uri": app.current.search}}));
|
||||||
});
|
});
|
||||||
add_all_songs.removeAttr('disabled').removeClass('disabled');
|
add_all_songs.removeAttr('disabled').removeClass('disabled');
|
||||||
} else {
|
} else {
|
||||||
@ -219,9 +214,8 @@ app.route=function() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (app.current.search.length >= 2) {
|
if (app.current.search.length >= 2) {
|
||||||
$.ajax({url: "/api", mimeType: "text/plain", contentType:"text/plain", method: "POST",
|
$.ajax({url: "/api", contentType:"application/json", method: "POST",
|
||||||
data: "MPD_API_SEARCH," + app.current.filter + ","+app.current.page+","+app.current.search}).done(function( data ) {
|
data: JSON.stringify({"cmd":"MPD_API_SEARCH", "data": { "mpdtag": app.current.filter,"offset":app.current.page,"searchstr":app.current.search}})}).done(function( obj ) {
|
||||||
var obj = JSON.parse(data);
|
|
||||||
parseSearch(obj);
|
parseSearch(obj);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@ -239,14 +233,12 @@ app.route=function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
$.ajax({url: "/api", mimeType: "text/plain", contentType:"text/plain", method: "POST",
|
$.ajax({url: "/api", contentType:"application/json", method: "POST",
|
||||||
data: "MPD_API_GET_SETTINGS"}).done(function( data ) {
|
data: JSON.stringify({"cmd":"MPD_API_GET_SETTINGS"})}).done(function( obj ) {
|
||||||
var obj = JSON.parse(data);
|
|
||||||
parseSettings(obj);
|
parseSettings(obj);
|
||||||
});
|
});
|
||||||
$.ajax({url: "/api", mimeType: "text/plain", contentType:"text/plain", method: "POST",
|
$.ajax({url: "/api", contentType:"application/json", method: "POST",
|
||||||
data: "MPD_API_GET_OUTPUTNAMES"}).done(function( data ) {
|
data: JSON.stringify({"cmd":"MPD_API_GET_OUTPUTNAMES"})}).done(function( obj ) {
|
||||||
var obj = JSON.parse(data);
|
|
||||||
parseOutputnames(obj);
|
parseOutputnames(obj);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -256,7 +248,7 @@ $(document).ready(function(){
|
|||||||
volumeBar=$('#volumebar').slider();
|
volumeBar=$('#volumebar').slider();
|
||||||
volumeBar.slider('setValue',0);
|
volumeBar.slider('setValue',0);
|
||||||
volumeBar.slider('on','slideStop', function(value){
|
volumeBar.slider('on','slideStop', function(value){
|
||||||
sendAPI("MPD_API_SET_VOLUME,"+value);
|
sendAPI(JSON.stringify({"cmd":"MPD_API_SET_VOLUME","data": {"volume":value}}));
|
||||||
});
|
});
|
||||||
|
|
||||||
progressBar=$('#progressbar').slider();
|
progressBar=$('#progressbar').slider();
|
||||||
@ -265,22 +257,20 @@ $(document).ready(function(){
|
|||||||
progressBar.slider('on','slideStop', function(value){
|
progressBar.slider('on','slideStop', function(value){
|
||||||
if(current_song && current_song.currentSongId >= 0) {
|
if(current_song && current_song.currentSongId >= 0) {
|
||||||
var seekVal = Math.ceil(current_song.totalTime*(value/100));
|
var seekVal = Math.ceil(current_song.totalTime*(value/100));
|
||||||
sendAPI("MPD_API_SET_SEEK,"+current_song.currentSongId+","+seekVal);
|
sendAPI(JSON.stringify({"cmd":"MPD_API_SET_SEEK", "data": {"songid":current_song.currentSongId,"seek":seekVal}}));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#about').on('shown.bs.modal', function () {
|
$('#about').on('shown.bs.modal', function () {
|
||||||
$.ajax({url: "/api", mimeType: "text/plain", contentType:"text/plain", method: "POST",
|
$.ajax({url: "/api", contentType:"application/json", method: "POST",
|
||||||
data: "MPD_API_GET_STATS"}).done(function( data ) {
|
data: JSON.stringify({"cmd":"MPD_API_GET_STATS"})}).done(function( obj ) {
|
||||||
var obj = JSON.parse(data);
|
|
||||||
parseStats(obj);
|
parseStats(obj);
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
$('#settings').on('shown.bs.modal', function () {
|
$('#settings').on('shown.bs.modal', function () {
|
||||||
$.ajax({url: "/api", mimeType: "text/plain", contentType:"text/plain", method: "POST",
|
$.ajax({url: "/api", contentType:"application/json", method: "POST",
|
||||||
data: "MPD_API_GET_SETTINGS"}).done(function( data ) {
|
data: JSON.stringify({"cmd":"MPD_API_GET_SETTINGS"})}).done(function( obj ) {
|
||||||
var obj = JSON.parse(data);
|
|
||||||
parseSettings(obj);
|
parseSettings(obj);
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
@ -511,9 +501,8 @@ function parseState(obj) {
|
|||||||
|
|
||||||
//Get current song on queue change for http streams
|
//Get current song on queue change for http streams
|
||||||
if (last_state == undefined || obj.data.queue_version != last_state.data.queue_version) {
|
if (last_state == undefined || obj.data.queue_version != last_state.data.queue_version) {
|
||||||
$.ajax({url: "/api", mimeType: "text/plain", contentType:"text/plain", method: "POST",
|
$.ajax({url: "/api", contentType:"application/json", method: "POST",
|
||||||
data: "MPD_API_GET_CURRENT_SONG"}).done(function( data ) {
|
data: JSON.stringify({"cmd":"MPD_API_GET_CURRENT_SONG"})}).done(function( obj ) {
|
||||||
var obj = JSON.parse(data);
|
|
||||||
songChange(obj.data.title, obj.data.artist, obj.data.album, obj.data.uri, obj.data.currentsongid);
|
songChange(obj.data.title, obj.data.artist, obj.data.album, obj.data.uri, obj.data.currentsongid);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -531,16 +520,14 @@ function parseState(obj) {
|
|||||||
|
|
||||||
function getQueue() {
|
function getQueue() {
|
||||||
if (app.current.search.length >= 2) {
|
if (app.current.search.length >= 2) {
|
||||||
$.ajax({url: "/api", mimeType: "text/plain", contentType:"text/plain", method: "POST",
|
$.ajax({url: "/api", contentType:"application/json", method: "POST",
|
||||||
data: "MPD_API_SEARCH_QUEUE," + app.current.filter + ","+app.current.page+"," + app.current.search}).done(function( data ) {
|
data: JSON.stringify({"cmd":"MPD_API_SEARCH_QUEUE", "data": {"mpdtag":app.current.filter, "offset":app.current.page,"searchstr": app.current.search}})}).done(function( obj ) {
|
||||||
var obj = JSON.parse(data);
|
|
||||||
parseQueue(obj);
|
parseQueue(obj);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$.ajax({url: "/api", mimeType: "text/plain", contentType:"text/plain", method: "POST",
|
$.ajax({url: "/api", contentType:"application/json", method: "POST",
|
||||||
data: "MPD_API_GET_QUEUE," + app.current.page}).done(function( data ) {
|
data: JSON.stringify({"cmd":"MPD_API_GET_QUEUE", "data": {"offset": app.current.page}})}).done(function( obj ) {
|
||||||
var obj = JSON.parse(data);
|
|
||||||
parseQueue(obj);
|
parseQueue(obj);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -622,7 +609,7 @@ function parseQueue(obj) {
|
|||||||
$('#QueueList > tbody > tr').on({
|
$('#QueueList > tbody > tr').on({
|
||||||
click: function() {
|
click: function() {
|
||||||
$('#queueList > tbody > tr').removeClass('active');
|
$('#queueList > tbody > tr').removeClass('active');
|
||||||
sendAPI('MPD_API_PLAY_TRACK,'+$(this).attr('trackid'));
|
sendAPI(JSON.stringify({"cmd":"MPD_API_PLAY_TRACK","data": {"track":$(this).attr('trackid')}}));
|
||||||
$(this).addClass('active');
|
$(this).addClass('active');
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@ -699,7 +686,7 @@ function parseFilesystem(obj) {
|
|||||||
'<span class="material-icons">' + glyphicon + '</span></a>')
|
'<span class="material-icons">' + glyphicon + '</span></a>')
|
||||||
.find('a').click(function(e) {
|
.find('a').click(function(e) {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
sendAPI(onClickAction + "," + decodeURI($(this).parents("tr").attr("uri")));
|
sendAPI(JSON.stringify({"cmd":onClickAction,"data":{ "uri":decodeURI($(this).parents("tr").attr("uri"))}}));
|
||||||
showNotification('"' + $('td:nth-last-child(3)', $(this).parents('tr')).text() + '" added','','','success');
|
showNotification('"' + $('td:nth-last-child(3)', $(this).parents('tr')).text() + '" added','','','success');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -730,11 +717,11 @@ function parseFilesystem(obj) {
|
|||||||
app.goto('Browse','Filesystem',undefined,app.current.page+'/'+app.current.filter+'/'+app.current.search);
|
app.goto('Browse','Filesystem',undefined,app.current.page+'/'+app.current.filter+'/'+app.current.search);
|
||||||
break;
|
break;
|
||||||
case 'song':
|
case 'song':
|
||||||
sendAPI("MPD_API_ADD_TRACK," + decodeURI($(this).attr("uri")));
|
sendAPI(JSON.stringify({"cmd":"MPD_API_ADD_TRACK", "data": {"uri": decodeURI($(this).attr("uri"))}}));
|
||||||
showNotification('"' + $('td:nth-last-child(5)', this).text() + '" added','','','success');
|
showNotification('"' + $('td:nth-last-child(5)', this).text() + '" added','','','success');
|
||||||
break;
|
break;
|
||||||
case 'plist':
|
case 'plist':
|
||||||
sendAPI("MPD_API_ADD_PLAYLIST," + decodeURI($(this).attr("uri")));
|
sendAPI(JSON.stringify({"cmd":"MPD_API_ADD_PLAYLIST", "data": {"plist": decodeURI($(this).attr("uri"))}}));
|
||||||
showNotification('"' + $('td:nth-last-child(3)', this).text() + '" added','','','success');
|
showNotification('"' + $('td:nth-last-child(3)', this).text() + '" added','','','success');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -792,7 +779,7 @@ function parsePlaylists(obj) {
|
|||||||
};
|
};
|
||||||
$('#'+app.current.app+app.current.tab+'List > tbody > tr').on({
|
$('#'+app.current.app+app.current.tab+'List > tbody > tr').on({
|
||||||
click: function() {
|
click: function() {
|
||||||
sendAPI('MPD_API_ADD_PLAYLIST,' + decodeURI($(this).attr('uri')));
|
sendAPI(JSON.stringify({"cmd":"MPD_API_ADD_PLAYLIST", "data": { "plist": decodeURI($(this).attr('uri'))}}));
|
||||||
showNotification('"' + $('td:nth-last-child(3)', this).text() + '" added','','','success');
|
showNotification('"' + $('td:nth-last-child(3)', this).text() + '" added','','','success');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -856,9 +843,8 @@ function parseListDBtags(obj) {
|
|||||||
' </div>'+
|
' </div>'+
|
||||||
'</div></div>';
|
'</div></div>';
|
||||||
$('#BrowseDatabaseAlbumCards').append(card);
|
$('#BrowseDatabaseAlbumCards').append(card);
|
||||||
$.ajax({url: "/jsonrpc", contentType:"application/json", method: "POST",
|
$.ajax({url: "/api", contentType:"application/json", method: "POST",
|
||||||
data: JSON.stringify({"cmd":"MPD_API_GET_ARTISTALBUMTITLES", "data": { "albumartist": obj.searchstr, "album": obj.data[item].value}})}).done(function( data ) {
|
data: JSON.stringify({"cmd":"MPD_API_GET_ARTISTALBUMTITLES", "data": { "albumartist": obj.searchstr, "album": obj.data[item].value}})}).done(function( obj ) {
|
||||||
var obj = JSON.parse(data);
|
|
||||||
parseListTitles(obj);
|
parseListTitles(obj);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -881,14 +867,14 @@ function parseListTitles(obj) {
|
|||||||
|
|
||||||
$('#'+genId(obj.album)+' > img').on({
|
$('#'+genId(obj.album)+' > img').on({
|
||||||
click: function() {
|
click: function() {
|
||||||
sendAPI('MPD_API_ADD_TRACK,' + decodeURI($(this).attr('uri')));
|
sendAPI(JSON.stringify({"cmd":"MPD_API_ADD_TRACK", "data": { "track": decodeURI($(this).attr('uri'))}}));
|
||||||
showNotification('"'+decodeURI($(this).attr('data-album'))+'" added','','','success');
|
showNotification('"'+decodeURI($(this).attr('data-album'))+'" added','','','success');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#tbl'+genId(obj.album)+' > tbody > tr').on({
|
$('#tbl'+genId(obj.album)+' > tbody > tr').on({
|
||||||
click: function() {
|
click: function() {
|
||||||
sendAPI('MPD_API_ADD_TRACK,' + decodeURI($(this).attr('uri')));
|
sendAPI(JSON.stringify({"cmd":"MPD_API_ADD_TRACK", "data": { "track": decodeURI($(this).attr('uri'))}}));
|
||||||
showNotification('"' + $('td:nth-last-child(1)', this).text() + '" added','','','success');
|
showNotification('"' + $('td:nth-last-child(1)', this).text() + '" added','','','success');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -982,24 +968,24 @@ function updatePlayIcon(obj) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function sendAPI(cmd) {
|
function sendAPI(cmd) {
|
||||||
$.ajax({url: "/api", mimeType: "text/plain", contentType:"text/plain", method: "POST", data: cmd});
|
$.ajax({url: "/api", contentType:"application/json", method: "POST", data: cmd});
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateDB(event) {
|
function updateDB(event) {
|
||||||
sendAPI('MPD_API_UPDATE_DB');
|
sendAPI(JSON.stringify({"cmd":"MPD_API_UPDATE_DB"}));
|
||||||
showNotification('Updating MPD Database...','','','success');
|
showNotification('Updating MPD Database...','','','success');
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
function clickPlay() {
|
function clickPlay() {
|
||||||
if( playstate != 'play')
|
if( playstate != 'play')
|
||||||
sendAPI('MPD_API_SET_PLAY');
|
sendAPI(JSON.stringify({"cmd":"MPD_API_SET_PLAY"}));
|
||||||
else
|
else
|
||||||
sendAPI('MPD_API_SET_PAUSE');
|
sendAPI(JSON.stringify({"cmd":"MPD_API_SET_PAUSE"}));
|
||||||
}
|
}
|
||||||
|
|
||||||
function clickStop() {
|
function clickStop() {
|
||||||
sendAPI('MPD_API_SET_STOP');
|
sendAPI(JSON.stringify({"cmd":"MPD_API_SET_STOP"}));
|
||||||
}
|
}
|
||||||
|
|
||||||
function setLocalStream(mpdhost,streamport) {
|
function setLocalStream(mpdhost,streamport) {
|
||||||
@ -1015,16 +1001,16 @@ function setLocalStream(mpdhost,streamport) {
|
|||||||
function delQueueSong(tr,event) {
|
function delQueueSong(tr,event) {
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
if ( $('#btntrashmodeup').hasClass('btn-success') ) {
|
if ( $('#btntrashmodeup').hasClass('btn-success') ) {
|
||||||
sendAPI('MPD_API_RM_RANGE,0,' + (tr.index() + 1));
|
sendAPI(JSON.stringify({"cmd":"MPD_API_RM_RANGE", "data": {"start":0, "end": (tr.index() + 1)}}));
|
||||||
} else if ( $('#btntrashmodesingle').hasClass('btn-success') ) {
|
} else if ( $('#btntrashmodesingle').hasClass('btn-success') ) {
|
||||||
sendAPI('MPD_API_RM_TRACK,' + tr.attr('trackid'));
|
sendAPI(JSON.stringify({"cmd":"MPD_API_RM_TRACK", "data": { "track": tr.attr('trackid')}}));
|
||||||
} else if ( $('#btntrashmodedown').hasClass('btn-success') ) {
|
} else if ( $('#btntrashmodedown').hasClass('btn-success') ) {
|
||||||
sendAPI('MPD_API_RM_RANGE,' + tr.index() + ',-1');
|
sendAPI(JSON.stringify({"cmd":"MPD_API_RM_RANGE", "data": {"start": tr.index(), "end":-1}}));
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function delPlaylist(tr) {
|
function delPlaylist(tr) {
|
||||||
sendAPI("MPD_API_RM_PLAYLIST," + decodeURI(tr.attr("uri")));
|
sendAPI(JSON.stringify({"cmd":"MPD_API_RM_PLAYLIST","data": {"plist": decodeURI(tr.attr("uri"))}}));
|
||||||
tr.remove();
|
tr.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1137,23 +1123,23 @@ function confirmSettings() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (formOK == true) {
|
if (formOK == true) {
|
||||||
sendAPI("MPD_API_TOGGLE_CONSUME," + ($('#btnconsume').hasClass('btn-success') ? 1 : 0));
|
sendAPI(JSON.stringify({"cmd":"MPD_API_TOGGLE_CONSUME","data": {"state": ($('#btnconsume').hasClass('btn-success') ? 1 : 0)}}));
|
||||||
sendAPI("MPD_API_TOGGLE_RANDOM," + ($('#btnrandom').hasClass('btn-success') ? 1 : 0));
|
sendAPI(JSON.stringify({"cmd":"MPD_API_TOGGLE_RANDOM","data":{"state": ($('#btnrandom').hasClass('btn-success') ? 1 : 0)}}));
|
||||||
sendAPI("MPD_API_TOGGLE_SINGLE," + ($('#btnsingle').hasClass('btn-success') ? 1 : 0));
|
sendAPI(JSON.stringify({"cmd":"MPD_API_TOGGLE_SINGLE","data":{"state": ($('#btnsingle').hasClass('btn-success') ? 1 : 0)}}));
|
||||||
sendAPI("MPD_API_TOGGLE_REPEAT," + ($('#btnrepeat').hasClass('btn-success') ? 1 : 0));
|
sendAPI(JSON.stringify({"cmd":"MPD_API_TOGGLE_REPEAT","data":{"state": ($('#btnrepeat').hasClass('btn-success') ? 1 : 0)}}));
|
||||||
sendAPI("MPD_API_SET_REPLAYGAIN," + $('#selectReplaygain').val());
|
sendAPI(JSON.stringify({"cmd":"MPD_API_SET_REPLAYGAIN","data":{"mode": $('#selectReplaygain').val()}}));
|
||||||
if (!$('#inputCrossfade').is(':disabled'))
|
if (!$('#inputCrossfade').is(':disabled'))
|
||||||
sendAPI("MPD_API_SET_CROSSFADE," + $('#inputCrossfade').val());
|
sendAPI(JSON.stringify({"cmd":"MPD_API_SET_CROSSFADE","data":{"state": $('#inputCrossfade').val()}}));
|
||||||
if (!$('#inputMixrampdb').is(':disabled'))
|
if (!$('#inputMixrampdb').is(':disabled'))
|
||||||
sendAPI("MPD_API_SET_MIXRAMPDB," + $('#inputMixrampdb').val());
|
sendAPI(JSON.stringify({"cmd":"MPD_API_SET_MIXRAMPDB","data":{"state": $('#inputMixrampdb').val()}}));
|
||||||
if (!$('#inputMixrampdelay').is(':disabled'))
|
if (!$('#inputMixrampdelay').is(':disabled'))
|
||||||
sendAPI("MPD_API_SET_MIXRAMPDELAY," + $('#inputMixrampdelay').val());
|
sendAPI(JSON.stringify({"cmd":"MPD_API_SET_MIXRAMPDELAY","data":{"state": $('#inputMixrampdelay').val()}}));
|
||||||
$('#settings').modal('hide');
|
$('#settings').modal('hide');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggleoutput(button, id) {
|
function toggleoutput(button, id) {
|
||||||
sendAPI("MPD_API_TOGGLE_OUTPUT,"+id+"," + ($(button).hasClass('btn-success') ? 0 : 1));
|
sendAPI(JSON.stringify({"cmd":"MPD_API_TOGGLE_OUTPUT", "data": {"output": id, "state": ($(button).hasClass('btn-success') ? 0 : 1)}}));
|
||||||
}
|
}
|
||||||
|
|
||||||
$('#trashmodebtns > button').on('click', function(e) {
|
$('#trashmodebtns > button').on('click', function(e) {
|
||||||
@ -1206,7 +1192,7 @@ $('#search2').submit(function () {
|
|||||||
|
|
||||||
function addAllFromSearch() {
|
function addAllFromSearch() {
|
||||||
if (app.current.search.length >= 2) {
|
if (app.current.search.length >= 2) {
|
||||||
sendAPI('MPD_API_SEARCH_ADD,' + app.current.filter + ',' + app.current.search);
|
sendAPI(JSON.stringify({"cmd":"MPD_API_SEARCH_ADD","data":{"filter": app.current.filter,"searchstr": + app.current.search}}));
|
||||||
var rowCount = $('#SearchList >tbody >tr').length;
|
var rowCount = $('#SearchList >tbody >tr').length;
|
||||||
showNotification('Added '+rowCount+' songs from search','','','success');
|
showNotification('Added '+rowCount+' songs from search','','','success');
|
||||||
}
|
}
|
||||||
@ -1271,7 +1257,7 @@ function gotoPage(x,element,event) {
|
|||||||
|
|
||||||
function addStream() {
|
function addStream() {
|
||||||
if($('#streamurl').val().length > 0) {
|
if($('#streamurl').val().length > 0) {
|
||||||
sendAPI('MPD_API_ADD_TRACK,'+$('#streamurl').val());
|
sendAPI(JSON.stringify({"cmd":"MPD_API_ADD_TRACK","data":{"uri":$('#streamurl').val()}}));
|
||||||
}
|
}
|
||||||
$('#streamurl').val("");
|
$('#streamurl').val("");
|
||||||
$('#addstream').modal('hide');
|
$('#addstream').modal('hide');
|
||||||
@ -1279,7 +1265,7 @@ function addStream() {
|
|||||||
|
|
||||||
function saveQueue() {
|
function saveQueue() {
|
||||||
if($('#playlistname').val().length > 0) {
|
if($('#playlistname').val().length > 0) {
|
||||||
sendAPI('MPD_API_SAVE_QUEUE,'+$('#playlistname').val());
|
sendAPI(JSON.stringify({"cmd":"MPD_API_SAVE_QUEUE","data":{"plist":$('#playlistname').val()}}));
|
||||||
}
|
}
|
||||||
$('#savequeue').modal('hide');
|
$('#savequeue').modal('hide');
|
||||||
}
|
}
|
||||||
@ -1361,10 +1347,10 @@ $(document).keydown(function(e){
|
|||||||
}
|
}
|
||||||
switch (e.which) {
|
switch (e.which) {
|
||||||
case 37: //left
|
case 37: //left
|
||||||
sendAPI('MPD_API_SET_PREV');
|
sendAPI(JSON.stringify({"cmd":"MPD_API_SET_PREV"}));
|
||||||
break;
|
break;
|
||||||
case 39: //right
|
case 39: //right
|
||||||
sendAPI('MPD_API_SET_NEXT');
|
sendAPI(JSON.stringify({"cmd":"MPD_API_SET_NEXT"}));
|
||||||
break;
|
break;
|
||||||
case 32: //space
|
case 32: //space
|
||||||
clickPlay();
|
clickPlay();
|
||||||
@ -1416,7 +1402,7 @@ function chVolume (increment) {
|
|||||||
if (newValue<0) { newValue=0; }
|
if (newValue<0) { newValue=0; }
|
||||||
else if (newValue > 100) { newValue=100; }
|
else if (newValue > 100) { newValue=100; }
|
||||||
volumeBar.slider('setValue',newValue);
|
volumeBar.slider('setValue',newValue);
|
||||||
sendAPI("MPD_API_SET_VOLUME,"+newValue);
|
sendAPI(JSON.stringify({"cmd":"MPD_API_SET_VOLUME", "data": {"volume":newValue}}));
|
||||||
}
|
}
|
||||||
|
|
||||||
function beautifyDuration(x) {
|
function beautifyDuration(x) {
|
||||||
|
445
src/mpd_client.c
445
src/mpd_client.c
@ -42,14 +42,6 @@ const char * mpd_cmd_strs[] = {
|
|||||||
MPD_CMDS(GEN_STR)
|
MPD_CMDS(GEN_STR)
|
||||||
};
|
};
|
||||||
|
|
||||||
char * get_arg1 (const char *p) {
|
|
||||||
return strchr(p, ',') + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
char * get_arg2 (const char *p) {
|
|
||||||
return get_arg1(get_arg1(p));
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline enum mpd_cmd_ids get_cmd_id(const char *cmd)
|
static inline enum mpd_cmd_ids get_cmd_id(const char *cmd)
|
||||||
{
|
{
|
||||||
for(int i = 0; i < sizeof(mpd_cmd_strs)/sizeof(mpd_cmd_strs[0]); i++)
|
for(int i = 0; i < sizeof(mpd_cmd_strs)/sizeof(mpd_cmd_strs[0]); i++)
|
||||||
@ -59,16 +51,14 @@ static inline enum mpd_cmd_ids get_cmd_id(const char *cmd)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void callback_mympd_jsonrpc(struct mg_connection *nc, const struct mg_str msg)
|
void callback_mympd(struct mg_connection *nc, const struct mg_str msg)
|
||||||
{
|
{
|
||||||
size_t n = 0;
|
size_t n = 0;
|
||||||
char *cmd;
|
char *cmd;
|
||||||
int int_buf;
|
unsigned int uint_buf1, uint_buf2;
|
||||||
int je;
|
int je, int_buf;
|
||||||
float float_buf;
|
float float_buf;
|
||||||
char *p_charbuf1;
|
char *p_charbuf1, *p_charbuf2;
|
||||||
char *p_charbuf2;
|
|
||||||
char *p_charbuf3;
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stdout,"Got request: %s\n",msg.p);
|
fprintf(stdout,"Got request: %s\n",msg.p);
|
||||||
@ -88,48 +78,6 @@ void callback_mympd_jsonrpc(struct mg_connection *nc, const struct mg_str msg)
|
|||||||
free(p_charbuf1);
|
free(p_charbuf1);
|
||||||
free(p_charbuf2);
|
free(p_charbuf2);
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
free(cmd);
|
|
||||||
|
|
||||||
if(mpd.conn_state == MPD_CONNECTED && mpd_connection_get_error(mpd.conn) != MPD_ERROR_SUCCESS)
|
|
||||||
{
|
|
||||||
#ifdef DEBUG
|
|
||||||
fprintf(stdout,"Error: %s\n",mpd_connection_get_error_message(mpd.conn));
|
|
||||||
#endif
|
|
||||||
n = snprintf(mpd.buf, MAX_SIZE, "{\"type\":\"error\", \"data\": \"%s\"}",
|
|
||||||
mpd_connection_get_error_message(mpd.conn));
|
|
||||||
|
|
||||||
/* Try to recover error */
|
|
||||||
if (!mpd_connection_clear_error(mpd.conn))
|
|
||||||
mpd.conn_state = MPD_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(n > 0) {
|
|
||||||
#ifdef DEBUG
|
|
||||||
fprintf(stdout,"Send http response:\n %s\n",mpd.buf);
|
|
||||||
#endif
|
|
||||||
mg_send_http_chunk(nc, mpd.buf, n);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void callback_mympd(struct mg_connection *nc, const struct mg_str msg)
|
|
||||||
{
|
|
||||||
enum mpd_cmd_ids cmd_id = get_cmd_id(msg.p);
|
|
||||||
size_t n = 0;
|
|
||||||
unsigned int uint_buf, uint_buf_2;
|
|
||||||
int int_buf;
|
|
||||||
float float_buf;
|
|
||||||
char *p_charbuf = NULL, *token;
|
|
||||||
char *p_charbuf2 = NULL;
|
|
||||||
char *searchstr = NULL;
|
|
||||||
#ifdef DEBUG
|
|
||||||
fprintf(stdout,"Got request: %s\n",msg.p);
|
|
||||||
#endif
|
|
||||||
if(cmd_id == -1)
|
|
||||||
return;
|
|
||||||
|
|
||||||
switch(cmd_id)
|
|
||||||
{
|
|
||||||
case MPD_API_WELCOME:
|
case MPD_API_WELCOME:
|
||||||
n = mympd_put_welcome(mpd.buf);
|
n = mympd_put_welcome(mpd.buf);
|
||||||
case MPD_API_UPDATE_DB:
|
case MPD_API_UPDATE_DB:
|
||||||
@ -154,343 +102,184 @@ void callback_mympd(struct mg_connection *nc, const struct mg_str msg)
|
|||||||
mpd_run_clear(mpd.conn);
|
mpd_run_clear(mpd.conn);
|
||||||
break;
|
break;
|
||||||
case MPD_API_RM_TRACK:
|
case MPD_API_RM_TRACK:
|
||||||
if(sscanf(msg.p, "MPD_API_RM_TRACK,%u", &uint_buf))
|
je = json_scanf(msg.p, msg.len, "{ data: { track:%u } }", &uint_buf1);
|
||||||
mpd_run_delete_id(mpd.conn, uint_buf);
|
if (je == 1)
|
||||||
|
mpd_run_delete_id(mpd.conn, uint_buf1);
|
||||||
break;
|
break;
|
||||||
case MPD_API_RM_RANGE:
|
case MPD_API_RM_RANGE:
|
||||||
if(sscanf(msg.p, "MPD_API_RM_RANGE,%u,%u", &uint_buf, &uint_buf_2))
|
je = json_scanf(msg.p, msg.len, "{ data: { start:%u, end:%u } }", &uint_buf1, &uint_buf2);
|
||||||
mpd_run_delete_range(mpd.conn, uint_buf, uint_buf_2);
|
if (je == 2)
|
||||||
|
mpd_run_delete_range(mpd.conn, uint_buf1, uint_buf2);
|
||||||
break;
|
break;
|
||||||
case MPD_API_MOVE_TRACK:
|
case MPD_API_MOVE_TRACK:
|
||||||
if (sscanf(msg.p, "MPD_API_MOVE_TRACK,%u,%u", &uint_buf, &uint_buf_2) == 2)
|
je = json_scanf(msg.p, msg.len, "{ data: { track:%u, pos:%u } }", &uint_buf1, &uint_buf2);
|
||||||
|
if (je == 2)
|
||||||
{
|
{
|
||||||
uint_buf -= 1;
|
uint_buf1 -= 1;
|
||||||
uint_buf_2 -= 1;
|
uint_buf2 -= 1;
|
||||||
mpd_run_move(mpd.conn, uint_buf, uint_buf_2);
|
mpd_run_move(mpd.conn, uint_buf1, uint_buf2);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MPD_API_PLAY_TRACK:
|
case MPD_API_PLAY_TRACK:
|
||||||
if(sscanf(msg.p, "MPD_API_PLAY_TRACK,%u", &uint_buf))
|
je = json_scanf(msg.p, msg.len, "{ data: { track:%u } }", &uint_buf1);
|
||||||
mpd_run_play_id(mpd.conn, uint_buf);
|
if (je == 1)
|
||||||
|
mpd_run_play_id(mpd.conn, uint_buf1);
|
||||||
break;
|
break;
|
||||||
case MPD_API_TOGGLE_RANDOM:
|
case MPD_API_TOGGLE_RANDOM:
|
||||||
if(sscanf(msg.p, "MPD_API_TOGGLE_RANDOM,%u", &uint_buf))
|
je = json_scanf(msg.p, msg.len, "{ data: { state:%u } }", &uint_buf1);
|
||||||
mpd_run_random(mpd.conn, uint_buf);
|
if (je == 1)
|
||||||
|
mpd_run_random(mpd.conn, uint_buf1);
|
||||||
break;
|
break;
|
||||||
case MPD_API_TOGGLE_REPEAT:
|
case MPD_API_TOGGLE_REPEAT:
|
||||||
if(sscanf(msg.p, "MPD_API_TOGGLE_REPEAT,%u", &uint_buf))
|
je = json_scanf(msg.p, msg.len, "{ data: { state:%u } }", &uint_buf1);
|
||||||
mpd_run_repeat(mpd.conn, uint_buf);
|
if (je == 1)
|
||||||
|
mpd_run_repeat(mpd.conn, uint_buf1);
|
||||||
break;
|
break;
|
||||||
case MPD_API_TOGGLE_CONSUME:
|
case MPD_API_TOGGLE_CONSUME:
|
||||||
if(sscanf(msg.p, "MPD_API_TOGGLE_CONSUME,%u", &uint_buf))
|
je = json_scanf(msg.p, msg.len, "{ data: { state:%u } }", &uint_buf1);
|
||||||
mpd_run_consume(mpd.conn, uint_buf);
|
if (je == 1)
|
||||||
|
mpd_run_consume(mpd.conn, uint_buf1);
|
||||||
break;
|
break;
|
||||||
case MPD_API_TOGGLE_SINGLE:
|
case MPD_API_TOGGLE_SINGLE:
|
||||||
if(sscanf(msg.p, "MPD_API_TOGGLE_SINGLE,%u", &uint_buf))
|
je = json_scanf(msg.p, msg.len, "{ data: { state:%u } }", &uint_buf1);
|
||||||
mpd_run_single(mpd.conn, uint_buf);
|
if (je == 1)
|
||||||
|
mpd_run_single(mpd.conn, uint_buf1);
|
||||||
break;
|
break;
|
||||||
case MPD_API_SET_CROSSFADE:
|
case MPD_API_SET_CROSSFADE:
|
||||||
if(sscanf(msg.p, "MPD_API_SET_CROSSFADE,%u", &uint_buf))
|
je = json_scanf(msg.p, msg.len, "{ data: { state:%u } }", &uint_buf1);
|
||||||
mpd_run_crossfade(mpd.conn, uint_buf);
|
if (je == 1)
|
||||||
|
mpd_run_crossfade(mpd.conn, uint_buf1);
|
||||||
break;
|
break;
|
||||||
case MPD_API_SET_MIXRAMPDB:
|
case MPD_API_SET_MIXRAMPDB:
|
||||||
if(sscanf(msg.p, "MPD_API_SET_MIXRAMPDB,%f", &float_buf))
|
je = json_scanf(msg.p, msg.len, "{ data: { state:%f } }", &float_buf);
|
||||||
|
if (je == 1)
|
||||||
mpd_run_mixrampdb(mpd.conn, float_buf);
|
mpd_run_mixrampdb(mpd.conn, float_buf);
|
||||||
break;
|
break;
|
||||||
case MPD_API_SET_MIXRAMPDELAY:
|
case MPD_API_SET_MIXRAMPDELAY:
|
||||||
if(sscanf(msg.p, "MPD_API_SET_MIXRAMPDELAY,%f", &float_buf))
|
je = json_scanf(msg.p, msg.len, "{ data: { state:%f } }", &float_buf);
|
||||||
|
if (je == 1)
|
||||||
mpd_run_mixrampdelay(mpd.conn, float_buf);
|
mpd_run_mixrampdelay(mpd.conn, float_buf);
|
||||||
break;
|
break;
|
||||||
case MPD_API_GET_OUTPUTNAMES:
|
case MPD_API_GET_OUTPUTNAMES:
|
||||||
n = mympd_put_outputnames(mpd.buf);
|
n = mympd_put_outputnames(mpd.buf);
|
||||||
break;
|
break;
|
||||||
case MPD_API_TOGGLE_OUTPUT:
|
case MPD_API_TOGGLE_OUTPUT:
|
||||||
if (sscanf(msg.p, "MPD_API_TOGGLE_OUTPUT,%u,%u", &uint_buf, &uint_buf_2)) {
|
je = json_scanf(msg.p, msg.len, "{ data: { output:%u, state:%u } }", &uint_buf1, &uint_buf2);
|
||||||
if (uint_buf_2)
|
if (je == 2)
|
||||||
mpd_run_enable_output(mpd.conn, uint_buf);
|
{
|
||||||
|
if (uint_buf2)
|
||||||
|
mpd_run_enable_output(mpd.conn, uint_buf1);
|
||||||
else
|
else
|
||||||
mpd_run_disable_output(mpd.conn, uint_buf);
|
mpd_run_disable_output(mpd.conn, uint_buf1);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MPD_API_SET_VOLUME:
|
case MPD_API_SET_VOLUME:
|
||||||
if(sscanf(msg.p, "MPD_API_SET_VOLUME,%ud", &uint_buf) && uint_buf <= 100)
|
je = json_scanf(msg.p, msg.len, "{ data: { volume:%u } }", &uint_buf1);
|
||||||
mpd_run_set_volume(mpd.conn, uint_buf);
|
if (je == 1)
|
||||||
|
mpd_run_set_volume(mpd.conn, uint_buf1);
|
||||||
break;
|
break;
|
||||||
case MPD_API_SET_SEEK:
|
case MPD_API_SET_SEEK:
|
||||||
if(sscanf(msg.p, "MPD_API_SET_SEEK,%u,%u", &uint_buf, &uint_buf_2))
|
je = json_scanf(msg.p, msg.len, "{ data: { songid:%u, seek:%u } }", &uint_buf1, &uint_buf2);
|
||||||
mpd_run_seek_id(mpd.conn, uint_buf, uint_buf_2);
|
if (je == 2)
|
||||||
|
mpd_run_seek_id(mpd.conn, uint_buf1, uint_buf2);
|
||||||
break;
|
break;
|
||||||
case MPD_API_GET_QUEUE:
|
case MPD_API_GET_QUEUE:
|
||||||
if(sscanf(msg.p, "MPD_API_GET_QUEUE,%u", &uint_buf))
|
je = json_scanf(msg.p, msg.len, "{ data: { offset:%u } }", &uint_buf1);
|
||||||
n = mympd_put_queue(mpd.buf, uint_buf);
|
if (je == 1)
|
||||||
|
n = mympd_put_queue(mpd.buf, uint_buf1);
|
||||||
break;
|
break;
|
||||||
case MPD_API_GET_CURRENT_SONG:
|
case MPD_API_GET_CURRENT_SONG:
|
||||||
n = mympd_put_current_song(mpd.buf);
|
n = mympd_put_current_song(mpd.buf);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MPD_API_GET_ARTISTS:
|
case MPD_API_GET_ARTISTS:
|
||||||
p_charbuf = strdup(msg.p);
|
je = json_scanf(msg.p, msg.len, "{ data: { offset:%u, filter:%Q } }", &uint_buf1, &p_charbuf1);
|
||||||
if(strcmp(strtok(p_charbuf, ","), "MPD_API_GET_ARTISTS"))
|
if (je == 2)
|
||||||
goto out_artist;
|
n = mympd_put_db_tag(mpd.buf, uint_buf1, "AlbumArtist","","",p_charbuf1);
|
||||||
uint_buf = strtoul(strtok(NULL, ","), NULL, 10);
|
free(p_charbuf1);
|
||||||
|
|
||||||
if((token = strtok(NULL, ",")) == NULL) {
|
|
||||||
goto out_artist;
|
|
||||||
} else {
|
|
||||||
p_charbuf2 = strdup(token);
|
|
||||||
}
|
|
||||||
n = mympd_put_db_tag(mpd.buf, uint_buf, "AlbumArtist","","",p_charbuf2);
|
|
||||||
free(p_charbuf2);
|
|
||||||
out_artist:
|
|
||||||
free(p_charbuf);
|
|
||||||
break;
|
break;
|
||||||
case MPD_API_GET_ARTISTALBUMS:
|
case MPD_API_GET_ARTISTALBUMS:
|
||||||
p_charbuf = strdup(msg.p);
|
je = json_scanf(msg.p, msg.len, "{ data: { offset:%u, filter:%Q, albumartist:%Q } }", &uint_buf1, &p_charbuf1, &p_charbuf2);
|
||||||
if(strcmp(strtok(p_charbuf, ","), "MPD_API_GET_ARTISTALBUMS"))
|
if (je == 3)
|
||||||
goto out_artistalbum;
|
n = mympd_put_db_tag(mpd.buf, uint_buf1, "Album", "AlbumArtist", p_charbuf2, p_charbuf1);
|
||||||
uint_buf = strtoul(strtok(NULL, ","), NULL, 10);
|
free(p_charbuf1);
|
||||||
|
|
||||||
if((token = strtok(NULL, ",")) == NULL) {
|
|
||||||
goto out_artistalbum;
|
|
||||||
} else {
|
|
||||||
p_charbuf2 = strdup(token);
|
|
||||||
}
|
|
||||||
|
|
||||||
if((token = strtok(NULL, ",")) == NULL) {
|
|
||||||
free(p_charbuf2);
|
free(p_charbuf2);
|
||||||
goto out_artistalbum;
|
|
||||||
} else {
|
|
||||||
searchstr = strdup(token);
|
|
||||||
}
|
|
||||||
n = mympd_put_db_tag(mpd.buf, uint_buf, "Album", "AlbumArtist", searchstr, p_charbuf2);
|
|
||||||
free(searchstr);
|
|
||||||
free(p_charbuf2);
|
|
||||||
out_artistalbum:
|
|
||||||
free(p_charbuf);
|
|
||||||
break;
|
|
||||||
case MPD_API_GET_ARTISTALBUMTITLES:
|
|
||||||
p_charbuf = strdup(msg.p);
|
|
||||||
if(strcmp(strtok(p_charbuf, ","), "MPD_API_GET_ARTISTALBUMTITLES"))
|
|
||||||
goto out_artistalbumtitle;
|
|
||||||
|
|
||||||
if((token = strtok(NULL, ",")) == NULL) {
|
|
||||||
goto out_artistalbumtitle;
|
|
||||||
} else {
|
|
||||||
searchstr = strdup(token);
|
|
||||||
}
|
|
||||||
n = mympd_put_songs_in_album(mpd.buf, searchstr, token+strlen(token)+1);
|
|
||||||
free(searchstr);
|
|
||||||
out_artistalbumtitle:
|
|
||||||
free(p_charbuf);
|
|
||||||
break;
|
break;
|
||||||
case MPD_API_GET_PLAYLISTS:
|
case MPD_API_GET_PLAYLISTS:
|
||||||
p_charbuf = strdup(msg.p);
|
je = json_scanf(msg.p, msg.len, "{ data: { offset:%u, filter:%Q } }", &uint_buf1, &p_charbuf1);
|
||||||
if(strcmp(strtok(p_charbuf, ","), "MPD_API_GET_PLAYLISTS"))
|
if (je == 2)
|
||||||
goto out_artist;
|
n = mympd_put_playlists(mpd.buf, uint_buf1, p_charbuf1);
|
||||||
uint_buf = strtoul(strtok(NULL, ","), NULL, 10);
|
free(p_charbuf1);
|
||||||
|
|
||||||
if((token = strtok(NULL, ",")) == NULL) {
|
|
||||||
goto out_playlists;
|
|
||||||
} else {
|
|
||||||
p_charbuf2 = strdup(token);
|
|
||||||
}
|
|
||||||
n = mympd_put_playlists(mpd.buf, uint_buf, p_charbuf2);
|
|
||||||
free(p_charbuf2);
|
|
||||||
out_playlists:
|
|
||||||
free(p_charbuf);
|
|
||||||
break;
|
break;
|
||||||
case MPD_API_GET_FILESYSTEM:
|
case MPD_API_GET_FILESYSTEM:
|
||||||
p_charbuf = strdup(msg.p);
|
je = json_scanf(msg.p, msg.len, "{ data: { offset:%u, filter:%Q, path:%Q } }", &uint_buf1, &p_charbuf1, &p_charbuf2);
|
||||||
if(strcmp(strtok(p_charbuf, ","), "MPD_API_GET_FILESYSTEM"))
|
if (je == 3)
|
||||||
goto out_browse;
|
n = mympd_put_browse(mpd.buf, p_charbuf2, uint_buf1, p_charbuf1);
|
||||||
|
free(p_charbuf1);
|
||||||
uint_buf = strtoul(strtok(NULL, ","), NULL, 10);
|
|
||||||
|
|
||||||
if((token = strtok(NULL, ",")) == NULL) {
|
|
||||||
goto out_browse;
|
|
||||||
} else {
|
|
||||||
p_charbuf2 = strdup(token);
|
|
||||||
}
|
|
||||||
|
|
||||||
if((token = strtok(NULL, ",")) == NULL) {
|
|
||||||
free(p_charbuf2);
|
free(p_charbuf2);
|
||||||
goto out_browse;
|
|
||||||
} else {
|
|
||||||
searchstr = strdup(token);
|
|
||||||
}
|
|
||||||
n = mympd_put_browse(mpd.buf, p_charbuf2, uint_buf, searchstr);
|
|
||||||
free(searchstr);
|
|
||||||
free(p_charbuf2);
|
|
||||||
out_browse:
|
|
||||||
free(p_charbuf);
|
|
||||||
break;
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case MPD_API_ADD_TRACK:
|
case MPD_API_ADD_TRACK:
|
||||||
p_charbuf = strdup(msg.p);
|
je = json_scanf(msg.p, msg.len, "{ data: { uri:%Q } }", &p_charbuf1);
|
||||||
if(strcmp(strtok(p_charbuf, ","), "MPD_API_ADD_TRACK"))
|
if (je == 1)
|
||||||
goto out_add_track;
|
mpd_run_add(mpd.conn, p_charbuf1);
|
||||||
|
free(p_charbuf1);
|
||||||
if((token = strtok(NULL, ",")) == NULL)
|
|
||||||
goto out_add_track;
|
|
||||||
|
|
||||||
free(p_charbuf);
|
|
||||||
p_charbuf = strdup(msg.p);
|
|
||||||
mpd_run_add(mpd.conn, get_arg1(p_charbuf));
|
|
||||||
out_add_track:
|
|
||||||
free(p_charbuf);
|
|
||||||
break;
|
break;
|
||||||
case MPD_API_ADD_PLAY_TRACK:
|
case MPD_API_ADD_PLAY_TRACK:
|
||||||
p_charbuf = strdup(msg.p);
|
je = json_scanf(msg.p, msg.len, "{ data: { uri:%Q } }", &p_charbuf1);
|
||||||
if(strcmp(strtok(p_charbuf, ","), "MPD_API_ADD_PLAY_TRACK"))
|
if (je == 1) {
|
||||||
goto out_play_track;
|
int_buf = mpd_run_add_id(mpd.conn, p_charbuf1);
|
||||||
|
|
||||||
if((token = strtok(NULL, ",")) == NULL)
|
|
||||||
goto out_play_track;
|
|
||||||
|
|
||||||
free(p_charbuf);
|
|
||||||
p_charbuf = strdup(msg.p);
|
|
||||||
int_buf = mpd_run_add_id(mpd.conn, get_arg1(p_charbuf));
|
|
||||||
if(int_buf != -1)
|
if(int_buf != -1)
|
||||||
mpd_run_play_id(mpd.conn, int_buf);
|
mpd_run_play_id(mpd.conn, int_buf);
|
||||||
out_play_track:
|
}
|
||||||
free(p_charbuf);
|
free(p_charbuf1);
|
||||||
break;
|
break;
|
||||||
case MPD_API_ADD_PLAYLIST:
|
case MPD_API_ADD_PLAYLIST:
|
||||||
p_charbuf = strdup(msg.p);
|
je = json_scanf(msg.p, msg.len, "{ data: { plist:%Q } }", &p_charbuf1);
|
||||||
if(strcmp(strtok(p_charbuf, ","), "MPD_API_ADD_PLAYLIST"))
|
if (je == 1)
|
||||||
goto out_playlist;
|
mpd_run_load(mpd.conn, p_charbuf1);
|
||||||
|
free(p_charbuf1);
|
||||||
if((token = strtok(NULL, ",")) == NULL)
|
|
||||||
goto out_playlist;
|
|
||||||
|
|
||||||
free(p_charbuf);
|
|
||||||
p_charbuf = strdup(msg.p);
|
|
||||||
mpd_run_load(mpd.conn, get_arg1(p_charbuf));
|
|
||||||
out_playlist:
|
|
||||||
free(p_charbuf);
|
|
||||||
break;
|
break;
|
||||||
case MPD_API_SAVE_QUEUE:
|
case MPD_API_SAVE_QUEUE:
|
||||||
p_charbuf = strdup(msg.p);
|
je = json_scanf(msg.p, msg.len, "{ data: { plist:%Q } }", &p_charbuf1);
|
||||||
if(strcmp(strtok(p_charbuf, ","), "MPD_API_SAVE_QUEUE"))
|
if (je == 1)
|
||||||
goto out_save_queue;
|
mpd_run_save(mpd.conn, p_charbuf1);
|
||||||
|
free(p_charbuf1);
|
||||||
if((token = strtok(NULL, ",")) == NULL)
|
|
||||||
goto out_save_queue;
|
|
||||||
|
|
||||||
free(p_charbuf);
|
|
||||||
p_charbuf = strdup(msg.p);
|
|
||||||
mpd_run_save(mpd.conn, get_arg1(p_charbuf));
|
|
||||||
out_save_queue:
|
|
||||||
free(p_charbuf);
|
|
||||||
break;
|
break;
|
||||||
case MPD_API_SEARCH_QUEUE:
|
case MPD_API_SEARCH_QUEUE:
|
||||||
p_charbuf = strdup(msg.p);
|
je = json_scanf(msg.p, msg.len, "{ data: { offset:%u, mpdtag:%Q, searchstr:%Q } }", &uint_buf1, &p_charbuf1, &p_charbuf2);
|
||||||
if(strcmp(strtok(p_charbuf, ","), "MPD_API_SEARCH_QUEUE"))
|
if (je == 3)
|
||||||
goto out_search_queue;
|
n = mympd_search_queue(mpd.buf, p_charbuf1, uint_buf1, p_charbuf2);
|
||||||
if((token = strtok(NULL, ",")) == NULL) {
|
free(p_charbuf1);
|
||||||
goto out_search_queue;
|
|
||||||
} else {
|
|
||||||
p_charbuf2 = strdup(token);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint_buf = strtoul(strtok(NULL, ","), NULL, 10);
|
|
||||||
|
|
||||||
if((token = strtok(NULL, ",")) == NULL) {
|
|
||||||
free(p_charbuf2);
|
free(p_charbuf2);
|
||||||
goto out_search_queue;
|
|
||||||
} else {
|
|
||||||
searchstr = strdup(token);
|
|
||||||
}
|
|
||||||
n = mympd_search_queue(mpd.buf, p_charbuf2, uint_buf, searchstr);
|
|
||||||
free(searchstr);
|
|
||||||
free(p_charbuf2);
|
|
||||||
out_search_queue:
|
|
||||||
free(p_charbuf);
|
|
||||||
break;
|
break;
|
||||||
case MPD_API_SEARCH_ADD:
|
case MPD_API_SEARCH_ADD:
|
||||||
p_charbuf = strdup(msg.p);
|
je = json_scanf(msg.p, msg.len, "{ data: { mpdtag:%Q, searchstr:%Q } }", &p_charbuf1, &p_charbuf2);
|
||||||
if(strcmp(strtok(p_charbuf, ","), "MPD_API_SEARCH_ADD"))
|
if (je == 2)
|
||||||
goto out_search_add;
|
n = mympd_search_add(mpd.buf, p_charbuf1, p_charbuf2);
|
||||||
if((token = strtok(NULL, ",")) == NULL) {
|
free(p_charbuf1);
|
||||||
goto out_search_add;
|
|
||||||
} else {
|
|
||||||
p_charbuf2 = strdup(token);
|
|
||||||
}
|
|
||||||
|
|
||||||
if((token = strtok(NULL, ",")) == NULL) {
|
|
||||||
free(p_charbuf2);
|
free(p_charbuf2);
|
||||||
goto out_search_add;
|
|
||||||
} else {
|
|
||||||
searchstr = strdup(token);
|
|
||||||
}
|
|
||||||
n = mympd_search_add(mpd.buf, p_charbuf2, searchstr);
|
|
||||||
free(searchstr);
|
|
||||||
free(p_charbuf2);
|
|
||||||
out_search_add:
|
|
||||||
free(p_charbuf);
|
|
||||||
break;
|
break;
|
||||||
case MPD_API_SEARCH:
|
case MPD_API_SEARCH:
|
||||||
p_charbuf = strdup(msg.p);
|
je = json_scanf(msg.p, msg.len, "{ data: { offset:%u, mpdtag:%Q, searchstr:%Q } }", &uint_buf1, &p_charbuf1, &p_charbuf2);
|
||||||
if(strcmp(strtok(p_charbuf, ","), "MPD_API_SEARCH"))
|
if (je == 3)
|
||||||
goto out_search;
|
n = mympd_search(mpd.buf, p_charbuf1, uint_buf1, p_charbuf2);
|
||||||
if((token = strtok(NULL, ",")) == NULL) {
|
free(p_charbuf1);
|
||||||
goto out_search;
|
|
||||||
} else {
|
|
||||||
p_charbuf2 = strdup(token);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint_buf = strtoul(strtok(NULL, ","), NULL, 10);
|
|
||||||
|
|
||||||
if((token = strtok(NULL, ",")) == NULL) {
|
|
||||||
free(p_charbuf2);
|
free(p_charbuf2);
|
||||||
goto out_search;
|
|
||||||
} else {
|
|
||||||
searchstr = strdup(token);
|
|
||||||
}
|
|
||||||
n = mympd_search(mpd.buf, p_charbuf2, uint_buf, searchstr);
|
|
||||||
free(searchstr);
|
|
||||||
free(p_charbuf2);
|
|
||||||
out_search:
|
|
||||||
free(p_charbuf);
|
|
||||||
break;
|
break;
|
||||||
case MPD_API_SEND_SHUFFLE:
|
case MPD_API_SEND_SHUFFLE:
|
||||||
mpd_run_shuffle(mpd.conn);
|
mpd_run_shuffle(mpd.conn);
|
||||||
break;
|
break;
|
||||||
case MPD_API_SEND_MESSAGE:
|
case MPD_API_SEND_MESSAGE:
|
||||||
p_charbuf = strdup(msg.p);
|
je = json_scanf(msg.p, msg.len, "{ data: { channel:%Q, text:%Q } }", &p_charbuf1, &p_charbuf2);
|
||||||
if(strcmp(strtok(p_charbuf, ","), "MPD_API_SEND_MESSAGE"))
|
if (je == 2)
|
||||||
goto out_send_message;
|
mpd_run_send_message(mpd.conn, p_charbuf1, p_charbuf2);
|
||||||
|
free(p_charbuf1);
|
||||||
if((token = strtok(NULL, ",")) == NULL)
|
free(p_charbuf2);
|
||||||
goto out_send_message;
|
|
||||||
|
|
||||||
free(p_charbuf);
|
|
||||||
p_charbuf = strdup(get_arg1(msg.p));
|
|
||||||
|
|
||||||
if ( strtok(p_charbuf, ",") == NULL )
|
|
||||||
goto out_send_message;
|
|
||||||
|
|
||||||
if ( (token = strtok(NULL, ",")) == NULL )
|
|
||||||
goto out_send_message;
|
|
||||||
|
|
||||||
mpd_run_send_message(mpd.conn, p_charbuf, token);
|
|
||||||
out_send_message:
|
|
||||||
free(p_charbuf);
|
|
||||||
break;
|
break;
|
||||||
case MPD_API_RM_PLAYLIST:
|
case MPD_API_RM_PLAYLIST:
|
||||||
p_charbuf = strdup(msg.p);
|
je = json_scanf(msg.p, msg.len, "{ data: { plist:%Q } }", &p_charbuf1);
|
||||||
if(strcmp(strtok(p_charbuf, ","), "MPD_API_RM_PLAYLIST"))
|
if (je == 1)
|
||||||
goto out_rm_playlist;
|
mpd_run_rm(mpd.conn, p_charbuf1);
|
||||||
|
free(p_charbuf1);
|
||||||
if((token = strtok(NULL, ",")) == NULL)
|
|
||||||
goto out_rm_playlist;
|
|
||||||
|
|
||||||
free(p_charbuf);
|
|
||||||
p_charbuf = strdup(msg.p);
|
|
||||||
mpd_run_rm(mpd.conn, get_arg1(p_charbuf));
|
|
||||||
out_rm_playlist:
|
|
||||||
free(p_charbuf);
|
|
||||||
break;
|
break;
|
||||||
case MPD_API_GET_SETTINGS:
|
case MPD_API_GET_SETTINGS:
|
||||||
n = mympd_put_settings(mpd.buf);
|
n = mympd_put_settings(mpd.buf);
|
||||||
@ -499,24 +288,19 @@ out_rm_playlist:
|
|||||||
n = mympd_get_stats(mpd.buf);
|
n = mympd_get_stats(mpd.buf);
|
||||||
break;
|
break;
|
||||||
case MPD_API_SET_REPLAYGAIN:
|
case MPD_API_SET_REPLAYGAIN:
|
||||||
p_charbuf = strdup(msg.p);
|
je = json_scanf(msg.p, msg.len, "{ data: { mode:%Q } }", &p_charbuf1);
|
||||||
if(strcmp(strtok(p_charbuf, ","), "MPD_API_SET_REPLAYGAIN"))
|
if (je == 1)
|
||||||
goto out_set_replaygain;
|
{
|
||||||
|
mpd_send_command(mpd.conn, "replay_gain_mode", p_charbuf1, NULL);
|
||||||
if((token = strtok(NULL, ",")) == NULL)
|
|
||||||
goto out_set_replaygain;
|
|
||||||
|
|
||||||
free(p_charbuf);
|
|
||||||
p_charbuf = strdup(msg.p);
|
|
||||||
mpd_send_command(mpd.conn, "replay_gain_mode", get_arg1(p_charbuf), NULL);
|
|
||||||
struct mpd_pair *pair;
|
struct mpd_pair *pair;
|
||||||
while ((pair = mpd_recv_pair(mpd.conn)) != NULL) {
|
while ((pair = mpd_recv_pair(mpd.conn)) != NULL) {
|
||||||
mpd_return_pair(mpd.conn, pair);
|
mpd_return_pair(mpd.conn, pair);
|
||||||
}
|
}
|
||||||
out_set_replaygain:
|
}
|
||||||
free(p_charbuf);
|
free(p_charbuf1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
free(cmd);
|
||||||
|
|
||||||
if(mpd.conn_state == MPD_CONNECTED && mpd_connection_get_error(mpd.conn) != MPD_ERROR_SUCCESS)
|
if(mpd.conn_state == MPD_CONNECTED && mpd_connection_get_error(mpd.conn) != MPD_ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
@ -532,10 +316,9 @@ out_set_replaygain:
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(n > 0) {
|
if(n > 0) {
|
||||||
|
|
||||||
if(is_websocket(nc)) {
|
if(is_websocket(nc)) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stdout,"Send response over websocket:\n %s\n",mpd.buf);
|
fprintf(stdout,"Send websocket response:\n %s\n",mpd.buf);
|
||||||
#endif
|
#endif
|
||||||
mg_send_websocket_frame(nc, WEBSOCKET_OP_TEXT, mpd.buf, n);
|
mg_send_websocket_frame(nc, WEBSOCKET_OP_TEXT, mpd.buf, n);
|
||||||
}
|
}
|
||||||
|
@ -133,7 +133,6 @@ struct t_mpd_client_session {
|
|||||||
};
|
};
|
||||||
|
|
||||||
void mympd_poll(struct mg_mgr *s);
|
void mympd_poll(struct mg_mgr *s);
|
||||||
void callback_mympd_jsonrpc(struct mg_connection *nc, const struct mg_str msg);
|
|
||||||
void callback_mympd(struct mg_connection *nc, const struct mg_str msg);
|
void callback_mympd(struct mg_connection *nc, const struct mg_str msg);
|
||||||
int mympd_close_handler(struct mg_connection *c);
|
int mympd_close_handler(struct mg_connection *c);
|
||||||
int mympd_put_state(char *buffer, int *current_song_id, int *next_song_id, unsigned *queue_version);
|
int mympd_put_state(char *buffer, int *current_song_id, int *next_song_id, unsigned *queue_version);
|
||||||
|
28
src/mympd.c
28
src/mympd.c
@ -44,21 +44,16 @@ static void signal_handler(int sig_num) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void handle_api(struct mg_connection *nc, struct http_message *hm) {
|
static void handle_api(struct mg_connection *nc, struct http_message *hm) {
|
||||||
mg_printf(nc, "%s", "HTTP/1.1 200 OK\r\nTransfer-Encoding: chunked\r\n\r\n");
|
if(!is_websocket(nc)) {
|
||||||
|
mg_printf(nc, "%s", "HTTP/1.1 200 OK\r\nTransfer-Encoding: chunked\r\nContent-Type: application/json\r\n\r\n");
|
||||||
|
}
|
||||||
char buf[1000] = {0};
|
char buf[1000] = {0};
|
||||||
memcpy(buf, hm->body.p,sizeof(buf) - 1 < hm->body.len ? sizeof(buf) - 1 : hm->body.len);
|
memcpy(buf, hm->body.p,sizeof(buf) - 1 < hm->body.len ? sizeof(buf) - 1 : hm->body.len);
|
||||||
struct mg_str d = {buf, strlen(buf)};
|
struct mg_str d = {buf, strlen(buf)};
|
||||||
callback_mympd(nc, d);
|
callback_mympd(nc, d);
|
||||||
|
if(!is_websocket(nc)) {
|
||||||
mg_send_http_chunk(nc, "", 0); /* Send empty chunk, the end of response */
|
mg_send_http_chunk(nc, "", 0); /* Send empty chunk, the end of response */
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_jsonrpc(struct mg_connection *nc, struct http_message *hm) {
|
|
||||||
mg_printf(nc, "%s", "HTTP/1.1 200 OK\r\nTransfer-Encoding: chunked\r\n\r\n");
|
|
||||||
char buf[1000] = {0};
|
|
||||||
memcpy(buf, hm->body.p,sizeof(buf) - 1 < hm->body.len ? sizeof(buf) - 1 : hm->body.len);
|
|
||||||
struct mg_str d = {buf, strlen(buf)};
|
|
||||||
callback_mympd_jsonrpc(nc, d);
|
|
||||||
mg_send_http_chunk(nc, "", 0); /* Send empty chunk, the end of response */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ev_handler(struct mg_connection *nc, int ev, void *ev_data) {
|
static void ev_handler(struct mg_connection *nc, int ev, void *ev_data) {
|
||||||
@ -67,17 +62,7 @@ static void ev_handler(struct mg_connection *nc, int ev, void *ev_data) {
|
|||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stdout,"New Websocket connection\n");
|
fprintf(stdout,"New Websocket connection\n");
|
||||||
#endif
|
#endif
|
||||||
struct mg_str d = {(char *) "MPD_API_WELCOME", 15 };
|
struct mg_str d = {(char *) "{\"cmd\":\"MPD_API_WELCOME\"}", 25 };
|
||||||
callback_mympd(nc, d);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case MG_EV_WEBSOCKET_FRAME: {
|
|
||||||
struct websocket_message *wm = (struct websocket_message *) ev_data;
|
|
||||||
wm->data[wm->size]='\0';
|
|
||||||
struct mg_str d = {(char *) wm->data, wm->size};
|
|
||||||
#ifdef DEBUG
|
|
||||||
fprintf(stdout,"Websocket request: %s\n",wm->data);
|
|
||||||
#endif
|
|
||||||
callback_mympd(nc, d);
|
callback_mympd(nc, d);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -89,9 +74,6 @@ static void ev_handler(struct mg_connection *nc, int ev, void *ev_data) {
|
|||||||
if (mg_vcmp(&hm->uri, "/api") == 0) {
|
if (mg_vcmp(&hm->uri, "/api") == 0) {
|
||||||
handle_api(nc, hm);
|
handle_api(nc, hm);
|
||||||
}
|
}
|
||||||
else if (mg_vcmp(&hm->uri, "/jsonrpc") == 0) {
|
|
||||||
handle_jsonrpc(nc, hm);
|
|
||||||
}
|
|
||||||
else {
|
else {
|
||||||
mg_serve_http(nc, hm, s_http_server_opts);
|
mg_serve_http(nc, hm, s_http_server_opts);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user