]> git.sesse.net Git - vlc/blobdiff - modules/control/rc.c
Remove interface b_block property.
[vlc] / modules / control / rc.c
index 97acec3a7a76e0b7896af838abdaab6c7af0b486..24eec8b10a695f2b6b1e66a3a716b01c244de5c5 100644 (file)
  *****************************************************************************/
 #include <vlc/vlc.h>
 
-#include <stdlib.h>                                      /* malloc(), free() */
-#include <string.h>
 
 #include <errno.h>                                                 /* ENOMEM */
-#include <stdio.h>
 #include <ctype.h>
 #include <signal.h>
 
@@ -183,15 +180,16 @@ vlc_module_begin();
     set_subcategory( SUBCAT_INTERFACE_MAIN );
     set_description( _("Remote control interface") );
     add_bool( "rc-show-pos", 0, NULL, POS_TEXT, POS_LONGTEXT, VLC_TRUE );
-#ifdef HAVE_ISATTY
-    add_bool( "rc-fake-tty", 0, NULL, TTY_TEXT, TTY_LONGTEXT, VLC_TRUE );
-#endif
-    add_string( "rc-unix", 0, NULL, UNIX_TEXT, UNIX_LONGTEXT, VLC_TRUE );
-    add_string( "rc-host", 0, NULL, HOST_TEXT, HOST_LONGTEXT, VLC_TRUE );
 
 #ifdef WIN32
     add_bool( "rc-quiet", 0, NULL, QUIET_TEXT, QUIET_LONGTEXT, VLC_FALSE );
+#else
+#if defined (HAVE_ISATTY)
+    add_bool( "rc-fake-tty", 0, NULL, TTY_TEXT, TTY_LONGTEXT, VLC_TRUE );
+#endif
+    add_string( "rc-unix", 0, NULL, UNIX_TEXT, UNIX_LONGTEXT, VLC_TRUE );
 #endif
+    add_string( "rc-host", 0, NULL, HOST_TEXT, HOST_LONGTEXT, VLC_TRUE );
 
     set_capability( "interface", 20 );
     set_callbacks( Activate, Deactivate );
@@ -206,7 +204,8 @@ static int Activate( vlc_object_t *p_this )
     char *psz_host, *psz_unix_path;
     int  *pi_socket = NULL;
 
-#if defined(HAVE_ISATTY) && !defined(WIN32)
+#ifndef WIN32
+#if defined(HAVE_ISATTY)
     /* Check that stdin is a TTY */
     if( !config_GetInt( p_intf, "rc-fake-tty" ) && !isatty( 0 ) )
     {
@@ -220,7 +219,7 @@ static int Activate( vlc_object_t *p_this )
     {
         int i_socket;
 
-#if !defined(AF_LOCAL) || defined(WIN32)
+#ifndef AF_LOCAL
         msg_Warn( p_intf, "your OS doesn't support filesystem sockets" );
         free( psz_unix_path );
         return VLC_EGENERIC;
@@ -278,8 +277,9 @@ static int Activate( vlc_object_t *p_this )
         }
         pi_socket[0] = i_socket;
         pi_socket[1] = -1;
-#endif
+#endif /* AF_LOCAL */
     }
+#endif /* !WIN32 */
 
     if( ( pi_socket == NULL ) &&
         ( psz_host = config_GetPsz( p_intf, "rc-host" ) ) != NULL )
@@ -454,7 +454,7 @@ static void Run( intf_thread_t *p_intf )
     if( p_intf->p_sys->hConsoleIn == INVALID_HANDLE_VALUE )
     {
         msg_Err( p_intf, "couldn't find user input handle" );
-        p_intf->b_die = VLC_TRUE;
+        vlc_object_kill( p_intf );
     }
 #endif
 
@@ -497,8 +497,10 @@ static void Run( intf_thread_t *p_intf )
             {
                 if( !p_input->b_dead || !p_input->b_die )
                 {
-                    msg_rc( STATUS_CHANGE "( new input: %s )",
-                            input_GetItem(p_input)->psz_uri );
+                    char *psz_uri =
+                            input_item_GetURI( input_GetItem( p_input ) );
+                    msg_rc( STATUS_CHANGE "( new input: %s )", psz_uri );
+                    free( psz_uri );
                     msg_rc( STATUS_CHANGE "( audio volume: %d )",
                             config_GetInt( p_intf, "volume" ));
                 }
@@ -601,56 +603,27 @@ static void Run( intf_thread_t *p_intf )
             char *psz_alias = psz_cmd + 1;
             char *psz_mycmd = strdup( psz_arg );
             char *psz_myarg = strchr( psz_mycmd, ' ' );
-            int i_ret = VLC_EGENERIC;
+            char *psz_msg;
 
-            *psz_myarg = '\0';
-            psz_myarg ++;
-            vlc_object_t *p_obj =
-                vlc_object_find_name( p_input->p_libvlc, psz_alias,
-                                      FIND_CHILD );
-
-            if( !p_obj )
-                msg_rc( "Unknown destination object!" );
+            if( !psz_myarg )
+            {
+                msg_rc( "Not enough parameters." );
+            }
             else
             {
-                int i_type;
-                if( (i_type = var_Type( p_obj, psz_mycmd )) & VLC_VAR_ISCOMMAND )
-                {
-                    i_type &= 0xf0;
-                    if( i_type == VLC_VAR_INTEGER )
-                    {
-                        i_ret = var_SetInteger( p_obj, psz_mycmd,
-                                                atoi( psz_myarg ) );
-                    }
-                    else if( i_type == VLC_VAR_FLOAT )
-                    {
-                        i_ret = var_SetFloat( p_obj, psz_mycmd,
-                                              atof( psz_myarg ) );
-                    }
-                    else if( i_type == VLC_VAR_STRING )
-                    {
-                        i_ret = var_SetString( p_obj, psz_mycmd,
-                                               psz_myarg );
-                    }
-                    else if( i_type == VLC_VAR_BOOL )
-                    {
-                        i_ret = var_SetBool( p_obj, psz_mycmd,
-                                             atoi( psz_myarg ) );
-                    }
-                    else
-                    {
-                        msg_rc( "Unhandled command type. Fix the code!" );
-                    }
-                }
-                else
+                *psz_myarg = '\0';
+                psz_myarg ++;
+
+                var_Command( p_intf, psz_alias, psz_mycmd, psz_myarg,
+                             &psz_msg );
+
+                if( psz_msg )
                 {
-                    msg_rc( "Unknown command! %d", i_type );
+                    msg_rc( psz_msg );
+                    free( psz_msg );
                 }
-                vlc_object_release( p_obj );
             }
             free( psz_mycmd );
-            msg_rc( "%s on object %s: returned %i (%s)",
-                    psz_mycmd, psz_alias, i_ret, vlc_error( i_ret ) );
         }
         /* If the user typed a registered local command, try it */
         else if( var_Type( p_intf, psz_cmd ) & VLC_VAR_ISCOMMAND )
@@ -664,15 +637,15 @@ static void Run( intf_thread_t *p_intf )
                     psz_cmd, i_ret, vlc_error( i_ret ) );
         }
         /* Or maybe it's a global command */
-        else if( var_Type( p_intf->p_libvlc_global, psz_cmd ) & VLC_VAR_ISCOMMAND )
+        else if( var_Type( p_intf->p_libvlc, psz_cmd ) & VLC_VAR_ISCOMMAND )
         {
             vlc_value_t val;
             int i_ret;
 
             val.psz_string = psz_arg;
             /* FIXME: it's a global command, but we should pass the
-             * local object as an argument, not p_intf->p_libvlc_global. */
-            i_ret = var_Set( p_intf->p_libvlc_global, psz_cmd, val );
+             * local object as an argument, not p_intf->p_libvlc. */
+            i_ret = var_Set( p_intf->p_libvlc, psz_cmd, val );
             if( i_ret != 0 )
             {
                 msg_rc( "%s: returned %i (%s)",
@@ -774,10 +747,12 @@ static void Run( intf_thread_t *p_intf )
 
             Help( p_intf, b_longhelp );
         }
+#if 0
         else if( !strcmp( psz_cmd, "check-updates" ) )
         {
             checkUpdates( p_intf, psz_arg );
         }
+#endif
         else if( !strcmp( psz_cmd, "key" ) || !strcmp( psz_cmd, "hotkey" ) )
         {
             var_SetInteger( p_intf->p_libvlc, "key-pressed",
@@ -1425,8 +1400,10 @@ static int Playlist( vlc_object_t *p_this, char const *psz_cmd,
         if( p_playlist->p_input )
         {
             /* Replay the current state of the system. */
-            msg_rc( STATUS_CHANGE "( new input: %s )",
-                    input_GetItem(p_playlist->p_input)->psz_uri );
+            char *psz_uri =
+                    input_item_GetURI( input_GetItem( p_playlist->p_input ) );
+            msg_rc( STATUS_CHANGE "( new input: %s )", psz_uri );
+            free( psz_uri );
             msg_rc( STATUS_CHANGE "( audio volume: %d )",
                     config_GetInt( p_intf, "volume" ));
 
@@ -1473,7 +1450,7 @@ static int Quit( vlc_object_t *p_this, char const *psz_cmd,
         playlist_Stop( p_playlist );
         vlc_object_release( p_playlist );
     }
-    p_this->p_libvlc->b_die = VLC_TRUE;
+    vlc_object_kill( p_this->p_libvlc );
     return VLC_SUCCESS;
 }
 
@@ -1485,7 +1462,6 @@ static int Intf( vlc_object_t *p_this, char const *psz_cmd,
     p_newintf = intf_Create( p_this->p_libvlc, newval.psz_string, 0, NULL );
     if( p_newintf )
     {
-        p_newintf->b_block = VLC_FALSE;
         if( intf_RunThread( p_newintf ) )
         {
             vlc_object_detach( p_newintf );
@@ -1988,7 +1964,7 @@ vlc_bool_t ReadCommand( intf_thread_t *p_intf, char *p_buffer, int *pi_size )
         }
         else
             /* Standard input closed: exit */
-            p_intf->b_die = VLC_TRUE;
+            vlc_object_kill( p_intf );
 
         p_buffer[ *pi_size ] = 0;
         return VLC_TRUE;
@@ -2081,6 +2057,7 @@ static input_item_t *parse_MRL( intf_thread_t *p_intf, char *psz_mrl )
     return p_item;
 }
 
+#if 0
 /*****************************************************************************
  * checkUpdates : check for updates
  ****************************************************************************/
@@ -2197,3 +2174,4 @@ static void checkUpdates( intf_thread_t *p_intf, char *psz_arg )
     }
     update_Delete( p_u );
 }
+#endif