summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: d98fbf6)
raw | patch | inline | side by side (parent: d98fbf6)
author | Kalle Wallin <kaw@linux.se> | |
Tue, 8 Jun 2004 13:15:03 +0000 (13:15 +0000) | ||
committer | Kalle Wallin <kaw@linux.se> | |
Tue, 8 Jun 2004 13:15:03 +0000 (13:15 +0000) |
TODO | patch | blob | history | |
src/libmpdclient.c | patch | blob | history | |
src/libmpdclient.h | patch | blob | history | |
src/mpc.c | patch | blob | history |
index a09a8a24e7ebb88c3901e0c0517fcece08f6f552..c0c3ae8562cfc832fd4be5e629e52b37b74fe0ec 100644 (file)
--- a/TODO
+++ b/TODO
-client functions
-----------------------------------------------------------------------------
- * move songs in playlists
- * search screen
- * id3 browser
-
-ncurses
-----------------------------------------------------------------------------
- * a small line editor (with history and support for KEY_RESIZE).
-
-other
-----------------------------------------------------------------------------
- * internationalization - gettext
- * A cleanup would be nice
+Features:
+* search screen
+* id3 browser
+
+Other:
+* Remove popt dependency
+* A cleanup would be nice
+
+*** Cleanup mpc.c !!!
diff --git a/src/libmpdclient.c b/src/libmpdclient.c
index a879b53e65fb08e25264e82fa7d60b8eab43ad9a..b61e2d1e9e33bf6dbfb33ac4e17df470f92c70e7 100644 (file)
--- a/src/libmpdclient.c
+++ b/src/libmpdclient.c
strcpy(connection->errorStr, output);
connection->error = MPD_ERROR_ACK;
- connection->errorCode = MPD_ERROR_CODE_UNK;
+ connection->errorCode = MPD_ACK_ERROR_UNK;
connection->errorAt = MPD_ERROR_AT_UNK;
connection->doneProcessing = 1;
needle = strchr(output, '[');
if(!needle) return;
- val = strtol(needle, &test, 10);
+ val = strtol(needle+1, &test, 10);
if(*test != '@') return;
connection->errorCode = val;
val = strtol(test+1, &test, 10);
void mpd_sendPlChangesCommand(mpd_Connection * connection, long long playlist) {
char * string = malloc(strlen("plchanges")+25);
- sprintf(string,"plchanges \"%i\"\n",playlist);
+ sprintf(string,"plchanges \"%lld\"\n",playlist);
mpd_sendInfoCommand(connection,string);
free(string);
}
diff --git a/src/libmpdclient.h b/src/libmpdclient.h
index 55d2ff077e4ed92b211472b5a15da3e45575a9a0..c4b022cd9e88442515418f4ffb2125e4cbbcb88a 100644 (file)
--- a/src/libmpdclient.h
+++ b/src/libmpdclient.h
#define MPD_ERROR_ACK 18 /* ACK returned! */
#define MPD_ERROR_BUFFEROVERRUN 19 /* Buffer was overrun! */
-#define MPD_ERROR_CODE_UNK -1;
-#define MPD_ERROR_AT_UNK -1;
+#define MPD_ACK_ERROR_UNK -1
+#define MPD_ERROR_AT_UNK -1
+
+#define MPD_ACK_ERROR_NOT_LIST 1
+#define MPD_ACK_ERROR_ARG 2
+#define MPD_ACK_ERROR_PASSWORD 3
+#define MPD_ACK_ERROR_PERMISSION 4
+#define MPD_ACK_ERROR_UNKNOWN 5
+#define MPD_ACK_ERROR_NO_EXIST 6
+#define MPD_ACK_ERROR_PLAYLIST_MAX 7
+#define MPD_ACK_ERROR_SYSTEM 8
+#define MPD_ACK_ERROR_PLAYLIST_LOAD 9
+#define MPD_ACK_ERROR_UPDATE_ALREADY 10
+#define MPD_ACK_ERROR_PLAYER_SYNC 11
#ifdef __cplusplus
extern "C" {
diff --git a/src/mpc.c b/src/mpc.c
index ab25f1964991eb36115e4c724078f300bb934d08..08ca970f6c1e563caab234a9a841808d51ac18df 100644 (file)
--- a/src/mpc.c
+++ b/src/mpc.c
{
if( c == NULL || c->connection == NULL )
return 1;
+
if( c->connection->error )
- return c->connection->error;
+ return c->connection->error;
return 0;
}
{
mpd_InfoEntity *entity;
- D(fprintf(stderr, "mpc_update_playlist() [%lld]\n", c->status->playlist));
+ D(fprintf(stderr, "mpc_update_playlist() [%lld -> %lld]\n",
+ c->status->playlist, c->playlist_id));
if( mpc_error(c) )
return -1;
mpd_sendPlChangesCommand(c->connection, c->playlist_id);
if( mpc_error(c) )
return -1;
- if( (entity=mpd_getNextInfoEntity(c->connection)) == NULL )
- return mpc_get_playlist(c);
- while( entity )
+
+ while( (entity=mpd_getNextInfoEntity(c->connection)) != NULL )
{
if(entity->type==MPD_INFO_ENTITY_TYPE_SONG)
{
GList *item;
if( (song=mpd_songDup(entity->info.song)) == NULL )
- return mpc_get_playlist(c);
+ {
+ D(fprintf(stderr, "song==NULL\n"));
+ return mpc_get_playlist(c);
+ }
item = g_list_nth(c->playlist, song->num);
if( item && item->data)
{
+ /* Update playlist entry */
mpd_freeSong((mpd_Song *) item->data);
item->data = song;
if( c->song_id == song->num )
}
else
{
+ /* Add a new playlist entry */
D(fprintf(stderr, "Adding num %d - %s\n",
song->num, mpc_get_song_name(song)));
c->playlist = g_list_append(c->playlist,
c->playlist_length++;
}
}
- mpd_freeInfoEntity(entity);
- entity=mpd_getNextInfoEntity(c->connection);
+ mpd_freeInfoEntity(entity);
}
mpd_finishCommand(c->connection);
+
+ while( g_list_length(c->playlist) > c->status->playlistLength )
+ {
+ GList *item = g_list_last(c->playlist);
+
+ /* Remove the last playlist entry */
+ mpd_freeSong((mpd_Song *) item->data);
+ c->playlist = g_list_delete_link(c->playlist, item);
+ c->playlist_length--;
+ D(fprintf(stderr, "Removed the last playlist entryn\n"));
+ }
c->playlist_id = c->status->playlist;
c->playlist_updated = 1;
c->filelist_length=0;
- // mpd_sendListallCommand(conn,"");
mpd_sendLsInfoCommand(c->connection, c->cwd);
-
+
if( c->cwd && c->cwd[0] )
{
/* add a dummy entry for ./.. */