Code

screen_queue: no typedef for completion_callback_data_t
[ncmpc.git] / src / screen_queue.c
index 3d20da3bc999ad10f62e13dfb3a9aa9c7e0471f5..a5383fa19927d6536db98f7f60cc0aff7450415a 100644 (file)
@@ -36,6 +36,7 @@
 #include "screen_utils.h"
 #include "screen_song.h"
 #include "screen_lyrics.h"
+#include "db_completion.h"
 #include "Compiler.h"
 
 #ifndef NCMPC_MINI
 #define MAX_SONG_LENGTH 512
 
 #ifndef NCMPC_MINI
-typedef struct
-{
-       GList **list;
-       GList **dir_list;
-       struct mpdclient *c;
-} completion_callback_data_t;
-
 static struct hscroll hscroll;
 #endif
 
@@ -205,9 +199,15 @@ static void add_dir(GCompletion *gcmp, gchar *dir, GList **dir_list,
        *dir_list = g_list_append(*dir_list, g_strdup(dir));
 }
 
+struct completion_callback_data {
+       GList **list;
+       GList **dir_list;
+       struct mpdclient *c;
+};
+
 static void add_pre_completion_cb(GCompletion *gcmp, gchar *line, void *data)
 {
-       completion_callback_data_t *tmp = (completion_callback_data_t *)data;
+       struct completion_callback_data *tmp = data;
        GList **dir_list = tmp->dir_list;
        GList **list = tmp->list;
        struct mpdclient *c = tmp->c;
@@ -226,7 +226,7 @@ static void add_pre_completion_cb(GCompletion *gcmp, gchar *line, void *data)
 static void add_post_completion_cb(GCompletion *gcmp, gchar *line,
                                   GList *items, void *data)
 {
-       completion_callback_data_t *tmp = (completion_callback_data_t *)data;
+       struct completion_callback_data *tmp = data;
        GList **dir_list = tmp->dir_list;
        GList **list = tmp->list;
        struct mpdclient *c = tmp->c;
@@ -252,7 +252,7 @@ handle_add_to_playlist(struct mpdclient *c)
 
        GList *list = NULL;
        GList *dir_list = NULL;
-       completion_callback_data_t data = {
+       struct completion_callback_data data = {
                .list = &list,
                .dir_list = &dir_list,
                .c = c,
@@ -369,13 +369,28 @@ screen_queue_exit(void)
        list_window_free(lw);
 }
 
+/**
+ * Extract the host portion (without the optional password) from the
+ * MPD_HOST string.
+ */
+static const char *
+host_without_password(const char *host)
+{
+       const char *separator = strchr(host, '@');
+       if (separator != NULL && separator != host && separator[1] != 0)
+               host = separator + 1;
+
+       return host;
+}
+
 static const char *
 screen_queue_title(char *str, size_t size)
 {
        if (options.host == NULL)
                return _("Queue");
 
-       g_snprintf(str, size, _("Queue on %s"), options.host);
+       g_snprintf(str, size, _("Queue on %s"),
+                  host_without_password(options.host));
        return str;
 }