diff options
Diffstat (limited to '')
-rw-r--r-- | TODO | 23 | ||||
-rw-r--r-- | src/libmpdclient.c | 6 | ||||
-rw-r--r-- | src/libmpdclient.h | 16 | ||||
-rw-r--r-- | src/mpc.c | 35 |
4 files changed, 51 insertions, 29 deletions
@@ -1,18 +1,13 @@ -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 a879b53e6..b61e2d1e9 100644 --- a/src/libmpdclient.c +++ b/src/libmpdclient.c @@ -469,13 +469,13 @@ void mpd_getNextReturnElement(mpd_Connection * connection) { 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); @@ -966,7 +966,7 @@ void mpd_sendPlaylistInfoCommand(mpd_Connection * connection, int songNum) { 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 55d2ff077..c4b022cd9 100644 --- a/src/libmpdclient.h +++ b/src/libmpdclient.h @@ -36,8 +36,20 @@ #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" { @@ -103,8 +103,9 @@ mpc_error(mpd_client_t *c) { if( c == NULL || c->connection == NULL ) return 1; + if( c->connection->error ) - return c->connection->error; + return c->connection->error; return 0; } @@ -194,7 +195,8 @@ mpc_update_playlist(mpd_client_t *c) { 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; @@ -202,9 +204,8 @@ mpc_update_playlist(mpd_client_t *c) 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) { @@ -212,11 +213,15 @@ mpc_update_playlist(mpd_client_t *c) 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 ) @@ -226,6 +231,7 @@ mpc_update_playlist(mpd_client_t *c) } 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, @@ -233,10 +239,20 @@ mpc_update_playlist(mpd_client_t *c) 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; @@ -476,9 +492,8 @@ mpc_update_filelist(mpd_client_t *c) c->filelist_length=0; - // mpd_sendListallCommand(conn,""); mpd_sendLsInfoCommand(c->connection, c->cwd); - + if( c->cwd && c->cwd[0] ) { /* add a dummy entry for ./.. */ |