aboutsummaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* screen_help: removed update() methodMax Kellermann2008-09-211-13/+6
| | | | | Why redraw the help screen when nothing has changed? Redraw it only after help_cmd(), and when explicitly requested (help_paint()).
* filelist: fix segfault during filelist_sort()Max Kellermann2008-09-191-1/+13
| | | | | | | When I converted the filelist from GList to GPtrArray, I missed that the GCompareFunc does not actually get the pointers from g_ptr_array_sort(), but pointers to the pointers... run g_ptr_array_sort_with_data() instead with a wrapper function.
* filelist: free entries with g_slice_free()Max Kellermann2008-09-191-2/+2
| | | | | Somehow I forgot about changing free() to g_slice_free() in the previous patch...
* filelist: allocate entries with g_slice_alloc()Max Kellermann2008-09-191-4/+2
| | | | | In this case, slices are faster. Also fix a memory leak in filelist_prepend() which I simply forgot about in the last patch set.
* properly configure M4 macro dirunK2008-09-192-0/+2
| | | | | Add information about the M4 macro dir ./m4/ to both configure.ac and Makefile.am.
* filelist: use GPtrArray instead of GListMax Kellermann2008-09-195-63/+57
| | | | | Since we do a lot of indexed accesses to the filelist, a linked list doesn't seem appropriate. Use GPtrArray instead.
* browser: added function browser_get_selected()Max Kellermann2008-09-191-9/+11
| | | | | browser_get_selected() checks if there is a file list and a valid selection, and returns the selected entry.
* screen_search: free second file listMax Kellermann2008-09-191-0/+1
| | | | Fix a memory leak: the concatened list was never freed.
* filelist: provide more functions for working with a filelistMax Kellermann2008-09-197-58/+124
| | | | Avoid direct accesses to the filelist struct, provide an API for that.
* filelist: drop "mpdclient" prefixMax Kellermann2008-09-198-18/+16
| | | | | The separate filelist library does not depend on mpdclient, so the prefix is superfluous.
* browser: use mpdclient_filelist_find_song() in set_highlight()Max Kellermann2008-09-191-18/+9
| | | | | A song should not be twice in the browser. Simplify set_highlight() by finding the entry with mpdclient_filelist_find_song().
* browser: song must not be NULL in set_highlight()Max Kellermann2008-09-191-2/+1
| | | | | The caller must not pass NULL to set_highlight(). Replaced check with assertion.
* filelist: song must not be NULLMax Kellermann2008-09-191-1/+4
| | | | | A caller must not pass NULL to mpdclient_filelist_find_song(). Replace the check with an assertion.
* mpdclient: moved code to filelist.cMax Kellermann2008-09-195-77/+126
| | | | | | | | Move everything which is solely filelist related to filelist.c and filelist.h. Fix the indentation of that file, and provide the struct name "filelist". Don't clear data in mpdclient_filelist_free() before calling g_free(). Constify the "song" parameter to mpdclient_filelist_find_song().
* code style, indent with tabs VIIMax Kellermann2008-09-191-23/+16
| | | | Follow the same code style als MPD itself.
* fix terminal resizing (SIGWINCH)Max Kellermann2008-09-191-0/+33
| | | | | | | | | | | When I replaced ncmpc's old main loop with g_main_loop from libglib, SIGWINCH (i.e. window resizing) stopped working. This regression was caused by the fact that ncurses' wgetch() function was only called when there was actually data on STDIN. wgetch() has several side effects besides reading data from STDIN, for example it checks whether there has been a window resize. Fix this with a custom SIGWINCH handler.
* removed the clock screenMax Kellermann2008-09-189-262/+0
| | | | Why should an audio player display a large clock?
* screen_browser: removed entity.song!=NULL checkMax Kellermann2008-09-181-6/+5
| | | | | It is guaranteed that the "song" attribute is not NULL, remove the check.
* screen_browser: removed redundant highlight checkMax Kellermann2008-09-181-6/+5
| | | | | | browser_select_entry() checked the entry's "highlight" flag twice: the first time, it was toggled, and the second time, action was performed based on the flag. Merge the two checks.
* screen_browser: removed redundant entity type checksMax Kellermann2008-09-181-14/+10
| | | | | The function browser_select_entry() returns early when the entity type is not "SONG". No need to double check that.
* screen_browser: moved code to browser_select_entry()Max Kellermann2008-09-182-52/+26
| | | | | | Moved code from browser_handle_select(). Call this new function also from browser_handle_select_all(). This fixes a bug in select_all(): it actually did not select all, but stopped after the first song.
* screen_browser: removed commented codeMax Kellermann2008-09-181-15/+0
|
* screen_browser: moved code to browser_playlist_changed()Max Kellermann2008-09-185-49/+39
| | | | | Merge code from all 3 browser screens into one generic browser function.
* screen_browser: moved code to screen_browser.cMax Kellermann2008-09-186-507/+542
| | | | Isolate the generic browser code from the directory browser.
* screen_browser: added struct screen_browserMax Kellermann2008-09-184-185/+208
| | | | | We are going to separate the browser functions from screen_file.c. Move all variables which are going to be needed by this code.
* renamed screen_browse.h to screen_browser.hMax Kellermann2008-09-185-4/+4
|
* code style, indent with tabs VIMax Kellermann2008-09-184-550/+515
| | | | Follow the same code style als MPD itself.
* added support for wide charactersMax Kellermann2008-09-182-4/+17
| | | | | | | | This patch was taken from bug 476, author unknown (http://www.musicpd.org/mantis/view.php?id=476). It changes the definition of my_strlen(): instead of returning the number of UTF-8 characters, it counts the number of terminal cells occupied by a string.
* code style, indent with tabs VMax Kellermann2008-09-181-87/+81
| | | | Follow the same code style als MPD itself.
* screen: don't handle CMD_PLAYMax Kellermann2008-09-181-0/+2
| | | | | | | | | | CMD_PLAY is mapped to the Enter key by default. Some screens (mis-)use it for navigation, for entering a directory. The playlist screen actually plays the file under the cursor. On all other screens, pressing Enter may be confusing, since it is more of a "confirmation" key instead of "play". We should probaby add CMD_CONFIRM later, but for now, disable the general CMD_PLAY handler in screen.c. This fixes bug 240.
* libmpdclient: added resolver libraryMax Kellermann2008-09-184-199/+327
| | | | | | | The resolver library provides unified access to all resolvers (getaddrinfo(), gethostbyname(), Unix domain sockets). Like getaddrinfo(), it can return more than one address for a host name. This fixes bug 1517 (http://www.musicpd.org/mantis/view.php?id=1517).
* quit with g_main_loop_quit()Max Kellermann2008-09-182-5/+5
| | | | | Call g_main_loop_quit() on CMD_QUIT, instead of exit() with an atexit() handler.
* playlist: reset id in playlist_clear()Max Kellermann2008-09-181-0/+2
| | | | | | The playlist is reset when the connection to the MPD server is closed. After a successful reconnect, we have to reload the full playlist. To remember this, also reset the id attribute.
* playlist: removed "updated" flagMax Kellermann2008-09-184-8/+3
| | | | | The caller may check the playlist.id instead of checking the old "updated" flag.
* use the glib main event loopMax Kellermann2008-09-185-90/+157
| | | | | | | | | | This big patch replaces our custom main loop with the event based glib main loop. This has several advantages: we can make all the tiny code bits in the main loop independent from each others, we can add additional file descriptors for polling (e.g. the mpdclient socket). We don't need the ncurses timeout() anymore, because glib will poll stdin for us.
* screen: check MPD status only if connectedMax Kellermann2008-09-183-42/+61
| | | | | | Fix several segmentation faults: when the connection to the MPD server is lost, there were NULL pointer dereferences because client->status==NULL. Check before accessing it.
* screen: moved code to screen_client_cmd()Max Kellermann2008-09-181-9/+24
| | | | | | Move all command handlers which need a connection to the MPD server to screen_client_cmd(). This will allow us to unify error handling later.
* main: connect while UI is displayedMax Kellermann2008-09-181-39/+21
| | | | | | | | Display the UI always, and show connection errors there. This fixes a lot of consistency problems: error messages used to be printed to stderr, but afterwards, the atexit() handlers deinitialized ncurses and the screen was cleared. This patch is still problematic, but constitutes a good step forward.
* libmpdclient: moved code to mpd_recv(), mpd_wait()Max Kellermann2008-09-181-90/+129
| | | | | | Create generic utility functions for doint I/O: two wait functions, and mpd_recv() fills the input buffer. These functions are used in mpd_newConnection() and mpd_getNextReturnElement().
* libmpdclient: smaller input bufferMax Kellermann2008-09-182-6/+5
| | | | | Even for large responses, 16kB should be enough. There is no performance gain for larger buffers, even if MPD is local.
* libmpdclient: smaller error bufferMax Kellermann2008-09-182-21/+23
| | | | | | | 512 characters should be well enough for error messages which are actually being displayed somewhere. Use sizeof(errorStr) instead of MPD_BUFFER_MAX_LENGTH everywhere. Do proper length checking when copying the output buffer to errorStr.
* libmpdclient: use memmove() instead of strcpy() for moving the bufferMax Kellermann2008-09-181-8/+8
| | | | | | | In general, don't treat the input buffer as a null-terminated string: don't append '\0', don't use strchr() and strtok(). To delete consumed portions of the buffer, strcpy() is bad anyway, because it does not allow overlapping buffers.
* libmpdclient: don't strdup() MPD's welcome messageMax Kellermann2008-09-181-7/+3
| | | | | Why bother duplicating the buffer, when we can simply parse the response directly from the input buffer?
* libmpdclient: use size_t and ssize_tMax Kellermann2008-09-182-5/+6
| | | | | | When working with buffer lengths and recv() results, we should declare size_t and ssize_t variables, otherwise the code may fail on 64 bit machines.
* screen: removed empty methodsMax Kellermann2008-09-184-49/+0
| | | | | Declaring empty methods is of no use. If a method is empty, we should set it to NULL in the screen_functions struct.
* screen: removed NULL checkMax Kellermann2008-09-181-2/+1
| | | | | Since the screen's initialization is guaranteed, we can remove the NULL check in center_playing_item().
* screen_artist: fix compilation errorsMax Kellermann2008-09-171-26/+29
| | | | | | Unfortunately when I fixed the GCC warnings and refactored lots of the code, the "artist" screen was disabled. This patch applies all API changes and fixes all warnings.
* code style, indent with tabs IVMax Kellermann2008-09-175-471/+449
| | | | Follow the same code style als MPD itself.
* browse: when deselecting, don't search twiceMax Kellermann2008-09-171-1/+1
| | | | | When deselecting a song in the file browser, the local variable "idx" was initialized and overwritten. Remove the initialization.
* playlist: added playlist_remove_reuse()Max Kellermann2008-09-172-3/+10
| | | | | | | | | | playlist_remove_reuse() removes a song from the playlist, but does not free it. Use this function in mpdclient_cmd_delete() to fix a segmentation fault: the song pointer was still used after it was freed, by passing it to mpdclient_playlist_callback(). Free the song manually now. Reorganize and simply some code in mpdclient_cmd_delete().