Code

ncmpc.git
15 years agoscreen_file: check connection in screen_file_cmd()
Max Kellermann [Thu, 1 Oct 2009 21:58:27 +0000 (23:58 +0200)]
screen_file: check connection in screen_file_cmd()

15 years agoscreen_play: check connection in screen_playlist_cmd()
Max Kellermann [Thu, 1 Oct 2009 21:51:04 +0000 (23:51 +0200)]
screen_play: check connection in screen_playlist_cmd()

15 years agoscreen_play: fixed function prefix
Max Kellermann [Thu, 1 Oct 2009 21:45:51 +0000 (23:45 +0200)]
screen_play: fixed function prefix

Prefix must be "screen_playlist_".

15 years agoscreen_play: check the result of mpd_connection_clear_error()
Max Kellermann [Thu, 1 Oct 2009 21:31:43 +0000 (23:31 +0200)]
screen_play: check the result of mpd_connection_clear_error()

15 years agompdclient: convert all functions to return "bool"
Max Kellermann [Thu, 1 Oct 2009 21:10:53 +0000 (23:10 +0200)]
mpdclient: convert all functions to return "bool"

No libmpdclient error codes.

15 years agompdclient: removed several functions
Max Kellermann [Thu, 1 Oct 2009 21:05:27 +0000 (23:05 +0200)]
mpdclient: removed several functions

Make the code use libmpdclient directly.

15 years agoscreen: moved status message functions to screen_message.c
Max Kellermann [Thu, 1 Oct 2009 20:12:47 +0000 (22:12 +0200)]
screen: moved status message functions to screen_message.c

15 years agoscreen: removed unused macro MAX_SONGNAME_LENGTH
Max Kellermann [Thu, 1 Oct 2009 20:03:53 +0000 (22:03 +0200)]
screen: removed unused macro MAX_SONGNAME_LENGTH

15 years agoscreen: eliminated state macros
Max Kellermann [Thu, 1 Oct 2009 20:03:33 +0000 (22:03 +0200)]
screen: eliminated state macros

Better do it manually.

15 years agoscreen: removed obsolete screen_error() prototype
Max Kellermann [Thu, 1 Oct 2009 20:00:54 +0000 (22:00 +0200)]
screen: removed obsolete screen_error() prototype

15 years agoscreen: removed obsolete screen_get_id() prototype
Max Kellermann [Thu, 1 Oct 2009 17:41:14 +0000 (19:41 +0200)]
screen: removed obsolete screen_get_id() prototype

15 years agoscreen: moved screen_interface externs to each screen header
Max Kellermann [Thu, 1 Oct 2009 17:40:49 +0000 (19:40 +0200)]
screen: moved screen_interface externs to each screen header

Make a header for each screen implementation.

15 years agoscreen: removed unused function volume_length()
Max Kellermann [Thu, 1 Oct 2009 17:40:43 +0000 (19:40 +0200)]
screen: removed unused function volume_length()

15 years agoscreen_lyrics: don't use strfsong() to obtain tags
Max Kellermann [Thu, 1 Oct 2009 17:40:39 +0000 (19:40 +0200)]
screen_lyrics: don't use strfsong() to obtain tags

Use mpd_song_get_tag().  This guarantees that the tags are encoded in
UTF-8.

15 years agostatus_bar: use a GLib timer to remove the message
Max Kellermann [Wed, 30 Sep 2009 22:13:30 +0000 (00:13 +0200)]
status_bar: use a GLib timer to remove the message

15 years agompdclient: rewrite the "fancy swap" code
Max Kellermann [Wed, 30 Sep 2009 21:55:48 +0000 (23:55 +0200)]
mpdclient: rewrite the "fancy swap" code

This is a trick to keep playlist swaps cheap: ncmpc tries to predict
the new playlist.

15 years agoscreen_play: use mpd_cmd_delete_range()
Max Kellermann [Wed, 30 Sep 2009 21:55:40 +0000 (23:55 +0200)]
screen_play: use mpd_cmd_delete_range()

15 years agompdclient: added mpdclient_cmd_delete_range()
Max Kellermann [Wed, 30 Sep 2009 21:55:38 +0000 (23:55 +0200)]
mpdclient: added mpdclient_cmd_delete_range()

MPD 0.16 supports "delete" with a range argument.

15 years agompdclient: rewrite the "fancy delete" code
Max Kellermann [Wed, 30 Sep 2009 21:55:14 +0000 (23:55 +0200)]
mpdclient: rewrite the "fancy delete" code

This is a trick to keep playlist deletes cheap: ncmpc tries to predict
the new playlist.

15 years agompdclient: rewrite the "fancy add" code
Max Kellermann [Wed, 30 Sep 2009 21:54:15 +0000 (23:54 +0200)]
mpdclient: rewrite the "fancy add" code

This is a trick to keep playlist adds cheap: ncmpc tries to predict
the new playlist.

15 years agoremoved obsolete Makefile.am
Max Kellermann [Wed, 30 Sep 2009 20:40:27 +0000 (22:40 +0200)]
removed obsolete Makefile.am

15 years agoplaylist: renamed "id" to "version"
Max Kellermann [Wed, 30 Sep 2009 20:18:22 +0000 (22:18 +0200)]
playlist: renamed "id" to "version"

15 years agompdclient: check to assertion in mpdclient_cmd_add()
Max Kellermann [Wed, 30 Sep 2009 20:13:06 +0000 (22:13 +0200)]
mpdclient: check to assertion in mpdclient_cmd_add()

It's illegal to pass song=NULL.

15 years agoscreen_browser: add "const" to several variables
Max Kellermann [Wed, 30 Sep 2009 20:12:51 +0000 (22:12 +0200)]
screen_browser: add "const" to several variables

15 years agoscreen_browser: pass playlist object to sync_highlights()
Max Kellermann [Wed, 30 Sep 2009 20:02:35 +0000 (22:02 +0200)]
screen_browser: pass playlist object to sync_highlights()

And add the screen_browser_ prefix to the function name.

15 years agoupdated .gitignore
Max Kellermann [Wed, 30 Sep 2009 19:58:11 +0000 (21:58 +0200)]
updated .gitignore

15 years agoscreen_outputs: toggle_output() returns bool
Max Kellermann [Wed, 30 Sep 2009 19:17:48 +0000 (21:17 +0200)]
screen_outputs: toggle_output() returns bool

15 years agoscreen_outputs: implemented the SCREEN_UPDATE command
Max Kellermann [Wed, 30 Sep 2009 19:17:19 +0000 (21:17 +0200)]
screen_outputs: implemented the SCREEN_UPDATE command

This reloads the output list from MPD.

15 years agoscreen_outputs: added update() method
Max Kellermann [Wed, 30 Sep 2009 19:13:21 +0000 (21:13 +0200)]
screen_outputs: added update() method

Automatically queue the "output" idle event when the user
enables/disables an output.

15 years agomoved struct screen_functions to screen_interface.h
Max Kellermann [Wed, 30 Sep 2009 19:08:17 +0000 (21:08 +0200)]
moved struct screen_functions to screen_interface.h

15 years agompdclient: added function mpdclient_get_current_song()
Max Kellermann [Wed, 30 Sep 2009 19:05:48 +0000 (21:05 +0200)]
mpdclient: added function mpdclient_get_current_song()

15 years agoscreen_play: query status.id instead of song.id
Max Kellermann [Wed, 30 Sep 2009 19:05:45 +0000 (21:05 +0200)]
screen_play: query status.id instead of song.id

15 years agoscreen_search: renamed internal functions
Max Kellermann [Wed, 30 Sep 2009 18:50:12 +0000 (20:50 +0200)]
screen_search: renamed internal functions

Use the "screen_search_" prefix.

15 years agoscreen_artist: renamed internal functions
Max Kellermann [Wed, 30 Sep 2009 18:49:26 +0000 (20:49 +0200)]
screen_artist: renamed internal functions

Use the "screen_artist_" prefix.

15 years agoscreen_file: renamed internal functions
Max Kellermann [Wed, 30 Sep 2009 18:42:59 +0000 (20:42 +0200)]
screen_file: renamed internal functions

Use the "screen_file_" prefix.

15 years agomoved screen_file_goto_song() prototype to screen_file.h
Max Kellermann [Wed, 30 Sep 2009 18:39:24 +0000 (20:39 +0200)]
moved screen_file_goto_song() prototype to screen_file.h

15 years agompdclient: removed all callbacks
Max Kellermann [Wed, 30 Sep 2009 18:29:32 +0000 (20:29 +0200)]
mpdclient: removed all callbacks

All users have switched to mpdclient.events.

15 years agoscreen: use idle events in screen_update()
Max Kellermann [Wed, 30 Sep 2009 18:28:38 +0000 (20:28 +0200)]
screen: use idle events in screen_update()

15 years agoscreen_browser: removed browser_playlist_changed()
Max Kellermann [Wed, 30 Sep 2009 18:28:30 +0000 (20:28 +0200)]
screen_browser: removed browser_playlist_changed()

This function is unused, since we have switched to idle events.

15 years agoscreen_search: use idle events instead of playlist/browse callback
Max Kellermann [Wed, 30 Sep 2009 18:26:30 +0000 (20:26 +0200)]
screen_search: use idle events instead of playlist/browse callback

15 years agoscreen_artist: use idle events instead of playlist/browse callback
Max Kellermann [Wed, 30 Sep 2009 18:16:00 +0000 (20:16 +0200)]
screen_artist: use idle events instead of playlist/browse callback

15 years agoscreen_file: use idle events instead of playlist/browse callback
Max Kellermann [Wed, 30 Sep 2009 18:16:00 +0000 (20:16 +0200)]
screen_file: use idle events instead of playlist/browse callback

15 years agoscreen_play: use idle events instead of playlist_callback
Max Kellermann [Wed, 30 Sep 2009 18:16:00 +0000 (20:16 +0200)]
screen_play: use idle events instead of playlist_callback

15 years agompdclient: added property "events", emulate idle
Max Kellermann [Wed, 30 Sep 2009 18:15:59 +0000 (20:15 +0200)]
mpdclient: added property "events", emulate idle

mpdclient_update() sets the "events" property after it has detected
changes.  This helps us eliminate the callback functions, and is a
good preparation for the real "idle" commandd.

15 years agompdclient: replaced error_callback with imported function
Max Kellermann [Wed, 30 Sep 2009 18:15:54 +0000 (20:15 +0200)]
mpdclient: replaced error_callback with imported function

Instead of having a GList of callback functions, call
mpdclient_ui_error(), which is exported by screen_client.c.

15 years agompdclient: mpdclient_filelist_get() returns NULL on error
Max Kellermann [Wed, 30 Sep 2009 17:56:06 +0000 (19:56 +0200)]
mpdclient: mpdclient_filelist_get() returns NULL on error

Don't artificially return an empty list when an error occurs.
Also don't insert the dummy ".." entry in mpdclient_filelist_get(),
screen_file.c should do this.

15 years agoscreen_play: remember the id of the selected song
Max Kellermann [Wed, 30 Sep 2009 17:11:09 +0000 (19:11 +0200)]
screen_play: remember the id of the selected song

When the playlist changes, restore the song selection.

15 years agoscreen_play: added helper function playlist_selected_song()
Max Kellermann [Wed, 30 Sep 2009 17:09:54 +0000 (19:09 +0200)]
screen_play: added helper function playlist_selected_song()

15 years agoscreen_play: fixed list_window.range_selection usage
Max Kellermann [Wed, 30 Sep 2009 15:50:50 +0000 (17:50 +0200)]
screen_play: fixed list_window.range_selection usage

It's a bool.

15 years agompdclient.h: include mpd/client.h instead of mpd/tag.h
Max Kellermann [Wed, 30 Sep 2009 15:40:26 +0000 (17:40 +0200)]
mpdclient.h: include mpd/client.h instead of mpd/tag.h

mpd/tag.h is not part of the libmpdclient2 API.

15 years agompdclient: renamed "updatingdb" to "update_id"
Max Kellermann [Wed, 30 Sep 2009 15:40:25 +0000 (17:40 +0200)]
mpdclient: renamed "updatingdb" to "update_id"

Adopt libmpdclient's name.

15 years agoplayer_command: use libmpdclient2 directly
Max Kellermann [Wed, 30 Sep 2009 14:33:55 +0000 (16:33 +0200)]
player_command: use libmpdclient2 directly

Don't use mpdclient_cmd_X().

15 years agoscreen: moved code to status_bar.c
Max Kellermann [Wed, 30 Sep 2009 14:32:47 +0000 (16:32 +0200)]
screen: moved code to status_bar.c

15 years agoscreen_utils: don't pass WINDOW to screen_readln()
Max Kellermann [Wed, 30 Sep 2009 14:30:18 +0000 (16:30 +0200)]
screen_utils: don't pass WINDOW to screen_readln()

Callers shouldn't care which window will be used; we're going to use
the global variable screen.status_window.

15 years agoscreen_utils: removed unused function screen_getstr()
Max Kellermann [Wed, 30 Sep 2009 14:30:15 +0000 (16:30 +0200)]
screen_utils: removed unused function screen_getstr()

15 years agoscreen_browser: repair the "mini" version
Max Kellermann [Wed, 30 Sep 2009 14:30:11 +0000 (16:30 +0200)]
screen_browser: repair the "mini" version

Added missing "}".

15 years agompdclient: initialize "retval" in mpdclient_update()
Max Kellermann [Wed, 30 Sep 2009 14:30:08 +0000 (16:30 +0200)]
mpdclient: initialize "retval" in mpdclient_update()

15 years agoscreen: moved code to title_bar.c
Max Kellermann [Wed, 30 Sep 2009 06:22:08 +0000 (08:22 +0200)]
screen: moved code to title_bar.c

15 years agoscreen: moved more (de)initialization code to progress_bar.c
Max Kellermann [Wed, 30 Sep 2009 06:21:57 +0000 (08:21 +0200)]
screen: moved more (de)initialization code to progress_bar.c

15 years agompdclient, screen: don't use MPD_STATUS_NO_VOLUME
Max Kellermann [Wed, 30 Sep 2009 05:58:55 +0000 (07:58 +0200)]
mpdclient, screen: don't use MPD_STATUS_NO_VOLUME

It was removed from libmpdclient.

15 years agoprogress_bar: do first paint manually
Max Kellermann [Wed, 30 Sep 2009 05:47:27 +0000 (07:47 +0200)]
progress_bar: do first paint manually

15 years agoscreen: moved refresh() to ncu_init()
Max Kellermann [Wed, 30 Sep 2009 05:47:26 +0000 (07:47 +0200)]
screen: moved refresh() to ncu_init()

The ncurses initialization code should do the refresh() to clear the
terminal, while screen_init() should reveal the empty controls
(progress bar currently).

15 years agoscreen: moved code to progress_bar.c
Max Kellermann [Tue, 29 Sep 2009 22:35:22 +0000 (00:35 +0200)]
screen: moved code to progress_bar.c

This class repaints only if the bar width has really changed.  It uses
integer division instead of floating point.

15 years agoscreen: moved struct window to window.h
Max Kellermann [Tue, 29 Sep 2009 22:02:47 +0000 (00:02 +0200)]
screen: moved struct window to window.h

15 years agompdclient: handle password errors properly in mpdclient_connect()
Max Kellermann [Tue, 29 Sep 2009 21:18:02 +0000 (23:18 +0200)]
mpdclient: handle password errors properly in mpdclient_connect()

Abort the connection when the configured password fails.

15 years agoscreen_play: repaint on playlist change
Max Kellermann [Tue, 29 Sep 2009 21:17:23 +0000 (23:17 +0200)]
screen_play: repaint on playlist change

When the playlist version changes, repaint the playlist screen.  This
fixes a regression from the patch "repaint hscrolling only if selected
item is wide".

15 years agoscreen_play: simplified function playlist_save()
Max Kellermann [Tue, 29 Sep 2009 20:35:55 +0000 (22:35 +0200)]
screen_play: simplified function playlist_save()

15 years agompdclient: mpdclient_update() returns bool
Max Kellermann [Tue, 29 Sep 2009 20:33:02 +0000 (22:33 +0200)]
mpdclient: mpdclient_update() returns bool

As a side effect, this patch adds the missing
mpdclient_finish_command() call to
mpdclient_playlist_update_changes().

15 years agompdclient: mpdclient_connect() returns bool
Max Kellermann [Tue, 29 Sep 2009 20:26:31 +0000 (22:26 +0200)]
mpdclient: mpdclient_connect() returns bool

.. and disable recovery with mpdclient_handle_error().

15 years agompdclient: mpdclient_disconnect() returns void
Max Kellermann [Tue, 29 Sep 2009 20:24:43 +0000 (22:24 +0200)]
mpdclient: mpdclient_disconnect() returns void

There is no useful return value.

15 years agoscreen_browser: optimize "add+play song" with addid/playid
Max Kellermann [Tue, 29 Sep 2009 20:22:54 +0000 (22:22 +0200)]
screen_browser: optimize "add+play song" with addid/playid

Use the "addid"/"playid" commands in enqueue_and_play().  This
requires MPD 0.12.

15 years agorequire MPD 0.12
Max Kellermann [Tue, 29 Sep 2009 20:14:35 +0000 (22:14 +0200)]
require MPD 0.12

We will take advantage of the "addid" command, which was introduced in
MPD 0.12.  Hey, who's still running 0.11 these days?

15 years agoplaylist: make functions const
Max Kellermann [Tue, 29 Sep 2009 20:14:20 +0000 (22:14 +0200)]
playlist: make functions const

And return const mpd_song objects.

15 years agoplaylist: pass struct mpdclient_playlist to functions
Max Kellermann [Tue, 29 Sep 2009 20:11:23 +0000 (22:11 +0200)]
playlist: pass struct mpdclient_playlist to functions

Passing a mpdclient object doesn't make sense in this library.

15 years agoplaylist: don't check mpd_song_get_uri()!=NULL
Max Kellermann [Tue, 29 Sep 2009 20:01:37 +0000 (22:01 +0200)]
playlist: don't check mpd_song_get_uri()!=NULL

libmpdclient2 guarantees that each mpd_song object has an URI.

15 years agompdclient: reactivate incremental playlist changes
Max Kellermann [Tue, 29 Sep 2009 19:49:53 +0000 (21:49 +0200)]
mpdclient: reactivate incremental playlist changes

A while ago, I broke "plchanges" calls because I forgot to add a "!"
before playlist_is_empty().

15 years agoscreen_client: allow multiple queued database updates
Max Kellermann [Tue, 29 Sep 2009 18:58:02 +0000 (20:58 +0200)]
screen_client: allow multiple queued database updates

MPD supports having multiple update paths in the queue.  Let's just
invoke the "update" command and see what MPD responds.

15 years agoscreen_outputs: finish response in fill_outputs_list()
Max Kellermann [Tue, 29 Sep 2009 18:58:01 +0000 (20:58 +0200)]
screen_outputs: finish response in fill_outputs_list()

15 years agompdclient: don't export mpdclient_finish_command()
Max Kellermann [Tue, 29 Sep 2009 18:57:48 +0000 (20:57 +0200)]
mpdclient: don't export mpdclient_finish_command()

Use plain libmpdclient2 functions plus mpdclient_handle_error()
instead.

15 years agompdclient: export mpdclient_handle_error()
Max Kellermann [Tue, 29 Sep 2009 18:57:29 +0000 (20:57 +0200)]
mpdclient: export mpdclient_handle_error()

This function will allow callers to use libmpdclient2 directly.

15 years agoscreen_file: moved update code to screen_client.c
Max Kellermann [Tue, 29 Sep 2009 18:57:27 +0000 (20:57 +0200)]
screen_file: moved update code to screen_client.c

Moved code from screen_file.c and player_command.c.

15 years agoscreen_client: screen_auth() returns bool
Max Kellermann [Tue, 29 Sep 2009 18:36:07 +0000 (20:36 +0200)]
screen_client: screen_auth() returns bool

true for success, false for error.

15 years agoscreen_client: don't update twice in screen_auth()
Max Kellermann [Tue, 29 Sep 2009 18:36:06 +0000 (20:36 +0200)]
screen_client: don't update twice in screen_auth()

One mpdclient_update() call is in _screen_auth(), and the second is in
screen_auth().  screen_auth() does not check whether _screen_auth()
was successful prior to that.

15 years agoscreen_client: removed curs_set() call from screen_auth()
Max Kellermann [Tue, 29 Sep 2009 18:36:05 +0000 (20:36 +0200)]
screen_client: removed curs_set() call from screen_auth()

screen_read_password() is responsible for hiding the cursor when
finished.

15 years agoscreen_utils: moved screen_auth() to screen_client.c
Max Kellermann [Tue, 29 Sep 2009 18:36:05 +0000 (20:36 +0200)]
screen_utils: moved screen_auth() to screen_client.c

screen_client.c is a new library for MPD specific screen functions.

15 years agompdclient: removed the "need_update" flag
Max Kellermann [Tue, 29 Sep 2009 18:36:04 +0000 (20:36 +0200)]
mpdclient: removed the "need_update" flag

It's set, but never read.

15 years agompdclient: removed the deprecated !ENABLE_PLCHANGES code
Max Kellermann [Tue, 29 Sep 2009 16:37:30 +0000 (18:37 +0200)]
mpdclient: removed the deprecated !ENABLE_PLCHANGES code

The ENABLE_PLCHANGES option has been enabled for ages.

15 years agompdclient: removed the deprecated !ENABLE_SONG_ID code
Max Kellermann [Tue, 29 Sep 2009 16:37:19 +0000 (18:37 +0200)]
mpdclient: removed the deprecated !ENABLE_SONG_ID code

The ENABLE_SONG_ID option has been enabled for ages.

15 years agompdclient: merged error_cb() into mpdclient_handle_error()
Max Kellermann [Tue, 29 Sep 2009 16:21:38 +0000 (18:21 +0200)]
mpdclient: merged error_cb() into mpdclient_handle_error()

Let mpd_connection_clear_error() decide if the error was fatal.

15 years agompdclient: abort ncmpc if out of memory
Max Kellermann [Tue, 29 Sep 2009 16:20:38 +0000 (18:20 +0200)]
mpdclient: abort ncmpc if out of memory

When mpd_connection_new() returns NULL, there's not much we can do.

15 years agomain: don't skip "{}" in server error message
Max Kellermann [Tue, 29 Sep 2009 16:20:33 +0000 (18:20 +0200)]
main: don't skip "{}" in server error message

libmpdclient2 discards the command name from the error message, we
don't need to do it again.

15 years agompdclient: added mpdclient_is_connected()
Max Kellermann [Tue, 29 Sep 2009 16:20:26 +0000 (18:20 +0200)]
mpdclient: added mpdclient_is_connected()

This allows us to remove the global "connected" variable from main.c.

15 years agomain: changed "connected" check to assertion
Max Kellermann [Tue, 29 Sep 2009 16:20:25 +0000 (18:20 +0200)]
main: changed "connected" check to assertion

timer_reconnect() must not be called when ncmpc is already connected.

15 years agoscreen_search: clear return value on error
Max Kellermann [Tue, 29 Sep 2009 16:20:22 +0000 (18:20 +0200)]
screen_search: clear return value on error

search_advanced_query() has a redundant "fl!=NULL" check, and it does
not clear the "fl" variable after freeing the object.

15 years agoscreen_play: repaint hscrolling only if selected item is wide
Max Kellermann [Mon, 28 Sep 2009 16:21:54 +0000 (18:21 +0200)]
screen_play: repaint hscrolling only if selected item is wide

When the "scroll" option is active, ncmpc repainted the whole screen
with each tick, even if the selected item is not wider than the
screen.  This wasted a lot of CPU cycles.

15 years agomoved the idle timer to player_command.c
Max Kellermann [Mon, 28 Sep 2009 16:10:58 +0000 (18:10 +0200)]
moved the idle timer to player_command.c

Create it only on demand, while seeking.

15 years agoplayer_command: handle_player_command() returns bool
Max Kellermann [Mon, 28 Sep 2009 15:48:46 +0000 (17:48 +0200)]
player_command: handle_player_command() returns bool

15 years agoscreen: moved screen_client_cmd() to player_command.c
Max Kellermann [Mon, 28 Sep 2009 15:47:45 +0000 (17:47 +0200)]
screen: moved screen_client_cmd() to player_command.c

15 years agompdclient: removed the mpdclient_t typedef
Max Kellermann [Mon, 28 Sep 2009 15:38:40 +0000 (17:38 +0200)]
mpdclient: removed the mpdclient_t typedef

Use forward-declared struct instead.  This also removes the typedefs
mpdclient_filelist_t, mpdclient_filelist_entry_t,
mpdclient_playlist_t.

15 years agopo: updated Chinese translation
Kyle WANG [Mon, 28 Sep 2009 15:14:16 +0000 (17:14 +0200)]
po: updated Chinese translation