From b123e01d42ca0abbb46b9006051b0ec65aefaaa6 Mon Sep 17 00:00:00 2001 From: Brenden Matthews Date: Mon, 13 Feb 2006 04:14:17 +0000 Subject: [PATCH] mpd fixes git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky@527 7f574dfc-610e-0410-a909-a81674777703 --- ChangeLog | 3 +++ src/mpd.c | 36 ++++++++++++------------------------ 2 files changed, 15 insertions(+), 24 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7294823e..1d51dbf1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ # $Id$ +2006-02-12 + * Conky 1.4.0 released + 2006-01-27 * Cleaned up texeci code diff --git a/src/mpd.c b/src/mpd.c index a1976352..c3e251c4 100644 --- a/src/mpd.c +++ b/src/mpd.c @@ -8,9 +8,9 @@ void update_mpd() { struct information *current_info = &info; - current_info->conn = - mpd_newConnection(current_info->mpd.host, - current_info->mpd.port, 10); + if (current_info->conn == NULL) { + current_info->conn = 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); @@ -19,6 +19,7 @@ void update_mpd() if (current_info->conn->error) { //ERR("%MPD error: s\n", current_info->conn->errorStr); mpd_closeConnection(current_info->conn); + current_info->conn = 0; if (current_info->mpd.artist == NULL) current_info->mpd.artist = malloc(TEXT_BUFFER_SIZE); @@ -57,15 +58,7 @@ void update_mpd() 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); - } + 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; @@ -82,6 +75,7 @@ void update_mpd() if ((status = mpd_getStatus(current_info->conn)) == NULL) { //ERR("MPD error: %s\n", current_info->conn->errorStr); mpd_closeConnection(current_info->conn); + current_info->conn = 0; if (current_info->mpd.artist == NULL) current_info->mpd.artist = malloc(TEXT_BUFFER_SIZE); @@ -98,8 +92,7 @@ void update_mpd() if (current_info->mpd.track == NULL) current_info->mpd.track = malloc(TEXT_BUFFER_SIZE); if (current_info->mpd.status == NULL) - current_info->mpd.status = - malloc(TEXT_BUFFER_SIZE); + 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) @@ -120,15 +113,7 @@ void update_mpd() 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); - } + 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; @@ -277,6 +262,7 @@ void update_mpd() if (current_info->conn->error) { //fprintf(stderr, "%s\n", current_info->conn->errorStr); mpd_closeConnection(current_info->conn); + current_info->conn = 0; return; } @@ -351,6 +337,7 @@ void update_mpd() if (current_info->conn->error) { //fprintf(stderr, "%s\n", current_info->conn->errorStr); mpd_closeConnection(current_info->conn); + current_info->conn = 0; return; } @@ -358,8 +345,9 @@ void update_mpd() if (current_info->conn->error) { //fprintf(stderr, "%s\n", current_info->conn->errorStr); mpd_closeConnection(current_info->conn); + current_info->conn = 0; return; } mpd_freeStatus(status); - mpd_closeConnection(current_info->conn); +// mpd_closeConnection(current_info->conn); }