summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: c907d71)
raw | patch | inline | side by side (parent: c907d71)
author | Max Kellermann <max.kellermann@gmail.com> | |
Fri, 17 Mar 2017 21:51:46 +0000 (22:51 +0100) | ||
committer | Max Kellermann <max.kellermann@gmail.com> | |
Fri, 17 Mar 2017 22:07:02 +0000 (23:07 +0100) |
Provide a consistent, documented API.
src/callbacks.c | patch | blob | history | |
src/callbacks.h | patch | blob | history | |
src/mpdclient.c | patch | blob | history |
diff --git a/src/callbacks.c b/src/callbacks.c
index e12268227586640528e63cf7232913c2dea9bb55..90eb40923001281ba7eb3a1d9936b8eb175f335d 100644 (file)
--- a/src/callbacks.c
+++ b/src/callbacks.c
#include "screen_utils.h"
#include "screen_status.h"
#include "mpdclient.h"
-#include "charset.h"
static bool
_mpdclient_auth_callback(struct mpdclient *c, gint recursion)
}
void
-mpdclient_error_callback(const char *message_utf8)
+mpdclient_error_callback(const char *message)
{
- char *message_locale = utf8_to_locale(message_utf8);
- screen_status_printf("%s", message_locale);
- g_free(message_locale);
-
+ screen_status_message(message);
screen_bell();
doupdate();
}
diff --git a/src/callbacks.h b/src/callbacks.h
index 610050895c346ab905bced0de0d268a5dc2fe6a1..4fa472fc406802e4168b7c717b1613a22bdf3b38 100644 (file)
--- a/src/callbacks.h
+++ b/src/callbacks.h
/**
* To be implemented by the application: mpdclient.c calls this to
* display an error message.
+ *
+ * @param message a human-readable error message in the locale charset
*/
void
mpdclient_error_callback(const char *message);
diff --git a/src/mpdclient.c b/src/mpdclient.c
index c8351d14cb1526365975875ae10d2520179feeb8..4c480d781357a72d961a854514d4258cc78954f0 100644 (file)
--- a/src/mpdclient.c
+++ b/src/mpdclient.c
#include "filelist.h"
#include "config.h"
#include "gidle.h"
+#include "charset.h"
#include <mpd/client.h>
#include <assert.h>
static void
-mpdclient_invoke_error_callback(gcc_unused enum mpd_error error,
+mpdclient_invoke_error_callback(enum mpd_error error,
const char *message)
{
+ char *allocated;
+ if (error == MPD_ERROR_SERVER)
+ /* server errors are UTF-8, the others are locale */
+ message = allocated = utf8_to_locale(message);
+ else
+ allocated = NULL;
+
mpdclient_error_callback(message);
+ g_free(allocated);
}
/****************************************************************************/