From c8e33e9cc30e78511de9ad07fb39aa6309753bcf Mon Sep 17 00:00:00 2001 From: Brenden Matthews Date: Tue, 31 Jan 2006 03:32:26 +0000 Subject: [PATCH] mpd improvements git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky@521 7f574dfc-610e-0410-a909-a81674777703 --- README | 8 + doc/conky.1 | 8 + doc/variables.xml | 18 +++ src/conky.c | 75 ++++++++- src/conky.h | 3 + src/mpd.c | 387 +++++++++++++++++++++++++++++++--------------- 6 files changed, 369 insertions(+), 130 deletions(-) diff --git a/README b/README index e60d642a..97ad1dc0 100644 --- a/README +++ b/README @@ -733,6 +733,14 @@ VARIABLES Prints the MPD track field + mpd_name + Prints the MPD name field + + + mpd_file + Prints the file name of the current MPD song + + new_mails Unread mail count in mail spool. diff --git a/doc/conky.1 b/doc/conky.1 index 96d12066..c98a9c05 100644 --- a/doc/conky.1 +++ b/doc/conky.1 @@ -662,6 +662,14 @@ Repeat status (On/Off) \fBmpd_track\fR Prints the MPD track field +.TP +\fBmpd_name\fR +Prints the MPD name field + +.TP +\fBmpd_file\fR +Prints the file name of the current MPD song + .TP \fBnew_mails\fR Unread mail count in mail spool. diff --git a/doc/variables.xml b/doc/variables.xml index 6721a478..bd559209 100644 --- a/doc/variables.xml +++ b/doc/variables.xml @@ -818,6 +818,24 @@ + + + + + + Prints the MPD name field + + + + + + + + + Prints the file name of the current MPD song + + + diff --git a/src/conky.c b/src/conky.c index f738b6f1..dd54512e 100644 --- a/src/conky.c +++ b/src/conky.c @@ -883,10 +883,13 @@ enum text_object_type { OBJ_mpd_status, OBJ_mpd_host, OBJ_mpd_port, + OBJ_mpd_password, OBJ_mpd_bar, OBJ_mpd_elapsed, OBJ_mpd_length, OBJ_mpd_track, + OBJ_mpd_name, + OBJ_mpd_file, OBJ_mpd_percent, #endif #if defined(XMMS) || defined(BMP) || defined(AUDACIOUS) || defined(INFOPIPE) @@ -1150,12 +1153,59 @@ static void free_text_objects(unsigned int count, struct text_object *objs) break;*/ #ifdef MPD case OBJ_mpd_title: + if (info.mpd.title) { + free(info.mpd.title); + info.mpd.title = 0; + } + break; case OBJ_mpd_artist: + if (info.mpd.artist) { + free(info.mpd.artist); + info.mpd.artist = 0; + } + break; case OBJ_mpd_album: + if (info.mpd.album) { + free(info.mpd.album); + info.mpd.album = 0; + } + break; case OBJ_mpd_random: + if (info.mpd.random) { + free(info.mpd.random); + info.mpd.random = 0; + } + break; case OBJ_mpd_repeat: + if (info.mpd.repeat) { + free(info.mpd.repeat); + info.mpd.repeat = 0; + } + break; case OBJ_mpd_track: + if (info.mpd.track) { + free(info.mpd.track); + info.mpd.track = 0; + } + break; + case OBJ_mpd_name: + if (info.mpd.name) { + free(info.mpd.name); + info.mpd.name = 0; + } + break; + case OBJ_mpd_file: + if (info.mpd.file) { + free(info.mpd.file); + info.mpd.file = 0; + } + break; case OBJ_mpd_status: + if (info.mpd.status) { + free(info.mpd.status); + info.mpd.status = 0; + } + break; case OBJ_mpd_host: #endif #ifdef BMPX @@ -1865,6 +1915,8 @@ static struct text_object *construct_text_object(const char *s, const char *arg, END OBJ(mpd_elapsed, INFO_MPD) END OBJ(mpd_length, INFO_MPD) END OBJ(mpd_track, INFO_MPD) + END OBJ(mpd_name, INFO_MPD) + END OBJ(mpd_file, INFO_MPD) END OBJ(mpd_percent, INFO_MPD) END OBJ(mpd_album, INFO_MPD) END OBJ(mpd_vol, INFO_MPD) END OBJ(mpd_bitrate, @@ -3090,6 +3142,12 @@ static void generate_text_internal(char *p, int p_max_size, struct text_object * OBJ(mpd_track) { snprintf(p, p_max_size, "%s", cur->mpd.track); } + OBJ(mpd_name) { + snprintf(p, p_max_size, "%s", cur->mpd.name); + } + OBJ(mpd_file) { + snprintf(p, p_max_size, "%s", cur->mpd.file); + } OBJ(mpd_vol) { snprintf(p, p_max_size, "%i", cur->mpd.volume); } @@ -4763,7 +4821,14 @@ static void set_default_configurations(void) #ifdef MPD strcpy(info.mpd.host, "localhost"); info.mpd.port = 6600; - info.mpd.status = "Checking status..."; + info.mpd.status = NULL; + info.mpd.artist = NULL; + info.mpd.album = NULL; + info.mpd.title = NULL; + info.mpd.random = NULL; + info.mpd.track = NULL; + info.mpd.name = NULL; + info.mpd.file = NULL; #endif use_spacer = 0; #ifdef X11 @@ -4967,7 +5032,7 @@ else if (strcasecmp(name, a) == 0 || strcasecmp(name, b) == 0) #ifdef MPD CONF("mpd_host") { if (value) - strcpy(info.mpd.host, value); + strncpy(info.mpd.host, value, 127); else CONF_ERR; } @@ -4979,6 +5044,12 @@ else if (strcasecmp(name, a) == 0 || strcasecmp(name, b) == 0) CONF_ERR; } } + CONF("mpd_password") { + if (value) + strncpy(info.mpd.password, value, 127); + else + CONF_ERR; + } #endif CONF("cpu_avg_samples") { if (value) { diff --git a/src/conky.h b/src/conky.h index 881ebb93..87520adc 100644 --- a/src/conky.h +++ b/src/conky.h @@ -119,9 +119,12 @@ struct mpd_s { char *random; char *repeat; char *track; + char *name; + char *file; int volume; unsigned int port; char host[128]; + char password[128]; float progress; int bitrate; int length; diff --git a/src/mpd.c b/src/mpd.c index d015c05c..a1976352 100644 --- a/src/mpd.c +++ b/src/mpd.c @@ -9,31 +9,63 @@ void update_mpd() { struct information *current_info = &info; current_info->conn = - mpd_newConnection(current_info->mpd.host, - current_info->mpd.port, 10); + mpd_newConnection(current_info->mpd.host, + current_info->mpd.port, 10); + if (strlen(current_info->mpd.password) > 1) { + mpd_sendPasswordCommand(current_info->conn, + current_info->mpd.password); + mpd_finishCommand(current_info->conn); + } if (current_info->conn->error) { - //fprintf(stderr, "%s\n", current_info->conn->errorStr); + //ERR("%MPD error: s\n", current_info->conn->errorStr); mpd_closeConnection(current_info->conn); if (current_info->mpd.artist == NULL) current_info->mpd.artist = - malloc(TEXT_BUFFER_SIZE); + malloc(TEXT_BUFFER_SIZE); if (current_info->mpd.album == NULL) current_info->mpd.album = malloc(TEXT_BUFFER_SIZE); if (current_info->mpd.title == NULL) current_info->mpd.title = malloc(TEXT_BUFFER_SIZE); if (current_info->mpd.random == NULL) - current_info->mpd.random = malloc(TEXT_BUFFER_SIZE); + current_info->mpd.random = + malloc(TEXT_BUFFER_SIZE); if (current_info->mpd.repeat == NULL) - current_info->mpd.repeat = malloc(TEXT_BUFFER_SIZE); + current_info->mpd.repeat = + malloc(TEXT_BUFFER_SIZE); if (current_info->mpd.track == NULL) current_info->mpd.track = malloc(TEXT_BUFFER_SIZE); - strcpy(current_info->mpd.artist, "Unknown"); - strcpy(current_info->mpd.album, "Unknown"); - strcpy(current_info->mpd.title, "Unknown"); - strcpy(current_info->mpd.random, "Unknown"); - strcpy(current_info->mpd.repeat, "Unknown"); - strcpy(current_info->mpd.track, "Unknown"); - current_info->mpd.status = "MPD not responding"; + if (current_info->mpd.status == NULL) + current_info->mpd.status = + malloc(TEXT_BUFFER_SIZE); + if (current_info->mpd.name == NULL) + current_info->mpd.name = malloc(TEXT_BUFFER_SIZE); + if (current_info->mpd.file == NULL) + current_info->mpd.file = malloc(TEXT_BUFFER_SIZE); + strncpy(current_info->mpd.name, "Unknown", + TEXT_BUFFER_SIZE - 1); + strncpy(current_info->mpd.file, "Unknown", + TEXT_BUFFER_SIZE - 1); + strncpy(current_info->mpd.artist, "Unknown", + TEXT_BUFFER_SIZE - 1); + strncpy(current_info->mpd.album, "Unknown", + TEXT_BUFFER_SIZE - 1); + strncpy(current_info->mpd.title, "Unknown", + TEXT_BUFFER_SIZE - 1); + strncpy(current_info->mpd.random, "Unknown", + TEXT_BUFFER_SIZE - 1); + strncpy(current_info->mpd.repeat, "Unknown", + TEXT_BUFFER_SIZE - 1); + strncpy(current_info->mpd.track, "Unknown", + TEXT_BUFFER_SIZE - 1); + if (strlen(current_info->conn->errorStr) > 1) { + strncpy(current_info->mpd.status, + current_info->conn->errorStr, + TEXT_BUFFER_SIZE - 1); + } else { + strncpy(current_info->mpd.status, + "MPD not responding", + TEXT_BUFFER_SIZE - 1); + } current_info->mpd.bitrate = 0; current_info->mpd.progress = 0; current_info->mpd.elapsed = 0; @@ -48,26 +80,55 @@ void update_mpd() mpd_sendCurrentSongCommand(current_info->conn); mpd_sendCommandListEnd(current_info->conn); if ((status = mpd_getStatus(current_info->conn)) == NULL) { - //fprintf(stderr, "%s\n", current_info->conn->errorStr); + //ERR("MPD error: %s\n", current_info->conn->errorStr); mpd_closeConnection(current_info->conn); if (current_info->mpd.artist == NULL) current_info->mpd.artist = - malloc(TEXT_BUFFER_SIZE); + malloc(TEXT_BUFFER_SIZE); if (current_info->mpd.album == NULL) current_info->mpd.album = malloc(TEXT_BUFFER_SIZE); if (current_info->mpd.title == NULL) current_info->mpd.title = malloc(TEXT_BUFFER_SIZE); if (current_info->mpd.random == NULL) - current_info->mpd.random = malloc(TEXT_BUFFER_SIZE); + current_info->mpd.random = + malloc(TEXT_BUFFER_SIZE); + if (current_info->mpd.repeat == NULL) + current_info->mpd.repeat = + malloc(TEXT_BUFFER_SIZE); if (current_info->mpd.track == NULL) current_info->mpd.track = malloc(TEXT_BUFFER_SIZE); - strcpy(current_info->mpd.artist, "Unknown"); - strcpy(current_info->mpd.album, "Unknown"); - strcpy(current_info->mpd.title, "Unknown"); - strcpy(current_info->mpd.random, "Unknown"); - strcpy(current_info->mpd.repeat, "Unknown"); - strcpy(current_info->mpd.track, "Unknown"); - current_info->mpd.status = "MPD not responding"; + if (current_info->mpd.status == NULL) + current_info->mpd.status = + malloc(TEXT_BUFFER_SIZE); + if (current_info->mpd.name == NULL) + current_info->mpd.name = malloc(TEXT_BUFFER_SIZE); + if (current_info->mpd.file == NULL) + current_info->mpd.file = malloc(TEXT_BUFFER_SIZE); + strncpy(current_info->mpd.name, "Unknown", + TEXT_BUFFER_SIZE - 1); + strncpy(current_info->mpd.file, "Unknown", + TEXT_BUFFER_SIZE - 1); + strncpy(current_info->mpd.artist, "Unknown", + TEXT_BUFFER_SIZE - 1); + strncpy(current_info->mpd.album, "Unknown", + TEXT_BUFFER_SIZE - 1); + strncpy(current_info->mpd.title, "Unknown", + TEXT_BUFFER_SIZE - 1); + strncpy(current_info->mpd.random, "Unknown", + TEXT_BUFFER_SIZE - 1); + strncpy(current_info->mpd.repeat, "Unknown", + TEXT_BUFFER_SIZE - 1); + strncpy(current_info->mpd.track, "Unknown", + TEXT_BUFFER_SIZE - 1); + if (strlen(current_info->conn->errorStr) > 1) { + strncpy(current_info->mpd.status, + current_info->conn->errorStr, + TEXT_BUFFER_SIZE - 1); + } else { + strncpy(current_info->mpd.status, + "MPD not responding", + TEXT_BUFFER_SIZE - 1); + } current_info->mpd.bitrate = 0; current_info->mpd.progress = 0; current_info->mpd.elapsed = 0; @@ -79,156 +140,226 @@ void update_mpd() //printf("error: %s\n", status->error); if (status->state == MPD_STATUS_STATE_PLAY) { - current_info->mpd.status = "Playing"; + if (current_info->mpd.status == NULL) + current_info->mpd.status = + malloc(TEXT_BUFFER_SIZE); + strncpy(current_info->mpd.status, "Playing", + TEXT_BUFFER_SIZE - 1); } if (status->state == MPD_STATUS_STATE_STOP) { - current_info->mpd.status = "Stopped"; current_info->mpd.bitrate = 0; current_info->mpd.progress = 0; current_info->mpd.elapsed = 0; current_info->mpd.length = 0; if (current_info->mpd.artist == NULL) current_info->mpd.artist = - malloc(TEXT_BUFFER_SIZE); + malloc(TEXT_BUFFER_SIZE); if (current_info->mpd.album == NULL) current_info->mpd.album = malloc(TEXT_BUFFER_SIZE); if (current_info->mpd.title == NULL) current_info->mpd.title = malloc(TEXT_BUFFER_SIZE); if (current_info->mpd.random == NULL) - current_info->mpd.random = malloc(TEXT_BUFFER_SIZE); + current_info->mpd.random = + malloc(TEXT_BUFFER_SIZE); if (current_info->mpd.repeat == NULL) - current_info->mpd.repeat = malloc(TEXT_BUFFER_SIZE); + current_info->mpd.repeat = + malloc(TEXT_BUFFER_SIZE); if (current_info->mpd.track == NULL) current_info->mpd.track = malloc(TEXT_BUFFER_SIZE); - strcpy(current_info->mpd.artist, "Stopped"); - strcpy(current_info->mpd.album, "Stopped"); - strcpy(current_info->mpd.title, "Stopped"); - strcpy(current_info->mpd.random, "Stopped"); - strcpy(current_info->mpd.repeat, "Stopped"); - strcpy(current_info->mpd.track, "Stopped"); + if (current_info->mpd.status == NULL) + current_info->mpd.status = + malloc(TEXT_BUFFER_SIZE); + if (current_info->mpd.name == NULL) + current_info->mpd.name = malloc(TEXT_BUFFER_SIZE); + if (current_info->mpd.file == NULL) + current_info->mpd.file = malloc(TEXT_BUFFER_SIZE); + strncpy(current_info->mpd.name, "Unknown", + TEXT_BUFFER_SIZE - 1); + strncpy(current_info->mpd.file, "Unknown", + TEXT_BUFFER_SIZE - 1); + strncpy(current_info->mpd.artist, "Unknown", + TEXT_BUFFER_SIZE - 1); + strncpy(current_info->mpd.album, "Unknown", + TEXT_BUFFER_SIZE - 1); + strncpy(current_info->mpd.title, "Unknown", + TEXT_BUFFER_SIZE - 1); + strncpy(current_info->mpd.random, "Unknown", + TEXT_BUFFER_SIZE - 1); + strncpy(current_info->mpd.repeat, "Unknown", + TEXT_BUFFER_SIZE - 1); + strncpy(current_info->mpd.track, "Unknown", + TEXT_BUFFER_SIZE - 1); + strncpy(current_info->mpd.status, "Unknown", + TEXT_BUFFER_SIZE - 1); } if (status->state == MPD_STATUS_STATE_PAUSE) { - current_info->mpd.status = "Paused"; + if (current_info->mpd.status == NULL) + current_info->mpd.status = + malloc(TEXT_BUFFER_SIZE); + strncpy(current_info->mpd.status, "Paused", + TEXT_BUFFER_SIZE - 1); } if (status->state == MPD_STATUS_STATE_UNKNOWN) { - current_info->mpd.status = "Unknown"; current_info->mpd.bitrate = 0; current_info->mpd.progress = 0; current_info->mpd.elapsed = 0; current_info->mpd.length = 0; if (current_info->mpd.artist == NULL) current_info->mpd.artist = - malloc(TEXT_BUFFER_SIZE); + malloc(TEXT_BUFFER_SIZE); if (current_info->mpd.album == NULL) current_info->mpd.album = malloc(TEXT_BUFFER_SIZE); if (current_info->mpd.title == NULL) current_info->mpd.title = malloc(TEXT_BUFFER_SIZE); if (current_info->mpd.random == NULL) - current_info->mpd.random = malloc(TEXT_BUFFER_SIZE); + current_info->mpd.random = + malloc(TEXT_BUFFER_SIZE); if (current_info->mpd.repeat == NULL) - current_info->mpd.repeat = malloc(TEXT_BUFFER_SIZE); + current_info->mpd.repeat = + malloc(TEXT_BUFFER_SIZE); if (current_info->mpd.track == NULL) current_info->mpd.track = malloc(TEXT_BUFFER_SIZE); - strcpy(current_info->mpd.artist, "Unknown"); - strcpy(current_info->mpd.album, "Unknown"); - strcpy(current_info->mpd.title, "Unknown"); - strcpy(current_info->mpd.random, "Unknown"); - strcpy(current_info->mpd.repeat, "Unknown"); - strcpy(current_info->mpd.track, "Unknown"); + if (current_info->mpd.status == NULL) + current_info->mpd.status = + malloc(TEXT_BUFFER_SIZE); + if (current_info->mpd.name == NULL) + current_info->mpd.name = malloc(TEXT_BUFFER_SIZE); + if (current_info->mpd.file == NULL) + current_info->mpd.file = malloc(TEXT_BUFFER_SIZE); + strncpy(current_info->mpd.name, "Unknown", + TEXT_BUFFER_SIZE - 1); + strncpy(current_info->mpd.file, "Unknown", + TEXT_BUFFER_SIZE - 1); + strncpy(current_info->mpd.artist, "Unknown", + TEXT_BUFFER_SIZE - 1); + strncpy(current_info->mpd.album, "Unknown", + TEXT_BUFFER_SIZE - 1); + strncpy(current_info->mpd.title, "Unknown", + TEXT_BUFFER_SIZE - 1); + strncpy(current_info->mpd.random, "Unknown", + TEXT_BUFFER_SIZE - 1); + strncpy(current_info->mpd.repeat, "Unknown", + TEXT_BUFFER_SIZE - 1); + strncpy(current_info->mpd.track, "Unknown", + TEXT_BUFFER_SIZE - 1); + strncpy(current_info->mpd.status, "Unknown", + TEXT_BUFFER_SIZE - 1); } if (status->state == MPD_STATUS_STATE_PLAY || - status->state == MPD_STATUS_STATE_PAUSE) { + status->state == MPD_STATUS_STATE_PAUSE) { current_info->mpd.bitrate = status->bitRate; current_info->mpd.progress = - (float) status->elapsedTime / status->totalTime; + (float) status->elapsedTime / status->totalTime; current_info->mpd.elapsed = status->elapsedTime; current_info->mpd.length = status->totalTime; - if (current_info->mpd.random == NULL) - current_info->mpd.random = malloc(TEXT_BUFFER_SIZE); - if (current_info->mpd.repeat == NULL) - current_info->mpd.repeat = malloc(TEXT_BUFFER_SIZE); - if (status->random == 0) { - strcpy(current_info->mpd.random, "Off"); - } else if (status->random == 1){ - strcpy(current_info->mpd.random, "On"); - } else { - strcpy(current_info->mpd.random, "Unknown"); - } - if (status->repeat == 0) { - strcpy(current_info->mpd.repeat, "Off"); - } else if (status->repeat == 1){ - strcpy(current_info->mpd.repeat, "On"); - } else { - strcpy(current_info->mpd.repeat, "Unknown"); - } - } - - - - if (current_info->conn->error) { + if (current_info->mpd.random == NULL) + current_info->mpd.random = + malloc(TEXT_BUFFER_SIZE); + if (current_info->mpd.repeat == NULL) + current_info->mpd.repeat = + malloc(TEXT_BUFFER_SIZE); + if (status->random == 0) { + strcpy(current_info->mpd.random, "Off"); + } else if (status->random == 1) { + strcpy(current_info->mpd.random, "On"); + } else { + strcpy(current_info->mpd.random, "Unknown"); + } + if (status->repeat == 0) { + strcpy(current_info->mpd.repeat, "Off"); + } else if (status->repeat == 1) { + strcpy(current_info->mpd.repeat, "On"); + } else { + strcpy(current_info->mpd.repeat, "Unknown"); + } + } + + if (current_info->conn->error) { //fprintf(stderr, "%s\n", current_info->conn->errorStr); - mpd_closeConnection(current_info->conn); - return; - } + mpd_closeConnection(current_info->conn); + return; + } - mpd_nextListOkCommand(current_info->conn); + mpd_nextListOkCommand(current_info->conn); - while ((entity = mpd_getNextInfoEntity(current_info->conn))) { - mpd_Song *song = entity->info.song; - if (entity->type != MPD_INFO_ENTITY_TYPE_SONG) { - mpd_freeInfoEntity(entity); - continue; - } + while ((entity = mpd_getNextInfoEntity(current_info->conn))) { + mpd_Song *song = entity->info.song; + if (entity->type != MPD_INFO_ENTITY_TYPE_SONG) { + mpd_freeInfoEntity(entity); + continue; + } - if (current_info->mpd.artist == NULL) - current_info->mpd.artist = - malloc(TEXT_BUFFER_SIZE); - if (current_info->mpd.album == NULL) - current_info->mpd.album = malloc(TEXT_BUFFER_SIZE); - if (current_info->mpd.title == NULL) - current_info->mpd.title = malloc(TEXT_BUFFER_SIZE); - if (current_info->mpd.track == NULL) - current_info->mpd.track = malloc(TEXT_BUFFER_SIZE); - if (song->artist) { - strcpy(current_info->mpd.artist, song->artist); - } else { - strcpy(current_info->mpd.artist, "Unknown"); - } - if (song->album) { - strcpy(current_info->mpd.album, song->album); - } else { - strcpy(current_info->mpd.album, "Unknown"); - } - if (song->title) { - strcpy(current_info->mpd.title, song->title); - } else { - strcpy(current_info->mpd.title, "Unknown"); - } - if (song->track) { - strcpy(current_info->mpd.track, song->track); - } else { - strcpy(current_info->mpd.track, "Unknown"); - } - if (entity != NULL) { - mpd_freeInfoEntity(entity); - } - } - if (entity != NULL) { - mpd_freeInfoEntity(entity); - } + if (current_info->mpd.artist == NULL) + current_info->mpd.artist = + malloc(TEXT_BUFFER_SIZE); + if (current_info->mpd.album == NULL) + current_info->mpd.album = malloc(TEXT_BUFFER_SIZE); + if (current_info->mpd.title == NULL) + current_info->mpd.title = malloc(TEXT_BUFFER_SIZE); + if (current_info->mpd.track == NULL) + current_info->mpd.track = malloc(TEXT_BUFFER_SIZE); + if (current_info->mpd.name == NULL) + current_info->mpd.name = malloc(TEXT_BUFFER_SIZE); + if (current_info->mpd.file == NULL) + current_info->mpd.file = malloc(TEXT_BUFFER_SIZE); + if (song->artist) { + strncpy(current_info->mpd.artist, song->artist, + TEXT_BUFFER_SIZE - 1); + } else { + strcpy(current_info->mpd.artist, "Unknown"); + } + if (song->album) { + strncpy(current_info->mpd.album, song->album, + TEXT_BUFFER_SIZE - 1); + } else { + strcpy(current_info->mpd.album, "Unknown"); + } + if (song->title) { + strncpy(current_info->mpd.title, song->title, + TEXT_BUFFER_SIZE - 1); + } else { + strcpy(current_info->mpd.title, "Unknown"); + } + if (song->track) { + strncpy(current_info->mpd.track, song->track, + TEXT_BUFFER_SIZE - 1); + } else { + strcpy(current_info->mpd.track, "Unknown"); + } + if (song->name) { + strncpy(current_info->mpd.name, song->name, + TEXT_BUFFER_SIZE - 1); + } else { + strcpy(current_info->mpd.name, "Unknown"); + } + if (song->file) { + strncpy(current_info->mpd.file, + song->file, TEXT_BUFFER_SIZE - 1); + } else { + strcpy(current_info->mpd.file, "Unknown"); + } + if (entity != NULL) { + mpd_freeInfoEntity(entity); + entity = NULL; + } + } + if (entity != NULL) { + mpd_freeInfoEntity(entity); + entity = NULL; + } - if (current_info->conn->error) { + if (current_info->conn->error) { //fprintf(stderr, "%s\n", current_info->conn->errorStr); - mpd_closeConnection(current_info->conn); - return; - } + mpd_closeConnection(current_info->conn); + return; + } - mpd_finishCommand(current_info->conn); - if (current_info->conn->error) { + mpd_finishCommand(current_info->conn); + if (current_info->conn->error) { //fprintf(stderr, "%s\n", current_info->conn->errorStr); - mpd_closeConnection(current_info->conn); - return; - } - mpd_freeStatus(status); - mpd_closeConnection(current_info->conn); - } + mpd_closeConnection(current_info->conn); + return; + } + mpd_freeStatus(status); + mpd_closeConnection(current_info->conn); +}