]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/input_manager.cpp
Do not check file size coherency on multi-parts rar.
[vlc] / modules / gui / qt4 / input_manager.cpp
index e2978850e0d3a570a97770a82b8cdd7fa62fab95..2500bb4e46af603a140654e03aa9987f2bae511b 100644 (file)
@@ -32,6 +32,8 @@
 #include "input_manager.hpp"
 #include <vlc_keys.h>
 #include <vlc_url.h>
+#include <vlc_strings.h>
+#include <vlc_aout.h>
 
 #include <QApplication>
 
@@ -284,6 +286,8 @@ inline void InputManager::delCallbacks()
 static int ItemChanged( vlc_object_t *p_this, const char *psz_var,
                         vlc_value_t oldval, vlc_value_t newval, void *param )
 {
+    VLC_UNUSED( p_this ); VLC_UNUSED( psz_var ); VLC_UNUSED( oldval );
+
     InputManager *im = (InputManager*)param;
     input_item_t *p_item = static_cast<input_item_t *>(newval.p_address);
 
@@ -295,6 +299,8 @@ static int ItemChanged( vlc_object_t *p_this, const char *psz_var,
 static int InputEvent( vlc_object_t *p_this, const char *,
                        vlc_value_t, vlc_value_t newval, void *param )
 {
+    VLC_UNUSED( p_this );
+
     InputManager *im = (InputManager*)param;
     IMEvent *event;
 
@@ -455,46 +461,36 @@ void InputManager::UpdateRate()
 void InputManager::UpdateName()
 {
     /* Update text, name and nowplaying */
-    QString text;
-
-    /* Try to get the Title, then the Name */
-    char *psz_name = input_item_GetTitleFbName( input_GetItem( p_input ) );
+    QString name;
 
     /* Try to get the nowplaying */
-    char *psz_nowplaying =
-        input_item_GetNowPlaying( input_GetItem( p_input ) );
-    if( !EMPTY_STR( psz_nowplaying ) )
-    {
-        text.sprintf( "%s - %s", psz_nowplaying, psz_name );
-    }
-    else  /* Do it ourself */
-    {
-        char *psz_artist = input_item_GetArtist( input_GetItem( p_input ) );
-
-        if( !EMPTY_STR( psz_artist ) )
-            text.sprintf( "%s - %s", psz_artist, psz_name );
-        else
-            text.sprintf( "%s", psz_name );
-
-        free( psz_artist );
-    }
-    /* Free everything */
-    free( psz_name );
-    free( psz_nowplaying );
+    char *format = var_InheritString( p_intf, "input-title-format" );
+    char *formated = str_format_meta( p_input, format );
+    free( format );
+    name = qfu(formated);
+    free( formated );
 
     /* If we have Nothing */
-    if( text.isEmpty() )
+    if( name.isEmpty() )
     {
-        psz_name = input_item_GetURI( input_GetItem( p_input ) );
-        text.sprintf( "%s", psz_name );
-        text = text.remove( 0, text.lastIndexOf( DIR_SEP ) + 1 );
-        free( psz_name );
+        char *uri = input_item_GetURI( input_GetItem( p_input ) );
+        char *file = uri ? strrchr( uri, '/' ) : NULL;
+        if( file != NULL )
+        {
+            decode_URI( ++file );
+            name = qfu(file);
+        }
+        else
+            name = qfu(uri);
+        free( uri );
     }
 
-    if( oldName != text )
+    name = name.trimmed();
+
+    if( oldName != name )
     {
-        emit nameChanged( text );
-        oldName = text;
+        emit nameChanged( name );
+        oldName = name;
     }
 }
 
@@ -612,7 +608,7 @@ void InputManager::UpdateVout()
             emit voutChanged( b_video );
 
         /* Release the vout list */
-        for( int i = 0; i < i_vout; i++ )
+        for( size_t i = 0; i < i_vout; i++ )
             vlc_object_release( (vlc_object_t*)pp_vout[i] );
         free( pp_vout );
     }
@@ -956,26 +952,13 @@ MainInputManager::MainInputManager( intf_thread_t *_p_intf )
     var_AddCallback( THEPL, "repeat", RepeatChanged, this );
     var_AddCallback( THEPL, "loop", LoopChanged, this );
 
-    var_AddCallback( THEPL, "volume-change", VolumeChanged, this );
+    var_AddCallback( THEPL, "volume", VolumeChanged, this );
     var_AddCallback( THEPL, "mute", SoundMuteChanged, this );
 
     /* Warn our embedded IM about input changes */
     DCONNECT( this, inputChanged( input_thread_t * ),
               im, setInput( input_thread_t * ) );
 
-    /* emit check if playlist has already started playing */
-    input_thread_t *p_input = playlist_CurrentInput( THEPL );
-    if( p_input )
-    {
-        input_item_t *p_item = input_GetItem( p_input );
-        if( p_item )
-        {
-            IMEvent *event = new IMEvent( ItemChanged_Type, p_item );
-            customEvent( event );
-            delete event;
-        }
-        vlc_object_release( p_input );
-    }
 }
 
 MainInputManager::~MainInputManager()
@@ -987,7 +970,7 @@ MainInputManager::~MainInputManager()
        vlc_object_release( p_input );
     }
 
-    var_DelCallback( THEPL, "volume-change", VolumeChanged, this );
+    var_DelCallback( THEPL, "volume", VolumeChanged, this );
     var_DelCallback( THEPL, "mute", SoundMuteChanged, this );
 
     var_DelCallback( THEPL, "activity", PLItemChanged, this );
@@ -1018,7 +1001,6 @@ void MainInputManager::customEvent( QEvent *event )
     int type = event->type();
 
     PLEvent *plEv;
-    IMEvent *imEv;
 
     // msg_Dbg( p_intf, "New MainIM Event of type: %i", type );
     switch( type )
@@ -1045,8 +1027,9 @@ void MainInputManager::customEvent( QEvent *event )
         notifyRepeatLoop();
         return;
     case LeafToParent_Type:
-        imEv = static_cast<IMEvent*>( event );
-        emit leafBecameParent( imEv->p_item );
+        plEv = static_cast<PLEvent*>( event );
+        emit leafBecameParent( plEv->i_item );
+        return;
     default:
         if( type != ItemChanged_Type ) return;
     }
@@ -1106,6 +1089,14 @@ void MainInputManager::prev()
    playlist_Prev( THEPL );
 }
 
+void MainInputManager::prevOrReset()
+{
+    if( !p_input || var_GetTime(  p_input , "time") < 10000 )
+        playlist_Prev( THEPL );
+    else
+        getIM()->sliderUpdate( 0.0 );
+}
+
 void MainInputManager::togglePlayPause()
 {
     /* No input, play */
@@ -1180,6 +1171,8 @@ bool MainInputManager::getPlayExitState()
 static int PLItemChanged( vlc_object_t *p_this, const char *psz_var,
                         vlc_value_t oldval, vlc_value_t, void *param )
 {
+    VLC_UNUSED( p_this ); VLC_UNUSED( psz_var ); VLC_UNUSED( oldval );
+
     MainInputManager *mim = (MainInputManager*)param;
 
     IMEvent *event = new IMEvent( ItemChanged_Type );
@@ -1190,10 +1183,11 @@ static int PLItemChanged( vlc_object_t *p_this, const char *psz_var,
 static int LeafToParent( vlc_object_t *p_this, const char *psz_var,
                         vlc_value_t oldval, vlc_value_t newval, void *param )
 {
+    VLC_UNUSED( p_this ); VLC_UNUSED( psz_var ); VLC_UNUSED( oldval );
     MainInputManager *mim = (MainInputManager*)param;
 
-    IMEvent *event = new IMEvent( LeafToParent_Type,
-                                  static_cast<input_item_t*>( newval.p_address ) );
+    PLEvent *event = new PLEvent( LeafToParent_Type, newval.i_int );
+
     QApplication::postEvent( mim, event );
     return VLC_SUCCESS;
 }
@@ -1201,6 +1195,8 @@ static int LeafToParent( vlc_object_t *p_this, const char *psz_var,
 static int VolumeChanged( vlc_object_t *p_this, const char *psz_var,
                         vlc_value_t oldval, vlc_value_t newval, void *param )
 {
+    VLC_UNUSED( p_this ); VLC_UNUSED( psz_var ); VLC_UNUSED( oldval ); VLC_UNUSED( newval );
+
     MainInputManager *mim = (MainInputManager*)param;
 
     IMEvent *event = new IMEvent( VolumeChanged_Type );
@@ -1211,6 +1207,8 @@ static int VolumeChanged( vlc_object_t *p_this, const char *psz_var,
 static int SoundMuteChanged( vlc_object_t *p_this, const char *psz_var,
                         vlc_value_t oldval, vlc_value_t newval, void *param )
 {
+    VLC_UNUSED( p_this ); VLC_UNUSED( psz_var ); VLC_UNUSED( oldval ); VLC_UNUSED( newval );
+
     MainInputManager *mim = (MainInputManager*)param;
 
     IMEvent *event = new IMEvent( SoundMuteChanged_Type );
@@ -1221,6 +1219,8 @@ static int SoundMuteChanged( vlc_object_t *p_this, const char *psz_var,
 static int PLItemAppended
 ( vlc_object_t * obj, const char *var, vlc_value_t old, vlc_value_t cur, void *data )
 {
+    VLC_UNUSED( obj ); VLC_UNUSED( var ); VLC_UNUSED( old );
+
     MainInputManager *mim = static_cast<MainInputManager*>(data);
     playlist_add_t *p_add = static_cast<playlist_add_t*>( cur.p_address );
 
@@ -1231,6 +1231,8 @@ static int PLItemAppended
 static int PLItemRemoved
 ( vlc_object_t * obj, const char *var, vlc_value_t old, vlc_value_t cur, void *data )
 {
+    VLC_UNUSED( obj ); VLC_UNUSED( var ); VLC_UNUSED( old );
+
     MainInputManager *mim = static_cast<MainInputManager*>(data);
 
     PLEvent *event = new PLEvent( PLItemRemoved_Type, cur.i_int, 0  );
@@ -1241,6 +1243,8 @@ static int PLItemRemoved
 static int RandomChanged
 ( vlc_object_t * obj, const char *var, vlc_value_t old, vlc_value_t cur, void *data )
 {
+    VLC_UNUSED( obj ); VLC_UNUSED( var ); VLC_UNUSED( old ); VLC_UNUSED( cur );
+
     MainInputManager *mim = static_cast<MainInputManager*>(data);
 
     IMEvent *event = new IMEvent( RandomChanged_Type );
@@ -1252,6 +1256,8 @@ static int RandomChanged
 static int LoopChanged
 ( vlc_object_t * obj, const char *var, vlc_value_t old, vlc_value_t cur, void *data )
 {
+    VLC_UNUSED( obj ); VLC_UNUSED( var ); VLC_UNUSED( old ); VLC_UNUSED( cur );
+
     MainInputManager *mim = static_cast<MainInputManager*>(data);
 
     IMEvent *event = new IMEvent( LoopChanged_Type );
@@ -1262,6 +1268,8 @@ static int LoopChanged
 static int RepeatChanged
 ( vlc_object_t * obj, const char *var, vlc_value_t old, vlc_value_t cur, void *data )
 {
+    VLC_UNUSED( obj ); VLC_UNUSED( var ); VLC_UNUSED( old ); VLC_UNUSED( cur );
+
     MainInputManager *mim = static_cast<MainInputManager*>(data);
 
     IMEvent *event = new IMEvent( RepeatChanged_Type );