]> git.sesse.net Git - vlc/blobdiff - modules/gui/ncurses.c
Qt: create a helper function to manage core ArtUrl
[vlc] / modules / gui / ncurses.c
index 137a461e37fb04203f7db74debafc2ab0a584060..d1cdba433d534e88754748975ea28147c14b7f6a 100644 (file)
 #   include <dirent.h>
 #endif
 
-#ifdef HAVE_CDDAX
-#define CDDA_MRL "cddax://"
-#else
-#define CDDA_MRL "cdda://"
-#endif
-
-#ifdef HAVE_VCDX
-#define VCD_MRL "vcdx://"
-#else
-#define VCD_MRL "vcd://"
-#endif
-
 #define SEARCH_CHAIN_SIZE 20
 #define OPEN_CHAIN_SIZE 50
 
@@ -310,7 +298,7 @@ static int Open( vlc_object_t *p_this )
         p_sys->psz_current_dir = psz_tmp;
     else
     {
-        p_sys->psz_current_dir = strdup( config_GetHomeDir() );
+        p_sys->psz_current_dir = config_GetUserDir( VLC_HOME_DIR );
         free( psz_tmp );
     }
 
@@ -548,7 +536,6 @@ static inline int RemoveLastUTF8Entity( char *psz, int len )
 static int HandleKey( intf_thread_t *p_intf, int i_key )
 {
     intf_sys_t *p_sys = p_intf->p_sys;
-    vlc_value_t val;
     int i_ret = 1;
 
     playlist_t *p_playlist = pl_Hold( p_intf );
@@ -560,22 +547,15 @@ static int HandleKey( intf_thread_t *p_intf, int i_key )
 
         switch( i_key )
         {
-            vlc_value_t val;
             /* Playlist Settings */
             case 'r':
-                var_Get( p_playlist, "random", &val );
-                val.b_bool = !val.b_bool;
-                var_Set( p_playlist, "random", val );
+                var_ToggleBool( p_playlist, "random" );
                 goto end;
             case 'l':
-                var_Get( p_playlist, "loop", &val );
-                val.b_bool = !val.b_bool;
-                var_Set( p_playlist, "loop", val );
+                var_ToggleBool( p_playlist, "loop" );
                 goto end;
             case 'R':
-                var_Get( p_playlist, "repeat", &val );
-                val.b_bool = !val.b_bool;
-                var_Set( p_playlist, "repeat", val );
+                var_ToggleBool( p_playlist, "repeat" );
                 goto end;
 
             /* Playlist sort */
@@ -753,8 +733,15 @@ static int HandleKey( intf_thread_t *p_intf, int i_key )
                 if( p_sys->pp_dir_entries[p_sys->i_box_bidx]->b_file || i_key == ' ' )
                 {
                     char* psz_uri;
-                    if( asprintf( &psz_uri, "directory://%s/%s", p_sys->psz_current_dir, p_sys->pp_dir_entries[p_sys->i_box_bidx]->psz_path ) == -1 )
+                    if( asprintf( &psz_uri, "%s://%s/%s",
+                        p_sys->pp_dir_entries[p_sys->i_box_bidx]->b_file ?
+                            "file" : "directory",
+                        p_sys->psz_current_dir,
+                        p_sys->pp_dir_entries[p_sys->i_box_bidx]->psz_path
+                        ) == -1 )
+                    {
                         psz_uri = NULL;
+                    }
 
                     playlist_item_t *p_parent = p_sys->p_node;
                     if( !p_parent )
@@ -960,6 +947,7 @@ static int HandleKey( intf_thread_t *p_intf, int i_key )
                 {
                     playlist_item_t *p_parent = p_sys->p_node;
 
+                    PL_LOCK;
                     if( !p_parent )
                     p_parent = playlist_CurrentPlayingItem(p_playlist) ? playlist_CurrentPlayingItem(p_playlist)->p_parent : NULL;
                     if( !p_parent )
@@ -967,6 +955,7 @@ static int HandleKey( intf_thread_t *p_intf, int i_key )
 
                     while( p_parent->p_parent && p_parent->p_parent->p_parent )
                         p_parent = p_parent->p_parent;
+                    PL_UNLOCK;
 
                     playlist_Add( p_playlist, p_sys->psz_open_chain, NULL,
                                   PLAYLIST_APPEND|PLAYLIST_GO, PLAYLIST_END,
@@ -1137,16 +1126,12 @@ static int HandleKey( intf_thread_t *p_intf, int i_key )
                                           VLC_OBJECT_VOUT, FIND_CHILD );
                 if( p_vout )
                 {
-                    var_Get( p_vout, "fullscreen", &val );
-                    val.b_bool = !val.b_bool;
-                    var_Set( p_vout, "fullscreen", val );
+                    var_ToggleBool( p_vout, "fullscreen" );
                     vlc_object_release( p_vout );
                 }
                 else
                 {
-                    var_Get( p_playlist, "fullscreen", &val );
-                    val.b_bool = !val.b_bool;
-                    var_Set( p_playlist, "fullscreen", val );
+                    var_ToggleBool( p_playlist, "fullscreen" );
                 }
             }
             i_ret = 0;
@@ -1456,10 +1441,13 @@ static void MainBoxWrite( intf_thread_t *p_intf, int l, int x, const char *p_fmt
 
 static void DumpObject( intf_thread_t *p_intf, int *l, vlc_object_t *p_obj, int i_level )
 {
-    if( p_obj->psz_object_name )
+    char *psz_name = vlc_object_get_name( p_obj );
+    if( psz_name )
+    {
         MainBoxWrite( p_intf, (*l)++, 1 + 2 * i_level, "%s \"%s\" (%p)",
-                p_obj->psz_object_type, p_obj->psz_object_name,
-                p_obj );
+                p_obj->psz_object_type, psz_name, p_obj );
+        free( psz_name );
+    }
     else
         MainBoxWrite( p_intf, (*l)++, 1 + 2 * i_level, "%s (%o)",
                 p_obj->psz_object_type, p_obj );
@@ -1767,7 +1755,7 @@ static void Redraw( intf_thread_t *p_intf, time_t *t_last_refresh )
             for( i=0; i<VLC_META_TYPE_COUNT; i++ )
             {
                 if( y >= y_end ) break;
-                char *psz_meta = p_item->p_meta->ppsz_meta[i];
+                char *psz_meta = vlc_meta_Get( p_item->p_meta, i );
                 if( psz_meta && *psz_meta )
                 {
                     const char *psz_meta_title;
@@ -2147,9 +2135,11 @@ static void Redraw( intf_thread_t *p_intf, time_t *t_last_refresh )
             input_thread_t *p_input2 = playlist_CurrentInput( p_playlist );
 
             PL_LOCK;
+            assert( p_item );
+            playlist_item_t *p_current_playing_item = playlist_CurrentPlayingItem(p_playlist);
             if( ( p_node && p_item->p_input == p_node->p_input ) ||
-                        ( !p_node && p_input2 &&
-                          p_item->p_input == playlist_CurrentPlayingItem(p_playlist)->p_input ) )
+                        ( !p_node && p_input2 && p_current_playing_item &&
+                          p_item->p_input == p_current_playing_item->p_input ) )
                 c = '*';
             else if( p_item == p_node || ( p_item != p_node &&
                         PlaylistIsPlaying( p_playlist, p_item ) ) )
@@ -2395,9 +2385,9 @@ static void Eject( intf_thread_t *p_intf )
 
     if( psz_name )
     {
-        if( !strncmp(psz_name, "dvd://", 4) )
+        if( !strncmp(psz_name, "dvd://", 6) )
         {
-            switch( psz_name[strlen("dvd://")] )
+            switch( psz_name[6] )
             {
             case '\0':
             case '@':
@@ -2409,23 +2399,23 @@ static void Eject( intf_thread_t *p_intf )
                 break;
             }
         }
-        else if( !strncmp(psz_name, VCD_MRL, strlen(VCD_MRL)) )
+        else if( !strncmp(psz_name, "vcd://", 6) )
         {
-            switch( psz_name[strlen(VCD_MRL)] )
+            switch( psz_name[6] )
             {
             case '\0':
             case '@':
-                psz_device = config_GetPsz( p_intf, VCD_MRL );
+                psz_device = config_GetPsz( p_intf, "vcd" );
                 break;
             default:
                 /* Omit the beginning MRL-selector characters */
-                psz_device = strdup( psz_name + strlen(VCD_MRL) );
+                psz_device = strdup( psz_name + 6 );
                 break;
             }
         }
-        else if( !strncmp(psz_name, CDDA_MRL, strlen(CDDA_MRL) ) )
+        else if( !strncmp(psz_name, "cdda://", 7 ) )
         {
-            switch( psz_name[strlen(CDDA_MRL)] )
+            switch( psz_name[7] )
             {
             case '\0':
             case '@':
@@ -2433,7 +2423,7 @@ static void Eject( intf_thread_t *p_intf )
                 break;
             default:
                 /* Omit the beginning MRL-selector characters */
-                psz_device = strdup( psz_name + strlen(CDDA_MRL) );
+                psz_device = strdup( psz_name + 7 );
                 break;
             }
         }