]> git.sesse.net Git - vlc/commitdiff
* modules/control/http.c: delete command supports a list of items.
authorGildas Bazin <gbazin@videolan.org>
Sun, 2 Nov 2003 19:26:30 +0000 (19:26 +0000)
committerGildas Bazin <gbazin@videolan.org>
Sun, 2 Nov 2003 19:26:30 +0000 (19:26 +0000)
* doc/intf-http.txt: update for delete command.
* share/http/index.html: added the possibility to delete playlist items.

doc/intf-http.txt
modules/control/http.c
share/http/index.html

index 4d25ed397ddc9cb1cc4ed85973b1401ec558cd01..81b43286773a12254c384b30407512d3176870e4 100644 (file)
@@ -207,7 +207,7 @@ Url commands are :
   | next      |              | Go to the next playlist element
   | previous  |              | Got to the previous playlist element
   | add       | mrl(string)  | Add a mrl to the playlist
-  | del       | item(integer)| Del an element of the playlist
+  | delete    | item(integer)| Deletes an (list of) element of the playlist
   | empty     |              | Empty the playlist
   | close     | id(hexa)     | Close a specific connection
   | shutdown  |              | Quit vlc
@@ -298,7 +298,7 @@ variable will be displayed (instead of it name).
           Fields:
             - current : 1 if currently selected else 0
             - index   : the index value (to be used for example for the 
-                        "del" control command.
+                        "delete" control command.
             - name
 
         - "informations"  : Create informations for  the current playing
index 2881735dd808beeaa18c74788d7db4b0958cb159..850f9fd5a8028947eae4c4a51efd71b45fea9495 100644 (file)
@@ -2,7 +2,7 @@
  * http.c :  http mini-server ;)
  *****************************************************************************
  * Copyright (C) 2001 VideoLAN
- * $Id: http.c,v 1.24 2003/10/21 01:05:32 titer Exp $
+ * $Id: http.c,v 1.25 2003/11/02 19:26:30 gbazin Exp $
  *
  * Authors: Gildas Bazin <gbazin@netcourrier.com>
  *          Laurent Aimar <fenrir@via.ecp.fr>
@@ -117,8 +117,8 @@ static int  http_get( httpd_file_callback_args_t *p_args,
                       uint8_t *p_request, int i_request,
                       uint8_t **pp_data, int *pi_data );
 
-static void uri_extract_value( char *psz_uri, char *psz_name,
-                               char *psz_value, int i_value_max );
+static char *uri_extract_value( char *psz_uri, char *psz_name,
+                                char *psz_value, int i_value_max );
 static void uri_decode_url_encoded( char *psz );
 
 /*****************************************************************************
@@ -1356,7 +1356,7 @@ StrToMacroTypeTab [] =
 
         /* playlist management */
         { "add",            MVLC_ADD },
-        { "del",            MVLC_DEL },
+        { "delete",         MVLC_DEL },
         { "empty",          MVLC_EMPTY },
 
         /* admin control */
@@ -1492,14 +1492,43 @@ static void MacroDo( httpd_file_callback_args_t *p_args,
                 }
                 case MVLC_DEL:
                 {
-                    int i_item;
-                    char item[512];
+                    int i_item, *p_items = NULL, i_nb_items = 0;
+                    char item[512], *p_parser = p_request;
 
-                    uri_extract_value( p_request, "item", item, 512 );
-                    i_item = atoi( item );
+                    /* Get the list of items to delete */
+                    while( (p_parser =
+                            uri_extract_value( p_parser, "item", item, 512 )) )
+                    {
+                        if( !*item ) continue;
 
-                    playlist_Delete( p_sys->p_playlist, i_item );
-                    msg_Dbg( p_intf, "requested playlist del: %d", i_item );
+                        i_item = atoi( item );
+                        p_items = realloc( p_items, i_nb_items+1 );
+                        p_items[i_nb_items] = i_item;
+                        i_nb_items++;
+                    }
+
+                    /* The items need to be deleted from in reversed order */
+                    if( i_nb_items )
+                    {
+                        int i;
+                        for( i = 0; i < i_nb_items; i++ )
+                        {
+                            int j, i_index = 0;
+                            for( j = 0; j < i_nb_items; j++ )
+                            {
+                                if( p_items[j] > p_items[i_index] )
+                                    i_index = j;
+                            }
+
+                            playlist_Delete( p_sys->p_playlist,
+                                             p_items[i_index] );
+                            msg_Dbg( p_intf, "requested playlist delete: %d",
+                                     p_items[i_index] );
+                            p_items[i_index] = -1;
+                        }
+                    }
+
+                    if( p_items ) free( p_items );
                     break;
                 }
                 case MVLC_EMPTY:
@@ -1950,8 +1979,8 @@ static int  http_get( httpd_file_callback_args_t *p_args,
 /****************************************************************************
  * uri parser
  ****************************************************************************/
-static void uri_extract_value( char *psz_uri, char *psz_name,
-                               char *psz_value, int i_value_max )
+static char *uri_extract_value( char *psz_uri, char *psz_name,
+                                char *psz_value, int i_value_max )
 {
     char *p;
 
@@ -1990,11 +2019,14 @@ static void uri_extract_value( char *psz_uri, char *psz_name,
         {
             strncpy( psz_value, "", i_value_max );
         }
+        p += i_len;
     }
     else
     {
         strncpy( psz_value, "", i_value_max );
     }
+
+    return p;
 }
 
 static void uri_decode_url_encoded( char *psz )
@@ -2321,6 +2353,3 @@ static void  EvaluateRPN( mvar_t  *vars, rpn_stack_t *st, char *exp )
         }
     }
 }
-
-
-
index 313b00e9ee054d4dfb9256ad289705389494c245..8d5be941788cf62cdc3a7da3241ef6aceb740e98 100644 (file)
@@ -10,7 +10,7 @@
         <meta http-equiv="refresh" content="0;URL=/" />
     <vlc id="end" />
 
-    <vlc id="control" param1="stop,pause,previous,next,add,sout,play,del,empty" />
+    <vlc id="control" param1="stop,pause,previous,next,add,sout,play,delete,empty" />
     <vlc id="set" param1="sout" param2="string" />
  </head>
  <body>
   
     <div class="sectitle">VLC Playlist</div>
     <div class="section"> 
-    <table>
+    <form method="get" action="">
+     <table>
         <vlc id="foreach" param1="pl" param2="playlist" />
           <tr class="<vlc id="if" param1="2 pl.index % 0 =" />ligne1<vlc id="else" />ligne2<vlc id="end" />">
           <td>
+           <input type=checkbox name="item" value="<vlc id="value" param1="pl.index" />">
            <vlc id="if" param1="pl.current" />
                 <b>
             <vlc id="end" />
@@ -63,7 +65,9 @@
             <vlc id="end" />
           </td></tr>
         <vlc id="end" />
-    </table>
+     </table>
+     <td><input type="submit" name="control" value="delete" /></td>
+    </form>
     </div>
     <hr/>
     <p> <vlc id="value" param1="copyright" /> </p>