mirror of
https://github.com/SuperBFG7/ympd
synced 2024-11-04 22:06:16 +00:00
fix: source code formating
This commit is contained in:
parent
83a3933056
commit
a5bddf4b4a
@ -589,7 +589,7 @@ function webSocketConnect() {
|
||||
}
|
||||
|
||||
socket.onmessage = function got_packet(msg) {
|
||||
if(msg.data === last_state || msg.data.length == 0)
|
||||
if (msg.data === last_state || msg.data.length == 0)
|
||||
return;
|
||||
|
||||
try {
|
||||
@ -606,7 +606,7 @@ function webSocketConnect() {
|
||||
showNotification('myMPD lost connection to MPD', '', '', 'danger');
|
||||
break;
|
||||
case 'update_queue':
|
||||
if(app.current.app === 'Queue')
|
||||
if (app.current.app === 'Queue')
|
||||
getQueue();
|
||||
break;
|
||||
case 'song_change':
|
||||
@ -796,7 +796,7 @@ function parseState(obj) {
|
||||
} else {
|
||||
domCache.volumeControl.classList.remove('hide');
|
||||
domCache.volumePrct.innerText = obj.data.volume + ' %';
|
||||
if(obj.data.volume == 0)
|
||||
if (obj.data.volume == 0)
|
||||
domCache.volumeIcon.innerText = 'volume_off';
|
||||
else if (obj.data.volume < 50)
|
||||
domCache.volumeIcon.innerText = 'volume_down';
|
||||
@ -903,7 +903,7 @@ function parseQueue(obj) {
|
||||
else
|
||||
tbody.append(row);
|
||||
}
|
||||
var tr_length=tr.length - 1;
|
||||
var tr_length = tr.length - 1;
|
||||
for (var i = tr_length; i >= nrItems; i --) {
|
||||
tr[i].remove();
|
||||
}
|
||||
@ -973,7 +973,7 @@ function parseFilesystem(obj) {
|
||||
else
|
||||
tbody.append(row);
|
||||
}
|
||||
var tr_length=tr.length - 1;
|
||||
var tr_length = tr.length - 1;
|
||||
for (var i = tr_length; i >= nrItems; i --) {
|
||||
tr[i].remove();
|
||||
}
|
||||
@ -1060,7 +1060,7 @@ function parsePlaylists(obj) {
|
||||
tbody.append(row);
|
||||
}
|
||||
}
|
||||
var tr_length=tr.length - 1;
|
||||
var tr_length = tr.length - 1;
|
||||
for (var i = tr_length; i >= nrItems; i --) {
|
||||
tr[i].remove();
|
||||
}
|
||||
@ -1079,7 +1079,7 @@ function parsePlaylists(obj) {
|
||||
}
|
||||
|
||||
function parseListDBtags(obj) {
|
||||
if(app.current.app !== 'Browse' && app.current.tab !== 'Database' && app.current.view !== 'Artist') return;
|
||||
if (app.current.app !== 'Browse' && app.current.tab !== 'Database' && app.current.view !== 'Artist') return;
|
||||
|
||||
if (obj.tagtype == 'AlbumArtist') {
|
||||
document.getElementById('BrowseDatabaseAlbumCards').classList.add('hide');
|
||||
@ -1148,7 +1148,7 @@ function parseListDBtags(obj) {
|
||||
|
||||
sendAPI({"cmd":"MPD_API_GET_ARTISTALBUMTITLES", "data": { "albumartist": obj.searchstr, "album": obj.data[i].value}}, parseListTitles);
|
||||
}
|
||||
var cards_length=cards.length - 1;
|
||||
var cards_length = cards.length - 1;
|
||||
for (var i = cards_length; i >= nrItems; i --) {
|
||||
cards[i].remove();
|
||||
}
|
||||
@ -1491,7 +1491,7 @@ function updateDB() {
|
||||
}
|
||||
|
||||
function clickPlay() {
|
||||
if( playstate != 'play')
|
||||
if (playstate != 'play')
|
||||
sendAPI({"cmd": "MPD_API_SET_PLAY"});
|
||||
else
|
||||
sendAPI({"cmd": "MPD_API_SET_PAUSE"});
|
||||
@ -1690,7 +1690,7 @@ function songChange(obj) {
|
||||
|
||||
document.getElementById('album-cover').style.backgroundImage = 'url("' + obj.data.cover + '")';
|
||||
|
||||
if(typeof obj.data.artist != 'undefined' && obj.data.artist.length > 0 && obj.data.artist != '-') {
|
||||
if (typeof obj.data.artist != 'undefined' && obj.data.artist.length > 0 && obj.data.artist != '-') {
|
||||
textNotification += obj.data.artist;
|
||||
htmlNotification += obj.data.artist;
|
||||
pageTitle += obj.data.artist + ' - ';
|
||||
@ -1698,7 +1698,7 @@ function songChange(obj) {
|
||||
} else {
|
||||
document.getElementById('artist').innerText = '';
|
||||
}
|
||||
if(typeof obj.data.album != 'undefined' && obj.data.album.length > 0 && obj.data.album != '-') {
|
||||
if (typeof obj.data.album != 'undefined' && obj.data.album.length > 0 && obj.data.album != '-') {
|
||||
textNotification += ' - ' + obj.data.album;
|
||||
htmlNotification += '<br/>' + obj.data.album;
|
||||
document.getElementById('album').innerText = obj.data.album;
|
||||
@ -1706,7 +1706,7 @@ function songChange(obj) {
|
||||
else {
|
||||
document.getElementById('album').innerText = '';
|
||||
}
|
||||
if(typeof obj.data.title != 'undefined' && obj.data.title.length > 0) {
|
||||
if (typeof obj.data.title != 'undefined' && obj.data.title.length > 0) {
|
||||
pageTitle += obj.data.title;
|
||||
document.getElementById('currenttrack').innerText = obj.data.title;
|
||||
} else {
|
||||
|
@ -46,7 +46,7 @@ const char * mpd_cmd_strs[] = {
|
||||
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++)
|
||||
if(!strncmp(cmd, mpd_cmd_strs[i], strlen(mpd_cmd_strs[i])))
|
||||
if (!strncmp(cmd, mpd_cmd_strs[i], strlen(mpd_cmd_strs[i])))
|
||||
return i;
|
||||
|
||||
return -1;
|
||||
@ -73,7 +73,7 @@ void callback_mympd(struct mg_connection *nc, const struct mg_str msg)
|
||||
else
|
||||
cmd_id = get_cmd_id("MPD_API_UNKNOWN");
|
||||
|
||||
if(cmd_id == -1)
|
||||
if (cmd_id == -1)
|
||||
cmd_id = get_cmd_id("MPD_API_UNKNOWN");
|
||||
|
||||
switch(cmd_id) {
|
||||
@ -342,7 +342,7 @@ void callback_mympd(struct mg_connection *nc, const struct mg_str msg)
|
||||
je = json_scanf(msg.p, msg.len, "{ data: { uri:%Q } }", &p_charbuf1);
|
||||
if (je == 1) {
|
||||
int_buf = mpd_run_add_id(mpd.conn, p_charbuf1);
|
||||
if(int_buf != -1)
|
||||
if (int_buf != -1)
|
||||
mpd_run_play_id(mpd.conn, int_buf);
|
||||
free(p_charbuf1);
|
||||
n = snprintf(mpd.buf, MAX_SIZE, "{\"type\": \"result\", \"data\": \"ok\"}");
|
||||
@ -479,12 +479,12 @@ static int mympd_notify_callback(struct mg_connection *c, const char *param) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(!c->user_data)
|
||||
if (!c->user_data)
|
||||
c->user_data = calloc(1, sizeof(struct t_mpd_client_session));
|
||||
|
||||
struct t_mpd_client_session *s = (struct t_mpd_client_session *)c->user_data;
|
||||
|
||||
if(mpd.conn_state != MPD_CONNECTED) {
|
||||
if (mpd.conn_state != MPD_CONNECTED) {
|
||||
n=snprintf(mpd.buf, MAX_SIZE, "{\"type\":\"disconnected\"}");
|
||||
#ifdef DEBUG
|
||||
fprintf(stdout,"Notify: disconnected\n");
|
||||
@ -497,7 +497,7 @@ static int mympd_notify_callback(struct mg_connection *c, const char *param) {
|
||||
#endif
|
||||
mg_send_websocket_frame(c, WEBSOCKET_OP_TEXT, mpd.buf, strlen(mpd.buf));
|
||||
|
||||
if(s->song_id != mpd.song_id) {
|
||||
if (s->song_id != mpd.song_id) {
|
||||
n=mympd_put_current_song(mpd.buf);
|
||||
#ifdef DEBUG
|
||||
fprintf(stdout,"Notify: %s\n",mpd.buf);
|
||||
@ -506,7 +506,7 @@ static int mympd_notify_callback(struct mg_connection *c, const char *param) {
|
||||
s->song_id = mpd.song_id;
|
||||
}
|
||||
|
||||
if(s->queue_version != mpd.queue_version) {
|
||||
if (s->queue_version != mpd.queue_version) {
|
||||
n=snprintf(mpd.buf, MAX_SIZE, "{\"type\":\"update_queue\"}");
|
||||
#ifdef DEBUG
|
||||
fprintf(stdout,"Notify: update_queue\n");
|
||||
@ -539,7 +539,7 @@ void mympd_poll(struct mg_mgr *s) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(mpd.password && !mpd_run_password(mpd.conn, mpd.password)) {
|
||||
if (mpd.password && !mpd_run_password(mpd.conn, mpd.password)) {
|
||||
fprintf(stderr, "MPD connection: %s\n", mpd_connection_get_error_message(mpd.conn));
|
||||
for (struct mg_connection *c = mg_next(s, NULL); c != NULL; c = mg_next(s, c)) {
|
||||
mympd_notify_callback(c, mpd_connection_get_error_message(mpd.conn));
|
||||
@ -558,7 +558,7 @@ void mympd_poll(struct mg_mgr *s) {
|
||||
|
||||
case MPD_DISCONNECT:
|
||||
case MPD_RECONNECT:
|
||||
if(mpd.conn != NULL)
|
||||
if (mpd.conn != NULL)
|
||||
mpd_connection_free(mpd.conn);
|
||||
mpd.conn = NULL;
|
||||
mpd.conn_state = MPD_DISCONNECTED;
|
||||
@ -670,7 +670,7 @@ int mympd_put_settings(char *buffer) {
|
||||
int je;
|
||||
struct json_out out = JSON_OUT_BUF(buffer, MAX_SIZE);
|
||||
struct mympd_state { int a; int b; } state = { .a = 0, .b = 0 };
|
||||
if( access( mpd.statefile, F_OK ) != -1 ) {
|
||||
if (access( mpd.statefile, F_OK ) != -1 ) {
|
||||
char *content = json_fread(mpd.statefile);
|
||||
je = json_scanf(content, strlen(content), "{notificationWeb: %d, notificationPage: %d}", &state.a, &state.b);
|
||||
if (je != 2) {
|
||||
@ -906,7 +906,7 @@ int mympd_put_browse(char *buffer, char *path, unsigned int offset, char *filter
|
||||
const struct mpd_song *song;
|
||||
const struct mpd_directory *dir;
|
||||
entity_count ++;
|
||||
if(entity_count > offset && entity_count <= offset+MAX_ELEMENTS_PER_PAGE) {
|
||||
if (entity_count > offset && entity_count <= offset+MAX_ELEMENTS_PER_PAGE) {
|
||||
switch (mpd_entity_get_type(entity)) {
|
||||
case MPD_ENTITY_TYPE_UNKNOWN:
|
||||
entity_count --;
|
||||
@ -1003,7 +1003,7 @@ int mympd_put_db_tag(char *buffer, unsigned int offset, char *mpdtagtype, char *
|
||||
int len;
|
||||
struct json_out out = JSON_OUT_BUF(buffer, MAX_SIZE);
|
||||
|
||||
if(mpd_search_db_tags(mpd.conn, mpd_tag_name_parse(mpdtagtype)) == false)
|
||||
if (mpd_search_db_tags(mpd.conn, mpd_tag_name_parse(mpdtagtype)) == false)
|
||||
RETURN_ERROR_AND_RECOVER("mpd_search_db_tags");
|
||||
|
||||
if (mpd_tag_name_parse(mpdsearchtagtype) != MPD_TAG_UNKNOWN) {
|
||||
@ -1011,13 +1011,13 @@ int mympd_put_db_tag(char *buffer, unsigned int offset, char *mpdtagtype, char *
|
||||
RETURN_ERROR_AND_RECOVER("mpd_search_add_tag_constraint");
|
||||
}
|
||||
|
||||
if(mpd_search_commit(mpd.conn) == false)
|
||||
if (mpd_search_commit(mpd.conn) == false)
|
||||
RETURN_ERROR_AND_RECOVER("mpd_search_commit");
|
||||
|
||||
len = json_printf(&out, "{type: listDBtags, data: [ ");
|
||||
while((pair = mpd_recv_pair_tag(mpd.conn, mpd_tag_name_parse(mpdtagtype))) != NULL) {
|
||||
entity_count ++;
|
||||
if(entity_count > offset && entity_count <= offset+MAX_ELEMENTS_PER_PAGE) {
|
||||
if (entity_count > offset && entity_count <= offset+MAX_ELEMENTS_PER_PAGE) {
|
||||
if (strncmp(filter,"-",1) == 0 || strncasecmp(filter,pair->value,1) == 0 ||
|
||||
( strncmp(filter,"0",1) == 0 && isalpha(*pair->value) == 0 )
|
||||
) {
|
||||
@ -1056,7 +1056,7 @@ int mympd_put_songs_in_album(char *buffer, char *albumartist, char *album) {
|
||||
char cover[500];
|
||||
struct json_out out = JSON_OUT_BUF(buffer, MAX_SIZE);
|
||||
|
||||
if(mpd_search_db_songs(mpd.conn, true) == false) {
|
||||
if (mpd_search_db_songs(mpd.conn, true) == false) {
|
||||
RETURN_ERROR_AND_RECOVER("mpd_search_db_songs");
|
||||
}
|
||||
|
||||
@ -1066,14 +1066,14 @@ int mympd_put_songs_in_album(char *buffer, char *albumartist, char *album) {
|
||||
if (mpd_search_add_tag_constraint(mpd.conn, MPD_OPERATOR_DEFAULT, MPD_TAG_ALBUM, album) == false)
|
||||
RETURN_ERROR_AND_RECOVER("mpd_search_add_tag_constraint");
|
||||
|
||||
if(mpd_search_commit(mpd.conn) == false)
|
||||
if (mpd_search_commit(mpd.conn) == false)
|
||||
RETURN_ERROR_AND_RECOVER("mpd_search_commit");
|
||||
else {
|
||||
len = json_printf(&out, "{ type: listTitles, data: [ ");
|
||||
|
||||
while((song = mpd_recv_song(mpd.conn)) != NULL) {
|
||||
entity_count ++;
|
||||
if(entity_count <= MAX_ELEMENTS_PER_PAGE) {
|
||||
if (entity_count <= MAX_ELEMENTS_PER_PAGE) {
|
||||
if (entities_returned ++) len += json_printf(&out, ", ");
|
||||
else mympd_get_cover(mpd_song_get_uri(song),cover,500);
|
||||
len += json_printf(&out, "{ type: song, uri: %Q, duration: %d, title: %Q, track: %Q }",
|
||||
@ -1114,7 +1114,7 @@ int mympd_put_playlists(char *buffer, unsigned int offset, char *filter) {
|
||||
|
||||
while((pl = mpd_recv_playlist(mpd.conn)) != NULL) {
|
||||
entity_count ++;
|
||||
if(entity_count > offset && entity_count <= offset+MAX_ELEMENTS_PER_PAGE) {
|
||||
if (entity_count > offset && entity_count <= offset+MAX_ELEMENTS_PER_PAGE) {
|
||||
plpath = mpd_playlist_get_path(pl);
|
||||
if (strncmp(filter,"-",1) == 0 || strncasecmp(filter,plpath,1) == 0 ||
|
||||
( strncmp(filter,"0",1) == 0 && isalpha(*plpath) == 0 )
|
||||
@ -1203,9 +1203,8 @@ int mympd_search(char *buffer, char *mpdtagtype, unsigned int offset, char *sear
|
||||
int len;
|
||||
struct json_out out = JSON_OUT_BUF(buffer, MAX_SIZE);
|
||||
|
||||
if(mpd_search_db_songs(mpd.conn, false) == false) {
|
||||
if (mpd_search_db_songs(mpd.conn, false) == false)
|
||||
RETURN_ERROR_AND_RECOVER("mpd_search_db_songs");
|
||||
}
|
||||
|
||||
if (mpd_tag_name_parse(mpdtagtype) != MPD_TAG_UNKNOWN) {
|
||||
if (mpd_search_add_tag_constraint(mpd.conn, MPD_OPERATOR_DEFAULT, mpd_tag_name_parse(mpdtagtype), searchstr) == false)
|
||||
@ -1216,14 +1215,14 @@ int mympd_search(char *buffer, char *mpdtagtype, unsigned int offset, char *sear
|
||||
RETURN_ERROR_AND_RECOVER("mpd_search_add_any_tag_constraint");
|
||||
}
|
||||
|
||||
if(mpd_search_commit(mpd.conn) == false)
|
||||
if (mpd_search_commit(mpd.conn) == false)
|
||||
RETURN_ERROR_AND_RECOVER("mpd_search_commit");
|
||||
else {
|
||||
len = json_printf(&out, "{ type: search, data: [ ");
|
||||
|
||||
while((song = mpd_recv_song(mpd.conn)) != NULL) {
|
||||
entity_count ++;
|
||||
if(entity_count > offset && entity_count <= offset+MAX_ELEMENTS_PER_PAGE) {
|
||||
if (entity_count > offset && entity_count <= offset+MAX_ELEMENTS_PER_PAGE) {
|
||||
if (entities_returned ++) len += json_printf(&out, ", ");
|
||||
len += json_printf(&out, "{ type: song, uri: %Q, album: %Q, artist: %Q, duration: %d, title: %Q, name: %Q }",
|
||||
mpd_song_get_uri(song),
|
||||
@ -1256,7 +1255,7 @@ int mympd_search_add(char *buffer,char *mpdtagtype, char *searchstr) {
|
||||
struct json_out out = JSON_OUT_BUF(buffer, MAX_SIZE);
|
||||
len = 0;
|
||||
|
||||
if(mpd_search_add_db_songs(mpd.conn, false) == false) {
|
||||
if (mpd_search_add_db_songs(mpd.conn, false) == false) {
|
||||
RETURN_ERROR_AND_RECOVER("mpd_search_add_db_songs");
|
||||
}
|
||||
|
||||
@ -1269,7 +1268,7 @@ int mympd_search_add(char *buffer,char *mpdtagtype, char *searchstr) {
|
||||
RETURN_ERROR_AND_RECOVER("mpd_search_add_any_tag_constraint");
|
||||
}
|
||||
|
||||
if(mpd_search_commit(mpd.conn) == false)
|
||||
if (mpd_search_commit(mpd.conn) == false)
|
||||
RETURN_ERROR_AND_RECOVER("mpd_search_commit");
|
||||
|
||||
while((song = mpd_recv_song(mpd.conn)) != NULL) {
|
||||
@ -1288,7 +1287,7 @@ int mympd_search_queue(char *buffer, char *mpdtagtype, unsigned int offset, char
|
||||
int len;
|
||||
struct json_out out = JSON_OUT_BUF(buffer, MAX_SIZE);
|
||||
|
||||
if(mpd_search_queue_songs(mpd.conn, false) == false) {
|
||||
if (mpd_search_queue_songs(mpd.conn, false) == false) {
|
||||
RETURN_ERROR_AND_RECOVER("mpd_search_queue_songs");
|
||||
}
|
||||
|
||||
@ -1301,14 +1300,14 @@ int mympd_search_queue(char *buffer, char *mpdtagtype, unsigned int offset, char
|
||||
RETURN_ERROR_AND_RECOVER("mpd_search_add_any_tag_constraint");
|
||||
}
|
||||
|
||||
if(mpd_search_commit(mpd.conn) == false)
|
||||
if (mpd_search_commit(mpd.conn) == false)
|
||||
RETURN_ERROR_AND_RECOVER("mpd_search_commit");
|
||||
else {
|
||||
len = json_printf(&out, "{ type: queuesearch, data: [ ");
|
||||
|
||||
while((song = mpd_recv_song(mpd.conn)) != NULL) {
|
||||
entity_count ++;
|
||||
if(entity_count > offset && entity_count <= offset+MAX_ELEMENTS_PER_PAGE) {
|
||||
if (entity_count > offset && entity_count <= offset+MAX_ELEMENTS_PER_PAGE) {
|
||||
if (entities_returned ++) len += json_printf(&out, ", ");
|
||||
len += json_printf(&out, "{ type: song, id: %d, pos: %d, album: %Q, artist: %Q, duration: %d, title: %Q }",
|
||||
mpd_song_get_id(song),
|
||||
|
@ -249,7 +249,7 @@ int main(int argc, char **argv) {
|
||||
}
|
||||
}
|
||||
|
||||
if(run_as_user != NULL) {
|
||||
if (run_as_user != NULL) {
|
||||
printf("Droping privileges\n");
|
||||
struct passwd *pw;
|
||||
if ((pw = getpwnam(run_as_user)) == NULL) {
|
||||
|
Loading…
Reference in New Issue
Block a user