[lastbash-cvs] lastbash lastbash,1.60,1.61
Status: Beta
Brought to you by:
cstroie
|
From: Costin S. <cs...@us...> - 2006-11-30 15:02:28
|
Update of /cvsroot/lastbash/lastbash In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv25739 Modified Files: lastbash Log Message: tui_lastfm_connect check error Index: lastbash =================================================================== RCS file: /cvsroot/lastbash/lastbash/lastbash,v retrieving revision 1.60 retrieving revision 1.61 diff -u -d -r1.60 -r1.61 --- lastbash 30 Nov 2006 14:43:20 -0000 1.60 +++ lastbash 30 Nov 2006 15:02:25 -0000 1.61 @@ -844,15 +844,40 @@ #----------------------------------------------------------------------------- function tui_lastfm_connect() { + local ERRCODE RET + # Set the status line tui_sbar "Connecting to Last.fm..." - # Connect + + # Try connecting lastfm_connect "${LASTFM_USER}" "${LASTFM_PASS}" - # Update the status line - tui_sbar "Connected" - sleep 1 - # Change the station, if required - [ "${LASTFM_STATION}" ] && tui_lastfm_station "${LASTFM_STATION}" + ERRCODE="$?" + + # Check the error code + if [ "${ERRCODE}" == "0" ] + then + # TODO Display the LASTFM_INFO_MESSAGE + RET="0" + # Update the status line + tui_sbar "Connected" + sleep 1 + # Change the station, if required + [ "${LASTFM_STATION}" ] && tui_lastfm_station "${LASTFM_STATION}" + elif [ "${ERRCODE}" == "2" ] + then + RET="2" + tui_sbar "Last.fm session failed, check credentials" + elif [ "${ERRCODE}" == "3" ] + then + RET="3" + tui_sbar "Player banned, contact the author" + else + RET="1" + tui_sbar "Last.fm handshake failed" + fi + + # Return the status code + return "${RET}" } # Function: TUI for changing station {{{1 @@ -1331,15 +1356,20 @@ tui_start # Next, connect to the Last.fm station -tui_lastfm_connect -# Start the player -player_start -# Get the initial metadata -tui_metadata -# Enter the readkey loop -read_key_loop -# Stop the player -player_stop +if tui_lastfm_connect +then + # Start the player + player_start + # Get the initial metadata + tui_metadata + # Enter the readkey loop + read_key_loop + # Stop the player + player_stop +else + # Wait for the user read the status and exit + read -n 1 -s -t ${REFRESH_INTERVAL} KEY +fi # Restore the terminal term_exit |