From 14ef6648c6f69bf9928f9d7cd3cf1c3e663a2204 Mon Sep 17 00:00:00 2001 From: jcorporation Date: Sun, 27 May 2018 15:13:42 +0100 Subject: [PATCH] Configurable coverimage filename --- README.md | 1 + mympd.1 | 7 +++++-- src/mpd_client.c | 5 +++-- src/mpd_client.h | 7 ++++--- src/mympd.c | 8 +++++++- 5 files changed, 20 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 4461746..e4afbe2 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,7 @@ Usage: ./mympd [OPTION]... -s, --streamport connect to mpd http stream at port [8000] -u, --user drop priviliges to user after socket bind -m, --mpdpass specifies the password to use when connecting to mpd + -i, --coverimage filename for coverimage [folder.jpg] -V, --version get version --help this help ``` diff --git a/mympd.1 b/mympd.1 index 31c9f78..80d2911 100644 --- a/mympd.1 +++ b/mympd.1 @@ -30,12 +30,15 @@ specifies the port for the webserver to listen to, defaults to 8080 \fB-s\fR, \fB\-\-streamport PORT connect to mpd http stream at port [8000] .TP -\fB\-u\fR, \fB\-\-user username\fR +\fB\-u\fR, \fB\-\-user USERNAME\fR drop privileges to the provided username after socket binding .TP -\fB\-m\fR, \fB\-\-mpdpass password\fR +\fB\-m\fR, \fB\-\-mpdpass PASSWORD\fR specifies the password to use when connecting to mpd .TP +\fB-i\fR, \fB\-\-coverimage FILENAME\fR +filename for coverimage [folder.jpg] +.TP \fB\-V\fR, \fB\-\-version\fR print version and exit .TP diff --git a/src/mpd_client.c b/src/mpd_client.c index 8ca59da..ec5b8d5 100644 --- a/src/mpd_client.c +++ b/src/mpd_client.c @@ -299,8 +299,9 @@ out_send_message: break; case MPD_API_GET_OPTIONS: n = snprintf(mpd.buf, MAX_SIZE, "{\"type\":\"mpdoptions\", \"data\": " - "{\"mpdhost\" : \"%s\", \"mpdport\": \"%d\", \"passwort_set\": %s, \"streamport\": \"%d\"}" - "}", mpd.host, mpd.port, mpd.password ? "true" : "false", streamport); + "{\"mpdhost\" : \"%s\", \"mpdport\": \"%d\", \"passwort_set\": %s, " + "\"streamport\": \"%d\",\"coverimage\": \"%s\"}" + "}", mpd.host, mpd.port, mpd.password ? "true" : "false", streamport, coverimage); break; } diff --git a/src/mpd_client.h b/src/mpd_client.h index 8316463..f53b8df 100644 --- a/src/mpd_client.h +++ b/src/mpd_client.h @@ -89,10 +89,10 @@ enum mpd_conn_states { struct t_mpd { int port; - int local_port; + int local_port; char host[128]; char *password; - char *gpass; + char *gpass; struct mpd_connection *conn; enum mpd_conn_states conn_state; @@ -106,6 +106,7 @@ struct t_mpd { } mpd; int streamport; +char coverimage[40]; struct t_mpd_client_session { int song_id; @@ -121,7 +122,7 @@ int mpd_put_current_song(char *buffer); int mpd_put_queue(char *buffer, unsigned int offset); int mpd_put_browse(char *buffer, char *path, unsigned int offset); int mpd_search(char *buffer, char *searchstr); -int mpd_search_queue(char *buffer, char *mp3tag, char *searchstr); +int mpd_search_queue(char *buffer, char *mpdtagtype, char *searchstr); void mpd_disconnect(); #endif diff --git a/src/mympd.c b/src/mympd.c index 952ceca..4364387 100644 --- a/src/mympd.c +++ b/src/mympd.c @@ -95,6 +95,7 @@ int main(int argc, char **argv) mpd.gpass = NULL; strcpy(mpd.host, "127.0.0.1"); streamport = 8000; + strcpy(coverimage, "folder.jpg"); static struct option long_options[] = { {"digest", required_argument, 0, 'D'}, @@ -107,10 +108,11 @@ int main(int argc, char **argv) {"help", no_argument, 0, 0 }, {"mpdpass", required_argument, 0, 'm'}, {"streamport", required_argument, 0, 's'}, + {"coverimage", required_argument, 0, 'i'}, {0, 0, 0, 0 } }; - while((n = getopt_long(argc, argv, "D:h:p:l:w:u:d:v:m:s", + while((n = getopt_long(argc, argv, "D:h:p:l:w:u:d:v:m:s:i:", long_options, &option_index)) != -1) { switch (n) { case 'D': @@ -138,6 +140,9 @@ int main(int argc, char **argv) case 's': streamport = atoi(optarg); break; + case 'i': + strncpy(coverimage, optarg, sizeof(coverimage)); + break; case 'v': fprintf(stdout, "myMPD %d.%d.%d\n" "Copyright (C) 2018 Juergen Mang \n" @@ -157,6 +162,7 @@ int main(int argc, char **argv) " -v, --version\t\t\tget version\n" " -m, --mpdpass \tspecifies the password to use when connecting to mpd\n" " -s, --streamport \tconnect to mpd http stream at port [8000]\n" + " -i, --coverimage \tfilename for coverimage [folder.jpg]\n" " --help\t\t\t\tthis help\n" , argv[0]); return EXIT_FAILURE;