From 0c90c2a30a88b13a81200b935bb2dd657305f9e7 Mon Sep 17 00:00:00 2001 From: Brenden Matthews Date: Tue, 11 Oct 2005 01:37:46 +0000 Subject: [PATCH] patch 1319461 git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky@343 7f574dfc-610e-0410-a909-a81674777703 --- AUTHORS | 3 +++ ChangeLog | 3 +++ src/conky.c | 21 +++++++++++++++++- src/conky.h | 3 +++ src/mpd.c | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++++---- 5 files changed, 96 insertions(+), 5 deletions(-) diff --git a/AUTHORS b/AUTHORS index d477468..acd7b80 100644 --- a/AUTHORS +++ b/AUTHORS @@ -125,6 +125,9 @@ Roman Bogorodskiy Szymon Boniecki Reads current LC_TIME +tyir + MPD features patch 1319461 + Walt Nelson $freq fix diff --git a/ChangeLog b/ChangeLog index ec52843..7824f28 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ # $Id$ +2005-10-10 + * More MPD objects (sf.net patch 1319461) + 2005-10-07 * fixed mldonkey bug? sf.net bug 1316531 diff --git a/src/conky.c b/src/conky.c index 3e5bd4b..52445f0 100644 --- a/src/conky.c +++ b/src/conky.c @@ -858,6 +858,8 @@ enum text_object_type { OBJ_mpd_title, OBJ_mpd_artist, OBJ_mpd_album, + OBJ_mpd_random, + OBJ_mpd_repeat, OBJ_mpd_vol, OBJ_mpd_bitrate, OBJ_mpd_status, @@ -866,6 +868,7 @@ enum text_object_type { OBJ_mpd_bar, OBJ_mpd_elapsed, OBJ_mpd_length, + OBJ_mpd_track, OBJ_mpd_percent, #endif }; @@ -1014,6 +1017,9 @@ static void free_text_objects() case OBJ_mpd_title: case OBJ_mpd_artist: case OBJ_mpd_album: + case OBJ_mpd_random: + case OBJ_mpd_repeat: + case OBJ_mpd_track: case OBJ_mpd_status: case OBJ_mpd_host: #endif @@ -1699,13 +1705,17 @@ int a = stippled_borders, b = 1; #ifdef MPD OBJ(mpd_artist, INFO_MPD) END OBJ(mpd_title, INFO_MPD) + END OBJ(mpd_random, INFO_MPD) + END OBJ(mpd_repeat, INFO_MPD) END OBJ(mpd_elapsed, INFO_MPD) END OBJ(mpd_length, INFO_MPD) + END OBJ(mpd_track, INFO_MPD) END OBJ(mpd_percent, INFO_MPD) END OBJ(mpd_album, INFO_MPD) END OBJ(mpd_vol, INFO_MPD) END OBJ(mpd_bitrate, INFO_MPD) - END OBJ(mpd_status, INFO_MPD) END OBJ(mpd_bar, INFO_MPD) + END OBJ(mpd_status, INFO_MPD) + END OBJ(mpd_bar, INFO_MPD) (void) scan_bar(arg, &obj->data.pair.a, &obj->data.pair.b); END #endif @@ -2755,6 +2765,15 @@ static void generate_text() OBJ(mpd_album) { snprintf(p, n, "%s", cur->mpd.album); } + OBJ(mpd_random) { + snprintf(p, n, "%s", cur->mpd.random); + } + OBJ(mpd_repeat) { + snprintf(p, n, "%s", cur->mpd.repeat); + } + OBJ(mpd_track) { + snprintf(p, n, "%s", cur->mpd.track); + } OBJ(mpd_vol) { snprintf(p, n, "%i", cur->mpd.volume); } diff --git a/src/conky.h b/src/conky.h index ca95392..8b3138f 100644 --- a/src/conky.h +++ b/src/conky.h @@ -96,6 +96,9 @@ struct mpd_s { char *artist; char *album; char *status; + char *random; + char *repeat; + char *track; int volume; unsigned int port; char host[128]; diff --git a/src/mpd.c b/src/mpd.c index 76ea65d..d468acb 100644 --- a/src/mpd.c +++ b/src/mpd.c @@ -21,9 +21,18 @@ void update_mpd() 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); + 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"; current_info->mpd.bitrate = 0; current_info->mpd.progress = 0; @@ -48,14 +57,22 @@ void update_mpd() 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); + 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"; current_info->mpd.bitrate = 0; current_info->mpd.progress = 0; current_info->mpd.elapsed = 0; current_info->mpd.length = 0; + current_info->mpd.track = 0; return; } current_info->mpd.volume = status->volume; @@ -71,6 +88,7 @@ void update_mpd() current_info->mpd.progress = 0; current_info->mpd.elapsed = 0; current_info->mpd.length = 0; + current_info->mpd.track = 0; if (current_info->mpd.artist == NULL) current_info->mpd.artist = malloc(TEXT_BUFFER_SIZE); @@ -78,9 +96,18 @@ void update_mpd() 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); + 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, "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 (status->state == MPD_STATUS_STATE_PAUSE) { current_info->mpd.status = "Paused"; @@ -91,6 +118,7 @@ void update_mpd() current_info->mpd.progress = 0; current_info->mpd.elapsed = 0; current_info->mpd.length = 0; + current_info->mpd.track = 0; if (current_info->mpd.artist == NULL) current_info->mpd.artist = malloc(TEXT_BUFFER_SIZE); @@ -98,9 +126,18 @@ void update_mpd() 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); + 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"); } if (status->state == MPD_STATUS_STATE_PLAY || status->state == MPD_STATUS_STATE_PAUSE) { @@ -109,9 +146,28 @@ void update_mpd() (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) { //fprintf(stderr, "%s\n", current_info->conn->errorStr); mpd_closeConnection(current_info->conn); @@ -134,6 +190,8 @@ void update_mpd() 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 { @@ -149,6 +207,11 @@ void update_mpd() } 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); } @@ -171,4 +234,4 @@ void update_mpd() } mpd_freeStatus(status); mpd_closeConnection(current_info->conn); -} + } -- 1.7.9.5