aboutsummaryrefslogtreecommitdiffstats
path: root/src (unfollow)
Commit message (Collapse)AuthorFilesLines
2008-09-18screen_browser: removed commented codeMax Kellermann1-15/+0
2008-09-18screen_browser: moved code to browser_playlist_changed()Max Kellermann5-49/+39
Merge code from all 3 browser screens into one generic browser function.
2008-09-18screen_browser: moved code to screen_browser.cMax Kellermann6-507/+542
Isolate the generic browser code from the directory browser.
2008-09-18screen_browser: added struct screen_browserMax Kellermann4-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.
2008-09-18renamed screen_browse.h to screen_browser.hMax Kellermann5-4/+4
2008-09-18code style, indent with tabs VIMax Kellermann4-550/+515
Follow the same code style als MPD itself.
2008-09-18added support for wide charactersMax Kellermann2-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.
2008-09-18code style, indent with tabs VMax Kellermann1-87/+81
Follow the same code style als MPD itself.
2008-09-18screen: don't handle CMD_PLAYMax Kellermann1-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.
2008-09-18libmpdclient: added resolver libraryMax Kellermann4-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).
2008-09-18quit with g_main_loop_quit()Max Kellermann2-5/+5
Call g_main_loop_quit() on CMD_QUIT, instead of exit() with an atexit() handler.
2008-09-18playlist: reset id in playlist_clear()Max Kellermann1-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.
2008-09-18playlist: removed "updated" flagMax Kellermann4-8/+3
The caller may check the playlist.id instead of checking the old "updated" flag.
2008-09-18use the glib main event loopMax Kellermann5-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.
2008-09-18screen: check MPD status only if connectedMax Kellermann3-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.
2008-09-18screen: moved code to screen_client_cmd()Max Kellermann1-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.
2008-09-18main: connect while UI is displayedMax Kellermann1-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.
2008-09-18libmpdclient: moved code to mpd_recv(), mpd_wait()Max Kellermann1-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().
2008-09-18libmpdclient: smaller input bufferMax Kellermann2-6/+5
Even for large responses, 16kB should be enough. There is no performance gain for larger buffers, even if MPD is local.
2008-09-18libmpdclient: smaller error bufferMax Kellermann2-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.
2008-09-18libmpdclient: use memmove() instead of strcpy() for moving the bufferMax Kellermann1-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.
2008-09-18libmpdclient: don't strdup() MPD's welcome messageMax Kellermann1-7/+3
Why bother duplicating the buffer, when we can simply parse the response directly from the input buffer?
2008-09-18libmpdclient: use size_t and ssize_tMax Kellermann2-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.
2008-09-18screen: removed empty methodsMax Kellermann4-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.
2008-09-18screen: removed NULL checkMax Kellermann1-2/+1
Since the screen's initialization is guaranteed, we can remove the NULL check in center_playing_item().
2008-09-17screen_artist: fix compilation errorsMax Kellermann1-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.
2008-09-17code style, indent with tabs IVMax Kellermann5-471/+449
Follow the same code style als MPD itself.
2008-09-17browse: when deselecting, don't search twiceMax Kellermann1-1/+1
When deselecting a song in the file browser, the local variable "idx" was initialized and overwritten. Remove the initialization.
2008-09-17playlist: added playlist_remove_reuse()Max Kellermann2-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().
2008-09-17make several functions return voidMax Kellermann10-41/+32
2008-09-17playlist: use playlist_get() instead of playlist_get_song()Max Kellermann2-6/+9
2008-09-17list_window: don't reset *highlight to 0Max Kellermann4-4/+0
Since the list_window code sets highlight to 0 before it calls the list_callback, the callback itself doesn't have to reset the flag.
2008-09-17lyrics: don't check current.lines==NULLMax Kellermann1-2/+2
current.lines is always initialized, and cannot be NULL, no need to check it.
2008-09-17help: return early from list_callback()Max Kellermann1-25/+25
2008-09-17help: converted help_text_rows to a macroMax Kellermann1-10/+3
Why bother counting the elements of help_text[] (with sentinel) at runtime, when the compiler can do it at compile time?
2008-09-17lyrics: removed lyrics_text_rows, use current.lines->len insteadMax Kellermann1-2/+1
lyrics_text_rows wasn't set anyway, I somehow removed the code in a patch some time ago.
2008-09-17list_window: added list_window_center()Max Kellermann5-27/+25
Merge code which used to be duplicated in the screens "play", "help", "lyrics".
2008-09-17list_window: added list_window_scroll_cmd()Max Kellermann4-69/+62
It is similar to list_window_cmd(), but it scrolls the window instead of moving the selection. It is used by the "lyrics" and the "help" screen.
2008-09-17list_window: set repaint at the end of list_window_cmd()Max Kellermann1-6/+1
2008-09-17screen: return early in switch_screen_mode() on errorMax Kellermann1-7/+7
When the selected screen does not exist, return before calling close().
2008-09-17screen: added macro NUM_SCREENSMax Kellermann1-25/+16
Since the number of screens is known at compile time, define a macro which calculates this, instead of having a sentinel element.
2008-09-17screen: close only current screen in screen_exit()Max Kellermann1-2/+3
Screens which are not active have already been closed, or have never been opened. Don't call close again on them.
2008-09-17screen: don't store "screen" as a pointerMax Kellermann1-140/+135
There can only be onle screen struct instance at a time. Declare it as a static struct, instead of a pointer to the struct. This simplifies all accesses, and avoids the dynamic allocation.
2008-09-17screen: moved code to find_configured_screen()Max Kellermann1-10/+13
2008-09-17screen: mode_fn cannot be NULL, removed checksMax Kellermann1-17/+9
At startup, mode_fn is initialized with &screen_playlist, and it will never be reset to NULL. Remove all checks.
2008-09-17screen: before calling update(), check if it is definedMax Kellermann1-1/+1
That seems to be a fn->paint was checked, then the code called fn->update(). Fix this.
2008-09-17screen: removed screen_functions.get_lw()Max Kellermann8-53/+2
If it is really important to set the curser, we should think of a better way, instead of exporting one non-generic method. For now, just set the cursor to the origin.
2008-09-17replaced get_screen_X() with static screen_functions variableMax Kellermann10-208/+134
Compile time initialization saves resources, compared to run-time initialization. Declare all screen_function structs as global variables, and remove all get functions.
2008-09-17code style, indent with tabs IIIMax Kellermann3-112/+104
Follow the same code style als MPD itself.
2008-09-17mpdclient: call playlist_clear() in mpdclient_playlist_update()Max Kellermann1-2/+1
Instead of freeing the playlist with mpdclient_playlist_free(), call playlist_clear() to empty the song list. This fixes a segmentation fault which occured when you cleared the playlist.