| Commit message (Collapse) | Author | Age | Files | Lines |
... | |
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
| |
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().
|
|
|
|
|
| |
Even for large responses, 16kB should be enough. There is no
performance gain for larger buffers, even if MPD is local.
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
| |
Why bother duplicating the buffer, when we can simply parse the
response directly from the input buffer?
|
|
|
|
|
|
| |
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.
|
|
|
|
|
| |
Declaring empty methods is of no use. If a method is empty, we should
set it to NULL in the screen_functions struct.
|
|
|
|
|
| |
Since the screen's initialization is guaranteed, we can remove the
NULL check in center_playing_item().
|
|
|
|
|
|
| |
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.
|
|
|
|
| |
Follow the same code style als MPD itself.
|
|
|
|
|
| |
When deselecting a song in the file browser, the local variable "idx"
was initialized and overwritten. Remove the initialization.
|
|
|
|
|
|
|
|
|
|
| |
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().
|
| |
|
| |
|
|
|
|
|
| |
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.
|
|
|
|
|
| |
current.lines is always initialized, and cannot be NULL, no need to
check it.
|
| |
|
|
|
|
|
| |
Why bother counting the elements of help_text[] (with sentinel) at
runtime, when the compiler can do it at compile time?
|
|
|
|
|
| |
lyrics_text_rows wasn't set anyway, I somehow removed the code in a
patch some time ago.
|
|
|
|
|
| |
Merge code which used to be duplicated in the screens "play", "help",
"lyrics".
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
| |
When the selected screen does not exist, return before calling
close().
|
|
|
|
|
| |
Since the number of screens is known at compile time, define a macro
which calculates this, instead of having a sentinel element.
|
|
|
|
|
| |
Screens which are not active have already been closed, or have never
been opened. Don't call close again on them.
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
| |
At startup, mode_fn is initialized with &screen_playlist, and it will
never be reset to NULL. Remove all checks.
|
|
|
|
|
| |
That seems to be a fn->paint was checked, then the code called
fn->update(). Fix this.
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
| |
Compile time initialization saves resources, compared to run-time
initialization. Declare all screen_function structs as global
variables, and remove all get functions.
|
|
|
|
| |
Follow the same code style als MPD itself.
|
|
|
|
|
|
| |
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.
|
|
|
|
|
| |
Due to a missing refresh() call, ncmpc painted the screen after one
second. Add refresh(), make ncmpc display immediately.
|
|
|
|
|
| |
Let us declare struct names in addition to typedef names, so we can
forward-declare them.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
In-process plugins are very problematic. It is much easier and
flexible to move the lyrics plugins to external programs, with a
trivial protocol. This is work in progress, among the things missing:
- protocol specification, including exit codes
- plugin installation
- plugin search directory
- run-time configuration (currently hard coded)
- automatic polling (using glib's main loop?)
- better and more robust error handling
|
| |
|
|
|
|
|
|
| |
Added functions like playlist_length(), playlist_get(),
playlist_replace(), playlist_remove(). Don't access the
mpdclient_playlist struct directly.
|
|
|
|
|
|
| |
Moved code from mpdclient_new() and mpdclient_playlist_free(). In
mpdclient_disconnect(), call mpdclient_playlist_clear() instead of
mpdclient_playlist_free() (which is now called in mpdclient_free()).
|
|
|
|
|
|
|
|
|
|
| |
Move everything which manipulates the mpdclient_playlist struct to
playlist.c. Many of the functions get a mpdclient pointer instead of
a playlist; this will be changed later.
The functions mpdclient_playlist_update() and
mpdclient_playlist_update_changes() stay in mpdclient.c for now, since
they are tightly connected to the client code.
|
|
|
|
|
|
| |
Since we compile ncmpc with glib, we can use its slice allocator for
efficient song allocation. I have added a way to disable this with a
macro.
|
|
|
|
|
| |
Use a forward declared struct mpd_song instead of the typedef
mpd_Song.
|
|
|
|
|
| |
Move everything which manipulates the mpd_Song struct to song.c.
Thousands of lines of too much for libmpdclient.c!
|
|
|
|
|
|
|
| |
To relax the include dependencies, give all structs real names, in
addition to the typedef names. This way, other headers can
forward-declare them, and do not need to include mpdclient.h. In the
future, the typedefs will be removed.
|
|
|
|
| |
Pass const pointers whenever possible.
|
|
|
|
| |
Follow the same code style als MPD itself.
|
|
|
|
|
| |
Apparently, somebody was too lazy to derive the formulas for cursor
movement, and wrote lots of while loops.
|
|
|
|
| |
Include only headers which are really used.
|
|
|
|
| |
Fix the type of write_data() to fit curl_write_callback.
|