]> git.sesse.net Git - vlc/blobdiff - modules/gui/ncurses.c
Qt: undo the FSC/KDE workaround
[vlc] / modules / gui / ncurses.c
index 23603208f33c2816d5db633d2235e35bce712666..b920f5b5c65328c3b720e0aa8d8b73051cadcce7 100644 (file)
@@ -51,6 +51,7 @@
 #include <vlc_playlist.h>
 #include <vlc_meta.h>
 #include <vlc_fs.h>
+#include <vlc_url.h>
 
 #include <assert.h>
 
@@ -258,7 +259,7 @@ static bool IsFile(const char *current_dir, const char *entry)
     char *uri;
     struct stat st;
 
-    if (asprintf(&uri, "%s/%s", current_dir, entry) != -1)
+    if (asprintf(&uri, "%s" DIR_SEP "%s", current_dir, entry) != -1)
     {
         ret = vlc_stat(uri, &st) || !S_ISDIR(st.st_mode);
         free(uri);
@@ -1131,7 +1132,7 @@ static int DrawStatus(intf_thread_t *p_intf)
 
             mvnprintw(y++, 0, COLS, _(" Position : %s/%s"), buf1, buf2);
 
-            aout_VolumeGet(p_playlist, &i_volume);
+            i_volume = aout_VolumeGet(p_playlist);
             mvnprintw(y++, 0, COLS, _(" Volume   : %i%%"),
                        i_volume*200/AOUT_VOLUME_MAX);
 
@@ -1439,31 +1440,27 @@ static bool HandleBrowseKey(intf_thread_t *p_intf, int key)
     case '\n':
     case ' ':
         dir_entry = p_sys->pp_dir_entries[p_sys->i_box_idx];
+        char *psz_path;
+        if (asprintf(&psz_path, "%s" DIR_SEP "%s", p_sys->psz_current_dir,
+                     dir_entry->psz_path) == -1)
+            return true;
 
         if (!dir_entry->b_file && key != ' ')
         {
-            char *current_dir = p_sys->psz_current_dir;
-            if (asprintf(&p_sys->psz_current_dir, "%s/%s",
-                          p_sys->psz_current_dir, dir_entry->psz_path) != -1)
-            {
-                ReadDir(p_intf);
-                free(current_dir);
-            }
-            else
-                p_sys->psz_current_dir = current_dir;
+            free(p_sys->psz_current_dir);
+            p_sys->psz_current_dir = psz_path;
+            ReadDir(p_intf);
 
             p_sys->i_box_start = 0;
             p_sys->i_box_idx = 0;
             return true;
         }
 
-        char* psz_uri;
-        if (asprintf(&psz_uri, "%s://%s/%s",
-                    dir_entry->b_file ? "file" : "directory",
-                    p_sys->psz_current_dir, dir_entry->psz_path) == -1)
-        {
-            return false;
-        }
+        char *psz_uri = make_URI(psz_path, dir_entry->b_file ? "file"
+                                                             : "directory");
+        free(psz_path);
+        if (psz_uri == NULL)
+            return true;
 
         playlist_t *p_playlist = pl_Get(p_intf);
         playlist_item_t *p_parent = p_sys->p_node;
@@ -1519,6 +1516,13 @@ static void HandleEditBoxKey(intf_thread_t *p_intf, int key, int box)
         }
         else if (len)
         {
+            char *psz_uri = make_URI(p_sys->psz_open_chain, NULL);
+            if (psz_uri == NULL)
+            {
+                p_sys->i_box_type = BOX_PLAYLIST;
+                return;
+            }
+
             playlist_t *p_playlist = pl_Get(p_intf);
             playlist_item_t *p_parent = p_sys->p_node, *p_current;
 
@@ -1535,11 +1539,12 @@ static void HandleEditBoxKey(intf_thread_t *p_intf, int key, int box)
                 p_parent = p_parent->p_parent;
             PL_UNLOCK;
 
-            playlist_Add(p_playlist, p_sys->psz_open_chain, NULL,
+            playlist_Add(p_playlist, psz_uri, NULL,
                   PLAYLIST_APPEND|PLAYLIST_GO, PLAYLIST_END,
                   p_parent->p_input == p_playlist->p_local_onelevel->p_input,
                   false);
 
+            free(psz_uri);
             p_sys->b_plidx_follow = true;
         }
         p_sys->i_box_type = BOX_PLAYLIST;
@@ -1573,8 +1578,8 @@ static void HandleEditBoxKey(intf_thread_t *p_intf, int key, int box)
         break;
 
     default:
-        if (len + 1 < search ? sizeof p_sys->psz_search_chain
-                             : sizeof p_sys->psz_open_chain)
+        if (len + 1 < (search ? sizeof p_sys->psz_search_chain
+                              : sizeof p_sys->psz_open_chain))
         {
             str[len + 0] = (char) key;
             str[len + 1] = '\0';