]> git.sesse.net Git - vlc/blobdiff - modules/control/rc.c
minimal_macosx: Fix the minimal window.
[vlc] / modules / control / rc.c
index 2dec506c85f9fa107b27549010e5f6296f636cd5..f0b0514e3cead752975b407dd69f5a6ad7bf407e 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" ));
                 }
@@ -603,16 +605,23 @@ static void Run( intf_thread_t *p_intf )
             char *psz_myarg = strchr( psz_mycmd, ' ' );
             char *psz_msg;
 
-            *psz_myarg = '\0';
-            psz_myarg ++;
-
-            var_Command( p_input, psz_alias, psz_mycmd, psz_myarg, &psz_msg );
+            if( !psz_myarg )
+            {
+                msg_rc( "Not enough parameters." );
+            }
+            else
+            {
+                *psz_myarg = '\0';
+                psz_myarg ++;
 
+                var_Command( p_intf, psz_alias, psz_mycmd, psz_myarg,
+                             &psz_msg );
 
-            if( psz_msg )
-            {
-                msg_rc( psz_msg );
-                free( psz_msg );
+                if( psz_msg )
+                {
+                    msg_rc( psz_msg );
+                    free( psz_msg );
+                }
             }
             free( psz_mycmd );
         }
@@ -628,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)",
@@ -1389,8 +1398,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" ));
 
@@ -1437,7 +1448,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;
 }
 
@@ -1952,7 +1963,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;