From 9e7903867979ebbf485c61cc95b69bd5ed1bfedb Mon Sep 17 00:00:00 2001 From: Lars-Dominik Braun Date: Mon, 23 Jun 2008 15:02:12 +0200 Subject: client/wardrobe: Fix scrobbling time issue --- libwardrobe/src/main.c | 9 +++++---- src/main.c | 5 ++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/libwardrobe/src/main.c b/libwardrobe/src/main.c index 2da94f0..897a596 100644 --- a/libwardrobe/src/main.c +++ b/libwardrobe/src/main.c @@ -26,6 +26,7 @@ THE SOFTWARE. #include #include +#include "wardrobe.h" #include "md5.h" #define WARDROBE_HTTP_BUFFER_SIZE 10000 @@ -144,17 +145,16 @@ void WardrobeDestroy (WardrobeHandle_t *wh) { */ WardrobeReturn_t WardrobeHandshake (WardrobeHandle_t *wh) { /* we'll use gmt */ - time_t currTime = time (NULL); - time_t currGmTime = mktime (gmtime (&currTime)); char url[1024], tmp[100], *tmpDigest, *pwDigest, *ret; WardrobeReturn_t fRet = WARDROBE_RET_ERR; + time_t currTStamp = time (NULL); tmpDigest = WardrobeMd5Calc (wh->password); - snprintf (tmp, sizeof (tmp), "%s%li", tmpDigest, currGmTime); + snprintf (tmp, sizeof (tmp), "%s%li", tmpDigest, currTStamp); pwDigest = WardrobeMd5Calc (tmp); snprintf (url, sizeof (url), "http://post.audioscrobbler.com/" "?hs=true&p=1.2&c=tst&v=1.0&u=%s&t=%li&a=%s", wh->user, - currGmTime, pwDigest); + currTStamp, pwDigest); WardrobeHttpGet (wh->ch, url, &ret); @@ -289,3 +289,4 @@ char *WardrobeErrorToString (WardrobeReturn_t ret) { } return NULL; } + diff --git a/src/main.c b/src/main.c index d198ac3..f08adeb 100644 --- a/src/main.c +++ b/src/main.c @@ -56,6 +56,7 @@ PianoStation_t *BarUiSelectStation (PianoHandle_t *ph) { i++; } printf ("Press c to abort.\n"); + if (scanf ("%i", &i) < 1) { return NULL; } @@ -293,8 +294,6 @@ int main (int argc, char **argv) { } } if (curSong != NULL) { - time_t currTime = time (NULL); - time_t currGmTime = mktime (gmtime (&currTime)); printf ("\"%s\" by \"%s\"%s\n", curSong->title, curSong->artist, (curSong->rating == PIANO_RATE_LOVE) ? " (Loved)" : ""); @@ -303,7 +302,7 @@ int main (int argc, char **argv) { WardrobeSongInit (&scrobbleSong); scrobbleSong.artist = strdup (curSong->artist); scrobbleSong.title = strdup (curSong->title); - scrobbleSong.started = currGmTime; + scrobbleSong.started = time (NULL); /* FIXME: why do we need to zero everything again? */ memset (&player, 0, sizeof (player)); -- cgit v1.2.3