]> git.sesse.net Git - vlc/blobdiff - modules/control/http/rpn.c
Lock/Unlock the http control module.
[vlc] / modules / control / http / rpn.c
index b5c840ec015b10a24c2d4d21724500b2ee66161c..712b145d7b8af8c486b249de0be152442221eca1 100644 (file)
@@ -1,8 +1,8 @@
 /*****************************************************************************
  * rpn.c : RPN evaluator for the HTTP Interface
  *****************************************************************************
- * Copyright (C) 2001-2005 the VideoLAN team
- * $Id: http.c 12225 2005-08-18 10:01:30Z massiot $
+ * Copyright (C) 2001-2006 the VideoLAN team
+ * $Id$
  *
  * Authors: Gildas Bazin <gbazin@netcourrier.com>
  *          Laurent Aimar <fenrir@via.ecp.fr>
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
 
 #include "http.h"
+#include "vlc_url.h"
+#include "vlc_meta.h"
+#include "vlc_strings.h"
+
+static vlc_object_t *GetVLCObject( intf_thread_t *p_intf,
+                                   const char *psz_object,
+                                   bool *pb_need_release )
+{
+    intf_sys_t    *p_sys = p_intf->p_sys;
+    int i_object_type = 0;
+    vlc_object_t *p_object = NULL;
+    *pb_need_release = false;
+
+    if( !strcmp( psz_object, "VLC_OBJECT_LIBVLC" ) )
+        p_object = VLC_OBJECT(p_intf->p_libvlc);
+    else if( !strcmp( psz_object, "VLC_OBJECT_INTF" ) )
+        p_object = VLC_OBJECT(p_intf);
+    else if( !strcmp( psz_object, "VLC_OBJECT_PLAYLIST" ) )
+        p_object = VLC_OBJECT(p_sys->p_playlist);
+    else if( !strcmp( psz_object, "VLC_OBJECT_INPUT" ) )
+        p_object = VLC_OBJECT(p_sys->p_input);
+    else if( !strcmp( psz_object, "VLC_OBJECT_VOUT" ) )
+        i_object_type = VLC_OBJECT_VOUT;
+    else if( !strcmp( psz_object, "VLC_OBJECT_AOUT" ) )
+        i_object_type = VLC_OBJECT_AOUT;
+    else
+        msg_Warn( p_intf, "unknown object type (%s)", psz_object );
+
+    if( p_object == NULL && i_object_type )
+    {
+        *pb_need_release = true;
+        p_object = vlc_object_find( p_intf, i_object_type, FIND_ANYWHERE );
+    }
+
+    return p_object;
+}
 
 void SSInit( rpn_stack_t *st )
 {
@@ -46,7 +85,7 @@ void SSPush( rpn_stack_t *st, const char *s )
     }
 }
 
-char * SSPop( rpn_stack_t *st )
+char *SSPop( rpn_stack_t *st )
 {
     if( st->i_stack <= 0 )
     {
@@ -80,14 +119,14 @@ int SSPopN( rpn_stack_t *st, mvar_t  *vars )
 
 void SSPushN( rpn_stack_t *st, int i )
 {
-    char v[512];
+    char v[12];
 
-    sprintf( v, "%d", i );
+    snprintf( v, sizeof (v), "%d", i );
     SSPush( st, v );
 }
 
-void  EvaluateRPN( intf_thread_t *p_intf, mvar_t  *vars,
-                   rpn_stack_t *st, char *exp )
+void EvaluateRPN( intf_thread_t *p_intf, mvar_t  *vars,
+                      rpn_stack_t *st, char *exp )
 {
     intf_sys_t    *p_sys = p_intf->p_sys;
 
@@ -104,14 +143,14 @@ void  EvaluateRPN( intf_thread_t *p_intf, mvar_t  *vars,
         if( *exp == '\'' )
         {
             /* extract string */
-            p = E_(FirstWord)( exp, exp );
+            p = FirstWord( exp, exp );
             SSPush( st, exp );
             exp = p;
             continue;
         }
 
         /* extract token */
-        p = E_(FirstWord)( exp, exp );
+        p = FirstWord( exp, exp );
         s = exp;
         if( p == NULL )
         {
@@ -311,25 +350,30 @@ void  EvaluateRPN( intf_thread_t *p_intf, mvar_t  *vars,
         {
             char *url = mvar_GetValue( vars, "url_value" );
             char *name = SSPop( st );
-            char value[512];
-            char *tmp;
-
-            E_(ExtractURIValue)( url, name, value, 512 );
-            E_(DecodeEncodedURI)( value );
-            tmp = E_(FromUTF8)( p_intf, value );
-            SSPush( st, tmp );
-            free( tmp );
+            char *value = ExtractURIString( url, name );
+            if( value != NULL )
+            {
+                decode_URI( value );
+                SSPush( st, value );
+                free( value );
+            }
+            else
+                SSPush( st, "" );
+
             free( name );
         }
         else if( !strcmp( s, "url_encode" ) )
         {
             char *url = SSPop( st );
-            char *value;
-
-            value = E_(ToUTF8)( p_intf, url );
+            char *value = vlc_UrlEncode( url );
             free( url );
-            url = value;
-            value = vlc_UrlEncode( url );
+            SSPush( st, value );
+            free( value );
+        }
+        else if( !strcmp( s, "xml_encode" ) )
+        {
+            char *url = SSPop( st );
+            char *value = convert_xml_special_chars( url );
             free( url );
             SSPush( st, value );
             free( value );
@@ -344,7 +388,7 @@ void  EvaluateRPN( intf_thread_t *p_intf, mvar_t  *vars,
 
             while( *str != '\0' )
             {
-                if( *str == '"' || *str == '\'' )
+                if( *str == '"' || *str == '\'' || *str == '\\' )
                 {
                     *p++ = '\\';
                 }
@@ -361,17 +405,17 @@ void  EvaluateRPN( intf_thread_t *p_intf, mvar_t  *vars,
         {
             char *psz_src = SSPop( st );
             char *psz_dest;
+            char *str = psz_src;
 
             p = psz_dest = strdup( psz_src );
 
-            while( *psz_src != '\0' )
+            while( *str )
             {
-                if( *psz_src == '\\' )
+                if( *str == '\\' && *(str + 1) )
                 {
-                    *psz_src++;
+                    str++;
                 }
-                *p++ = *psz_src;
-                psz_src++;
+                *p++ = *str++;
             }
             *p = '\0';
 
@@ -383,44 +427,8 @@ void  EvaluateRPN( intf_thread_t *p_intf, mvar_t  *vars,
         {
             char *psz_src = SSPop( st );
             char *psz_dest;
-            char *str = psz_src;
 
-            p = psz_dest = malloc( strlen( str ) * 6 + 1 );
-
-            while( *str != '\0' )
-            {
-                if( *str == '&' )
-                {
-                    strcpy( p, "&amp;" );
-                    p += 5;
-                }
-                else if( *str == '\"' )
-                {
-                    strcpy( p, "&quot;" );
-                    p += 6;
-                }
-                else if( *str == '\'' )
-                {
-                    strcpy( p, "&#039;" );
-                    p += 6;
-                }
-                else if( *str == '<' )
-                {
-                    strcpy( p, "&lt;" );
-                    p += 4;
-                }
-                else if( *str == '>' )
-                {
-                    strcpy( p, "&gt;" );
-                    p += 4;
-                }
-                else
-                {
-                    *p++ = *str;
-                }
-                str++;
-            }
-            *p = '\0';
+            psz_dest = convert_xml_special_chars( psz_src );
 
             SSPush( st, psz_dest );
             free( psz_src );
@@ -428,73 +436,12 @@ void  EvaluateRPN( intf_thread_t *p_intf, mvar_t  *vars,
         }
         else if( !strcmp( s, "realpath" ) )
         {
-            char dir[MAX_DIR_SIZE], *src;
             char *psz_src = SSPop( st );
-            char *psz_dir = psz_src;
-            char sep;
-
-            /* convert all / to native separator */
-#if defined( WIN32 )
-            while( (p = strchr( psz_dir, '/' )) )
-            {
-                *p = '\\';
-            }
-            sep = '\\';
-#else
-            sep = '/';
-#endif
-
-            if( *psz_dir == '~' )
-            {
-                /* This is incomplete : we should also support the ~cmassiot/ syntax. */
-                snprintf( dir, sizeof(dir), "%s/%s", p_intf->p_vlc->psz_homedir,
-                          psz_dir + 1 );
-                psz_dir = dir;
-            }
-
-            /* first fix all .. dir */
-            p = src = psz_dir;
-            while( *src )
-            {
-                if( src[0] == '.' && src[1] == '.' )
-                {
-                    src += 2;
-                    if( p <= &psz_dir[1] )
-                    {
-                        continue;
-                    }
-
-                    p -= 2;
-
-                    while( p > &psz_dir[1] && *p != sep )
-                    {
-                        p--;
-                    }
-                }
-                else if( *src == sep )
-                {
-                    if( p > psz_dir && p[-1] == sep )
-                    {
-                        src++;
-                    }
-                    else
-                    {
-                        *p++ = *src++;
-                    }
-                }
-                else
-                {
-                    do
-                    {
-                        *p++ = *src++;
-                    } while( *src && *src != sep );
-                }
-            }
-            if( p != psz_dir + 1 && p[-1] == '/' ) p--;
-            *p = '\0';
+            char *psz_dir = RealPath( psz_src );
 
             SSPush( st, psz_dir );
             free( psz_src );
+            free( psz_dir );
         }
         /* 4. stack functions */
         else if( !strcmp( s, "dup" ) )
@@ -548,57 +495,70 @@ void  EvaluateRPN( intf_thread_t *p_intf, mvar_t  *vars,
             int i_id = SSPopN( st, vars );
             int i_ret;
 
-            i_ret = playlist_Control( p_sys->p_playlist, PLAYLIST_ITEMPLAY,
+            vlc_object_lock( p_sys->p_playlist );
+            i_ret = playlist_Control( p_sys->p_playlist, PLAYLIST_VIEWPLAY,
+                                      pl_Locked, NULL,
                                       playlist_ItemGetById( p_sys->p_playlist,
-                                      i_id ) );
+                                      i_id, pl_Locked ) );
+            vlc_object_unlock( p_sys->p_playlist );
             msg_Dbg( p_intf, "requested playlist item: %i", i_id );
             SSPushN( st, i_ret );
         }
         else if( !strcmp( s, "vlc_stop" ) )
         {
-            playlist_Control( p_sys->p_playlist, PLAYLIST_STOP );
+            playlist_Control( p_sys->p_playlist, PLAYLIST_STOP, pl_Unlocked );
             msg_Dbg( p_intf, "requested playlist stop" );
         }
         else if( !strcmp( s, "vlc_pause" ) )
         {
-            playlist_Control( p_sys->p_playlist, PLAYLIST_PAUSE );
+            playlist_Control( p_sys->p_playlist, PLAYLIST_PAUSE, pl_Unlocked );
             msg_Dbg( p_intf, "requested playlist pause" );
         }
         else if( !strcmp( s, "vlc_next" ) )
         {
-            playlist_Control( p_sys->p_playlist, PLAYLIST_SKIP, 1 );
+            playlist_Control( p_sys->p_playlist, PLAYLIST_SKIP, pl_Unlocked, 1 );
             msg_Dbg( p_intf, "requested playlist next" );
         }
         else if( !strcmp( s, "vlc_previous" ) )
         {
-            playlist_Control( p_sys->p_playlist, PLAYLIST_SKIP, -1 );
+            playlist_Control( p_sys->p_playlist, PLAYLIST_SKIP, pl_Unlocked, -1 );
             msg_Dbg( p_intf, "requested playlist previous" );
         }
         else if( !strcmp( s, "vlc_seek" ) )
         {
             char *psz_value = SSPop( st );
-            E_(HandleSeek)( p_intf, psz_value );
+            HandleSeek( p_intf, psz_value );
             msg_Dbg( p_intf, "requested playlist seek: %s", psz_value );
             free( psz_value );
         }
         else if( !strcmp( s, "vlc_var_type" )
                   || !strcmp( s, "vlc_config_type" ) )
         {
-            const char *psz_type = NULL;
-            char *psz_variable = SSPop( st );
             vlc_object_t *p_object;
-            int i_type;
+            const char *psz_type = NULL;
+            int i_type = 0;
 
             if( !strcmp( s, "vlc_var_type" ) )
             {
-                p_object = VLC_OBJECT(p_sys->p_input);
+                char *psz_object = SSPop( st );
+                char *psz_variable = SSPop( st );
+                bool b_need_release;
+
+                p_object = GetVLCObject( p_intf, psz_object, &b_need_release );
+
                 if( p_object != NULL )
                     i_type = var_Type( p_object, psz_variable );
+                free( psz_variable );
+                free( psz_object );
+                if( b_need_release && p_object != NULL )
+                    vlc_object_release( p_object );
             }
             else
             {
+                char *psz_variable = SSPop( st );
                 p_object = VLC_OBJECT(p_intf);
                 i_type = config_GetType( p_object, psz_variable );
+                free( psz_variable );
             }
 
             if( p_object != NULL )
@@ -640,33 +600,37 @@ void  EvaluateRPN( intf_thread_t *p_intf, mvar_t  *vars,
                 psz_type = "INVALID";
 
             SSPush( st, psz_type );
-            free( psz_variable );
         }
         else if( !strcmp( s, "vlc_var_set" ) )
         {
+            char *psz_object = SSPop( st );
             char *psz_variable = SSPop( st );
+            bool b_need_release;
 
-            if( p_sys->p_input != NULL )
+            vlc_object_t *p_object = GetVLCObject( p_intf, psz_object,
+                                                   &b_need_release );
+
+            if( p_object != NULL )
             {
-                vlc_bool_t b_error = VLC_FALSE;
+                bool b_error = false;
                 char *psz_value = NULL;
                 vlc_value_t val;
                 int i_type;
 
-                i_type = var_Type( p_sys->p_input, psz_variable );
+                i_type = var_Type( p_object, psz_variable );
 
                 switch( i_type & VLC_VAR_TYPE )
                 {
                 case VLC_VAR_BOOL:
                     val.b_bool = SSPopN( st, vars );
-                    msg_Dbg( p_intf, "requested input var change: %s->%d",
-                             psz_variable, val.b_bool );
+                    msg_Dbg( p_intf, "requested %s var change: %s->%d",
+                             psz_object, psz_variable, val.b_bool );
                     break;
                 case VLC_VAR_INTEGER:
                 case VLC_VAR_HOTKEY:
                     val.i_int = SSPopN( st, vars );
-                    msg_Dbg( p_intf, "requested input var change: %s->%d",
-                             psz_variable, val.i_int );
+                    msg_Dbg( p_intf, "requested %s var change: %s->%d",
+                             psz_object, psz_variable, val.i_int );
                     break;
                 case VLC_VAR_STRING:
                 case VLC_VAR_MODULE:
@@ -674,41 +638,51 @@ void  EvaluateRPN( intf_thread_t *p_intf, mvar_t  *vars,
                 case VLC_VAR_DIRECTORY:
                 case VLC_VAR_VARIABLE:
                     val.psz_string = psz_value = SSPop( st );
-                    msg_Dbg( p_intf, "requested input var change: %s->%s",
-                             psz_variable, psz_value );
+                    msg_Dbg( p_intf, "requested %s var change: %s->%s",
+                             psz_object, psz_variable, psz_value );
                     break;
                 case VLC_VAR_FLOAT:
                     psz_value = SSPop( st );
                     val.f_float = atof( psz_value );
-                    msg_Dbg( p_intf, "requested input var change: %s->%f",
-                             psz_variable, val.f_float );
+                    msg_Dbg( p_intf, "requested %s var change: %s->%f",
+                             psz_object, psz_variable, val.f_float );
                     break;
                 default:
-                    msg_Warn( p_intf, "invalid variable type %d (%s)",
-                              i_type & VLC_VAR_TYPE, psz_variable );
-                    b_error = VLC_TRUE;
+                    SSPopN( st, vars );
+                    msg_Warn( p_intf, "invalid %s variable type %d (%s)",
+                              psz_object, i_type & VLC_VAR_TYPE, psz_variable );
+                    b_error = true;
                 }
 
                 if( !b_error )
-                    var_Set( p_sys->p_input, psz_variable, val );
+                    var_Set( p_object, psz_variable, val );
                 if( psz_value != NULL )
                     free( psz_value );
             }
             else
-                msg_Warn( p_intf, "vlc_var_set called without an input" );
+                msg_Warn( p_intf, "vlc_var_set called without an object" );
             free( psz_variable );
+            free( psz_object );
+
+            if( b_need_release && p_object != NULL )
+                vlc_object_release( p_object );
         }
         else if( !strcmp( s, "vlc_var_get" ) )
         {
+            char *psz_object = SSPop( st );
             char *psz_variable = SSPop( st );
+            bool b_need_release;
+
+            vlc_object_t *p_object = GetVLCObject( p_intf, psz_object,
+                                                   &b_need_release );
 
-            if( p_sys->p_input != NULL )
+            if( p_object != NULL )
             {
                 vlc_value_t val;
                 int i_type;
 
-                i_type = var_Type( p_sys->p_input, psz_variable );
-                var_Get( p_sys->p_input, psz_variable, &val );
+                i_type = var_Type( p_object, psz_variable );
+                var_Get( p_object, psz_variable, &val );
 
                 switch( i_type & VLC_VAR_TYPE )
                 {
@@ -730,22 +704,43 @@ void  EvaluateRPN( intf_thread_t *p_intf, mvar_t  *vars,
                 case VLC_VAR_FLOAT:
                 {
                     char psz_value[20];
-                    snprintf( psz_value, sizeof(psz_value), "%f", val.f_float );
+                    lldiv_t value = lldiv( val.f_float * 1000000, 1000000 );
+                    snprintf( psz_value, sizeof(psz_value), "%lld.%06u",
+                                    value.quot, (unsigned int)value.rem );
                     SSPush( st, psz_value );
                     break;
                 }
                 default:
-                    msg_Warn( p_intf, "invalid variable type %d (%s)",
-                              i_type & VLC_VAR_TYPE, psz_variable );
+                    msg_Warn( p_intf, "invalid %s variable type %d (%s)",
+                              psz_object, i_type & VLC_VAR_TYPE, psz_variable );
                     SSPush( st, "" );
                 }
             }
             else
             {
-                msg_Warn( p_intf, "vlc_var_get called without an input" );
+                msg_Warn( p_intf, "vlc_var_get called without an object" );
                 SSPush( st, "" );
             }
             free( psz_variable );
+            free( psz_object );
+
+            if( b_need_release && p_object != NULL )
+                vlc_object_release( p_object );
+        }
+        else if( !strcmp( s, "vlc_object_exists" ) )
+        {
+            char *psz_object = SSPop( st );
+            bool b_need_release;
+
+            vlc_object_t *p_object = GetVLCObject( p_intf, psz_object,
+                                                   &b_need_release );
+            if( b_need_release && p_object != NULL )
+                vlc_object_release( p_object );
+
+            if( p_object != NULL )
+                SSPush( st, "1" );
+            else
+                SSPush( st, "0" );
         }
         else if( !strcmp( s, "vlc_config_set" ) )
         {
@@ -805,14 +800,17 @@ void  EvaluateRPN( intf_thread_t *p_intf, mvar_t  *vars,
             case VLC_VAR_FLOAT:
             {
                 char psz_string[20];
-                snprintf( psz_string, sizeof(psz_string), "%f",
-                          config_GetFloat( p_intf, psz_variable ) );
+                lldiv_t value = lldiv( config_GetFloat( p_intf, psz_variable )
+                                       * 1000000, 1000000 );
+                snprintf( psz_string, sizeof(psz_string), "%lld.%06u",
+                          value.quot, (unsigned int)value.rem );
                 SSPush( st, psz_string );
                 break;
             }
             default:
                 msg_Warn( p_intf, "vlc_config_get called on unknown var (%s)",
                           psz_variable );
+                SSPush( st, "" );
             }
             free( psz_variable );
         }
@@ -841,58 +839,62 @@ void  EvaluateRPN( intf_thread_t *p_intf, mvar_t  *vars,
         {
             char *psz_name = SSPop( st );
             char *mrl = SSPop( st );
-            char *tmp;
-            playlist_item_t *p_item;
-            int i_id;
+            input_item_t *p_input;
+            int i_ret;
 
-            tmp = E_(ToUTF8)( p_intf, psz_name );
-            free( psz_name );
-            psz_name = tmp;
-            tmp = E_(ToUTF8)( p_intf, mrl );
-            free( mrl );
-            mrl = tmp;
+            p_input = MRLParse( p_intf, mrl, psz_name );
 
-            if( !*psz_name )
+            char *psz_uri = input_item_GetURI( p_input );
+            if( !p_input || !psz_uri || !*psz_uri )
             {
-                p_item = E_(MRLParse)( p_intf, mrl, mrl );
-            }
-            else
-            {
-                p_item = E_(MRLParse)( p_intf, mrl, psz_name );
-            }
-
-            if( p_item == NULL || p_item->input.psz_uri == NULL ||
-                 !*p_item->input.psz_uri )
-            {
-                i_id = VLC_EGENERIC;
+                i_ret = VLC_EGENERIC;
                 msg_Dbg( p_intf, "invalid requested mrl: %s", mrl );
             }
             else
             {
-                i_id = playlist_AddItem( p_sys->p_playlist, p_item,
-                                         PLAYLIST_APPEND, PLAYLIST_END );
-                msg_Dbg( p_intf, "requested mrl add: %s", mrl );
+                i_ret = playlist_AddInput( p_sys->p_playlist, p_input,
+                                   PLAYLIST_APPEND, PLAYLIST_END, true,
+                                   pl_Unlocked );
+                vlc_gc_decref( p_input );
+                if( i_ret == VLC_SUCCESS )
+                    msg_Dbg( p_intf, "requested mrl add: %s", mrl );
+                else
+                    msg_Warn( p_intf, "adding mrl %s failed", mrl );
             }
-            SSPushN( st, i_id );
+            free( psz_uri );
+            SSPushN( st, i_ret );
 
             free( mrl );
             free( psz_name );
         }
         else if( !strcmp( s, "playlist_empty" ) )
         {
-            playlist_LockClear( p_sys->p_playlist );
+            playlist_Clear( p_sys->p_playlist, pl_Unlocked );
             msg_Dbg( p_intf, "requested playlist empty" );
         }
         else if( !strcmp( s, "playlist_delete" ) )
         {
             int i_id = SSPopN( st, vars );
-            playlist_LockDelete( p_sys->p_playlist, i_id );
-            msg_Dbg( p_intf, "requested playlist delete: %d", i_id );
+            playlist_item_t *p_item = playlist_ItemGetById( p_sys->p_playlist,
+                                                            i_id, pl_Unlocked );
+            if( p_item )
+            {
+                playlist_DeleteFromInput( p_sys->p_playlist,
+                                          p_item->p_input->i_id, pl_Unlocked );
+                msg_Dbg( p_intf, "requested playlist delete: %d", i_id );
+            }
+            else
+            {
+                msg_Dbg( p_intf, "couldn't find playlist item to delete (%d)",
+                         i_id );
+            }
         }
         else if( !strcmp( s, "playlist_move" ) )
         {
-            int i_newpos = SSPopN( st, vars );
-            int i_pos = SSPopN( st, vars );
+            /*int i_newpos =*/ SSPopN( st, vars );
+            /*int i_pos =*/ SSPopN( st, vars );
+            /* FIXME FIXME TODO TODO XXX XXX
+            do not release before fixing this
             if ( i_pos < i_newpos )
             {
                 playlist_Move( p_sys->p_playlist, i_pos, i_newpos + 1 );
@@ -903,6 +905,184 @@ void  EvaluateRPN( intf_thread_t *p_intf, mvar_t  *vars,
             }
             msg_Dbg( p_intf, "requested to move playlist item %d to %d",
                      i_pos, i_newpos);
+               FIXME FIXME TODO TODO XXX XXX */
+            msg_Err( p_intf, "moving using indexes is obsolete. We need to update this function" );
+        }
+        else if( !strcmp( s, "playlist_sort" ) )
+        {
+            int i_order = SSPopN( st, vars );
+            int i_sort = SSPopN( st, vars );
+            i_order = i_order % 2;
+            i_sort = i_sort % 9;
+            /* FIXME FIXME TODO TODO XXX XXX
+            do not release before fixing this
+            playlist_RecursiveNodeSort(  p_sys->p_playlist,
+                                         p_sys->p_playlist->p_general,
+                                         i_sort, i_order );
+            msg_Dbg( p_intf, "requested sort playlist by : %d in order : %d",
+                     i_sort, i_order );
+               FIXME FIXME TODO TODO XXX XXX */
+            msg_Err( p_intf, "this needs to be fixed to use the new playlist framework" );
+        }
+        else if( !strcmp( s, "services_discovery_add" ) )
+        {
+            char *psz_sd = SSPop( st );
+            playlist_ServicesDiscoveryAdd( p_sys->p_playlist, psz_sd );
+            free( psz_sd );
+        }
+        else if( !strcmp( s, "services_discovery_remove" ) )
+        {
+            char *psz_sd = SSPop( st );
+            playlist_ServicesDiscoveryRemove( p_sys->p_playlist, psz_sd );
+            free( psz_sd );
+        }
+        else if( !strcmp( s, "services_discovery_is_loaded" ) )
+        {
+            char *psz_sd = SSPop( st );
+            SSPushN( st,
+            playlist_IsServicesDiscoveryLoaded( p_sys->p_playlist, psz_sd ) );
+            free( psz_sd );
+        }
+        else if( !strcmp( s, "vlc_volume_set" ) )
+        {
+            char *psz_vol = SSPop( st );
+            int i_value;
+            audio_volume_t i_volume;
+            aout_VolumeGet( p_intf, &i_volume );
+            if( psz_vol[0] == '+' )
+            {
+                i_value = atoi( psz_vol );
+                if( (i_volume + i_value) > AOUT_VOLUME_MAX )
+                    aout_VolumeSet( p_intf, AOUT_VOLUME_MAX );
+                else
+                    aout_VolumeSet( p_intf, i_volume + i_value );
+            }
+            else if( psz_vol[0] == '-' )
+            {
+                i_value = atoi( psz_vol );
+                if( (i_volume + i_value) < AOUT_VOLUME_MIN )
+                    aout_VolumeSet( p_intf, AOUT_VOLUME_MIN );
+                else
+                    aout_VolumeSet( p_intf, i_volume + i_value );
+            }
+            else if( strstr( psz_vol, "%") != NULL )
+            {
+                i_value = atoi( psz_vol );
+                if( i_value < 0 ) i_value = 0;
+                if( i_value > 400 ) i_value = 400;
+                aout_VolumeSet( p_intf, (i_value * (AOUT_VOLUME_MAX - AOUT_VOLUME_MIN))/400+AOUT_VOLUME_MIN);
+            }
+            else
+            {
+                i_value = atoi( psz_vol );
+                if( i_value > AOUT_VOLUME_MAX ) i_value = AOUT_VOLUME_MAX;
+                if( i_value < AOUT_VOLUME_MIN ) i_value = AOUT_VOLUME_MIN;
+                aout_VolumeSet( p_intf, i_value );
+            }
+            aout_VolumeGet( p_intf, &i_volume );
+            free( psz_vol );
+        }
+        else if( !strcmp( s, "vlc_get_meta" ) )
+        {
+            char *psz_meta = SSPop( st );
+            char *psz_val = NULL;
+            if( p_sys->p_input && input_GetItem(p_sys->p_input) )
+            {
+#define p_item input_GetItem( p_sys->p_input )
+                if( !strcmp( psz_meta, "ARTIST" ) )
+                {
+                    psz_val = input_item_GetArtist( p_item );
+                }
+                else if( !strcmp( psz_meta, "TITLE" ) )
+                {
+                    psz_val = input_item_GetTitle( p_item );
+                    if( !psz_val )
+                        psz_val = input_item_GetName( p_item );
+                }
+                else if( !strcmp( psz_meta, "ALBUM" ) )
+                {
+                    psz_val = input_item_GetAlbum( p_item );
+                }
+                else if( !strcmp( psz_meta, "GENRE" ) )
+                {
+                    psz_val = input_item_GetGenre( p_item );
+                }
+#undef p_item
+            }
+            if( psz_val == NULL ) psz_val = strdup( "" );
+            SSPush( st, psz_val );
+            free( psz_meta );
+            free( psz_val );
+        }
+#ifdef ENABLE_VLM
+        else if( !strcmp( s, "vlm_command" ) || !strcmp( s, "vlm_cmd" ) )
+        {
+            char *psz_elt;
+            char *psz_cmd = strdup( "" );
+            char *psz_error;
+            vlm_message_t *vlm_answer;
+
+            /* make sure that we have a vlm object */
+            if( p_intf->p_sys->p_vlm == NULL )
+                p_intf->p_sys->p_vlm = vlm_New( p_intf );
+
+
+            /* vlm command uses the ';' delimiter
+             * (else we can't know when to stop) */
+            while( strcmp( psz_elt = SSPop( st ), "" )
+                   && strcmp( psz_elt, ";" ) )
+            {
+                char *psz_buf =
+                    (char *)malloc( strlen( psz_cmd ) + strlen( psz_elt ) + 2 );
+                sprintf( psz_buf, "%s %s", psz_cmd, psz_elt );
+                free( psz_cmd );
+                free( psz_elt );
+                psz_cmd = psz_buf;
+            }
+
+            msg_Dbg( p_intf, "executing vlm command: %s", psz_cmd );
+            vlm_ExecuteCommand( p_intf->p_sys->p_vlm, psz_cmd, &vlm_answer );
+
+            if( vlm_answer->psz_value == NULL )
+            {
+                psz_error = strdup( "" );
+            }
+            else
+            {
+                psz_error = malloc( strlen(vlm_answer->psz_name) +
+                                    strlen(vlm_answer->psz_value) +
+                                    strlen( " : ") + 1 );
+                sprintf( psz_error , "%s : %s" , vlm_answer->psz_name,
+                                                 vlm_answer->psz_value );
+            }
+
+            mvar_AppendNewVar( vars, "vlm_error", psz_error );
+            /* this is kind of a duplicate but we need to have the message
+             * without the command name for the "export" command */
+            mvar_AppendNewVar( vars, "vlm_value", vlm_answer->psz_value );
+            vlm_MessageDelete( vlm_answer );
+
+            free( psz_cmd );
+            free( psz_error );
+        }
+#endif /* ENABLE_VLM */
+        else if( !strcmp( s, "snapshot" ) )
+        {
+            if( p_sys->p_input )
+            {
+                vout_thread_t *p_vout;
+                p_vout = vlc_object_find( p_sys->p_input,
+                                          VLC_OBJECT_VOUT, FIND_CHILD );
+
+                if( p_vout )
+                {
+                    vout_Control( p_vout, VOUT_SNAPSHOT );
+                    vlc_object_release( p_vout );
+                    msg_Dbg( p_intf, "requested snapshot" );
+                }
+            }
+            break;
+
         }
         else
         {