[Goodies-commits] r4108 - xfce4-mpc-plugin/trunk/panel-plugin
Landry Breuil
landry at xfce.org
Mon Mar 24 17:02:06 CET 2008
Author: landry
Date: 2008-03-24 16:02:06 +0000 (Mon, 24 Mar 2008)
New Revision: 4108
Modified:
xfce4-mpc-plugin/trunk/panel-plugin/simple-libmpd.c
xfce4-mpc-plugin/trunk/panel-plugin/simple-libmpd.h
Log:
Add support for song->file, to use as fallback when title/artist/album tags are null
Modified: xfce4-mpc-plugin/trunk/panel-plugin/simple-libmpd.c
===================================================================
--- xfce4-mpc-plugin/trunk/panel-plugin/simple-libmpd.c 2008-03-24 11:23:48 UTC (rev 4107)
+++ xfce4-mpc-plugin/trunk/panel-plugin/simple-libmpd.c 2008-03-24 16:02:06 UTC (rev 4108)
@@ -289,6 +289,12 @@
{
/* save the end of the buffer from last occurence of 'file:', and replace it with 'OK\n' */
ptr = g_strrstr(mo->buffer, "file:");
+ if (!ptr)
+ {
+ mo->error = MPD_ERROR_CONNCLOSED;
+ DBG("ERROR parsing reply");
+ return;
+ }
tmp_buffer = (char*) calloc (MAXBUFLEN*2, sizeof(char));
strcpy(tmp_buffer, ptr);
@@ -332,7 +338,7 @@
int i;
mo->songid = -1;
lines = g_strsplit(mo->buffer, "\n", 0);
- for (i = 0 ; lines[i] && strcmp(lines[i], "OK") ; i++)
+ for (i = 0 ; lines[i] && strncmp(lines[i], "OK", 2) ; i++)
{
tokens = g_strsplit(lines[i], ":", 2);
/* remove leading whitespace */
@@ -369,7 +375,7 @@
mpd_Song* ms = (mpd_Song*) param;
gchar **lines, **tokens;
int i;
- ms->artist = ms->album = ms->title = ms->track = NULL;
+ ms->file = ms->artist = ms->album = ms->title = ms->track = NULL;
ms->id = ms->pos = -1;
lines = g_strsplit(mo->buffer, "\n", 0);
@@ -379,7 +385,8 @@
/* remove leading whitespace */
tokens[1] = g_strchug(tokens[1]);
DBG("key=\"%s\",value=\"%s\"", tokens[0], tokens[1]);
- if (!ms->artist && 0 == strcmp("Artist",tokens[0])) ms->artist= g_strdup(tokens[1]);
+ if (!ms->file && 0 == strcmp("file", tokens[0])) ms->file = g_strdup(tokens[1]);
+ else if (!ms->artist && 0 == strcmp("Artist",tokens[0])) ms->artist= g_strdup(tokens[1]);
else if (!ms->album && 0 == strcmp("Album", tokens[0])) ms->album = g_strdup(tokens[1]);
else if (!ms->title && 0 == strcmp("Title", tokens[0])) ms->title = g_strdup(tokens[1]);
else if (!ms->track && 0 == strcmp("Track", tokens[0])) ms->track = g_strdup(tokens[1]);
@@ -403,7 +410,7 @@
while(lines[i] && strcmp(lines[i],"OK"))
{
ms = &md->allsongs[md->nb];
- ms->artist = ms->album = ms->title = ms->track = NULL;
+ ms->file = ms->artist = ms->album = ms->title = ms->track = NULL;
ms->id = ms->pos = -1;
DBG("Going to parse song #%d", md->nb);
@@ -413,7 +420,8 @@
/* remove leading whitespace */
tokens[1] = g_strchug(tokens[1]);
DBG("key=\"%s\",value=\"%s\"", tokens[0], tokens[1]);
- if (!ms->artist && 0 == strcmp("Artist",tokens[0])) ms->artist= g_strdup(tokens[1]);
+ if (!ms->file && 0 == strcmp("file", tokens[0])) ms->file = g_strdup(tokens[1]);
+ else if (!ms->artist && 0 == strcmp("Artist",tokens[0])) ms->artist= g_strdup(tokens[1]);
else if (!ms->album && 0 == strcmp("Album", tokens[0])) ms->album = g_strdup(tokens[1]);
else if (!ms->title && 0 == strcmp("Title", tokens[0])) ms->title = g_strdup(tokens[1]);
else if (!ms->track && 0 == strcmp("Track", tokens[0])) ms->track = g_strdup(tokens[1]);
@@ -433,6 +441,7 @@
DBG("!");
if (mo->cursong != NULL && mo->cursong->id != mo->songid)
{
+ if (mo->cursong->file) free(mo->cursong->file);
if (mo->cursong->artist) free(mo->cursong->artist);
if (mo->cursong->album) free(mo->cursong->album);
if (mo->cursong->title) free(mo->cursong->title);
@@ -479,6 +488,7 @@
{
for (md->cur--; md->cur; md->cur--)
{
+ if (md->allsongs[md->cur].file) free(md->allsongs[md->cur].file);
if (md->allsongs[md->cur].artist) free(md->allsongs[md->cur].artist);
if (md->allsongs[md->cur].album) free(md->allsongs[md->cur].album);
if (md->allsongs[md->cur].title) free(md->allsongs[md->cur].title);
Modified: xfce4-mpc-plugin/trunk/panel-plugin/simple-libmpd.h
===================================================================
--- xfce4-mpc-plugin/trunk/panel-plugin/simple-libmpd.h 2008-03-24 11:23:48 UTC (rev 4107)
+++ xfce4-mpc-plugin/trunk/panel-plugin/simple-libmpd.h 2008-03-24 16:02:06 UTC (rev 4108)
@@ -41,6 +41,7 @@
typedef struct {
+ char* file;
char* artist;
char* album;
char* track;
More information about the Goodies-commits
mailing list