diff --git a/src/screen_chat.c b/src/screen_chat.c
index b4d3aaca89844e97aa36d6dd4513577657a8e313..b4c80fbce14c1432042a5519325444ba0fa8a94d 100644 (file)
--- a/src/screen_chat.c
+++ b/src/screen_chat.c
#include "mpdclient.h"
#include "i18n.h"
#include "charset.h"
+#include "options.h"
#include <glib.h>
#include <mpd/idle.h>
static void
process_message(struct mpd_message *message)
{
- char *message_text;
-
assert(message != NULL);
/* You'll have to move this out of screen_chat, if you want to use
client-to-client messages anywhere else */
assert(g_strcmp0(mpd_message_get_channel(message), chat_channel) == 0);
- message_text = utf8_to_locale(mpd_message_get_text(message));
+ char *message_text = utf8_to_locale(mpd_message_get_text(message));
screen_text_append(&text, message_text);
g_free(message_text);
}
}
+static char *
+screen_chat_get_prefix(void)
+{
+ static char *prefix = NULL;
+
+ if (prefix)
+ return prefix;
+
+ if (options.chat_prefix) {
+ /* Options are encoded in the "locale" charset */
+ prefix = locale_to_utf8(options.chat_prefix);
+ return prefix;
+ }
+
+ prefix = g_strconcat("<", g_get_user_name(), "> ", NULL);
+ return prefix;
+}
+
static void
screen_chat_send_message(struct mpdclient *c, char *msg)
{
char *utf8 = locale_to_utf8(msg);
-
- (void) mpdclient_cmd_send_message(c, chat_channel, utf8);
+ char *prefix = screen_chat_get_prefix();
+ char *full_msg = g_strconcat(prefix, utf8, NULL);
g_free(utf8);
+
+ (void) mpdclient_cmd_send_message(c, chat_channel, full_msg);
+ g_free(full_msg);
}
static bool
}
static const char *
-screen_chat_title(G_GNUC_UNUSED char *s, G_GNUC_UNUSED size_t size)
+screen_chat_title(gcc_unused char *s, gcc_unused size_t size)
{
return _("Chat");
}