Commit 2a212b5c authored by Gildas Bazin's avatar Gildas Bazin

* modules/control/http.c: delete command supports a list of items.
* doc/intf-http.txt: update for delete command.
* share/http/index.html: added the possibility to delete playlist items.
parent 8a4ad005
...@@ -207,7 +207,7 @@ Url commands are : ...@@ -207,7 +207,7 @@ Url commands are :
| next | | Go to the next playlist element | next | | Go to the next playlist element
| previous | | Got to the previous playlist element | previous | | Got to the previous playlist element
| add | mrl(string) | Add a mrl to the playlist | 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 | empty | | Empty the playlist
| close | id(hexa) | Close a specific connection | close | id(hexa) | Close a specific connection
| shutdown | | Quit vlc | shutdown | | Quit vlc
...@@ -298,7 +298,7 @@ variable will be displayed (instead of it name). ...@@ -298,7 +298,7 @@ variable will be displayed (instead of it name).
Fields: Fields:
- current : 1 if currently selected else 0 - current : 1 if currently selected else 0
- index : the index value (to be used for example for the - index : the index value (to be used for example for the
"del" control command. "delete" control command.
- name - name
- "informations" : Create informations for the current playing - "informations" : Create informations for the current playing
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* http.c : http mini-server ;) * http.c : http mini-server ;)
***************************************************************************** *****************************************************************************
* Copyright (C) 2001 VideoLAN * 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> * Authors: Gildas Bazin <gbazin@netcourrier.com>
* Laurent Aimar <fenrir@via.ecp.fr> * Laurent Aimar <fenrir@via.ecp.fr>
...@@ -117,7 +117,7 @@ static int http_get( httpd_file_callback_args_t *p_args, ...@@ -117,7 +117,7 @@ static int http_get( httpd_file_callback_args_t *p_args,
uint8_t *p_request, int i_request, uint8_t *p_request, int i_request,
uint8_t **pp_data, int *pi_data ); uint8_t **pp_data, int *pi_data );
static void uri_extract_value( char *psz_uri, char *psz_name, static char *uri_extract_value( char *psz_uri, char *psz_name,
char *psz_value, int i_value_max ); char *psz_value, int i_value_max );
static void uri_decode_url_encoded( char *psz ); static void uri_decode_url_encoded( char *psz );
...@@ -1356,7 +1356,7 @@ StrToMacroTypeTab [] = ...@@ -1356,7 +1356,7 @@ StrToMacroTypeTab [] =
/* playlist management */ /* playlist management */
{ "add", MVLC_ADD }, { "add", MVLC_ADD },
{ "del", MVLC_DEL }, { "delete", MVLC_DEL },
{ "empty", MVLC_EMPTY }, { "empty", MVLC_EMPTY },
/* admin control */ /* admin control */
...@@ -1492,14 +1492,43 @@ static void MacroDo( httpd_file_callback_args_t *p_args, ...@@ -1492,14 +1492,43 @@ static void MacroDo( httpd_file_callback_args_t *p_args,
} }
case MVLC_DEL: case MVLC_DEL:
{ {
int i_item; int i_item, *p_items = NULL, i_nb_items = 0;
char item[512]; char item[512], *p_parser = p_request;
/* Get the list of items to delete */
while( (p_parser =
uri_extract_value( p_parser, "item", item, 512 )) )
{
if( !*item ) continue;
uri_extract_value( p_request, "item", item, 512 );
i_item = atoi( item ); i_item = atoi( item );
p_items = realloc( p_items, i_nb_items+1 );
p_items[i_nb_items] = i_item;
i_nb_items++;
}
playlist_Delete( p_sys->p_playlist, i_item ); /* The items need to be deleted from in reversed order */
msg_Dbg( p_intf, "requested playlist del: %d", i_item ); 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; break;
} }
case MVLC_EMPTY: case MVLC_EMPTY:
...@@ -1950,7 +1979,7 @@ static int http_get( httpd_file_callback_args_t *p_args, ...@@ -1950,7 +1979,7 @@ static int http_get( httpd_file_callback_args_t *p_args,
/**************************************************************************** /****************************************************************************
* uri parser * uri parser
****************************************************************************/ ****************************************************************************/
static void uri_extract_value( char *psz_uri, char *psz_name, static char *uri_extract_value( char *psz_uri, char *psz_name,
char *psz_value, int i_value_max ) char *psz_value, int i_value_max )
{ {
char *p; char *p;
...@@ -1990,11 +2019,14 @@ static void uri_extract_value( char *psz_uri, char *psz_name, ...@@ -1990,11 +2019,14 @@ static void uri_extract_value( char *psz_uri, char *psz_name,
{ {
strncpy( psz_value, "", i_value_max ); strncpy( psz_value, "", i_value_max );
} }
p += i_len;
} }
else else
{ {
strncpy( psz_value, "", i_value_max ); strncpy( psz_value, "", i_value_max );
} }
return p;
} }
static void uri_decode_url_encoded( char *psz ) static void uri_decode_url_encoded( char *psz )
...@@ -2321,6 +2353,3 @@ static void EvaluateRPN( mvar_t *vars, rpn_stack_t *st, char *exp ) ...@@ -2321,6 +2353,3 @@ static void EvaluateRPN( mvar_t *vars, rpn_stack_t *st, char *exp )
} }
} }
} }
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
<meta http-equiv="refresh" content="0;URL=/" /> <meta http-equiv="refresh" content="0;URL=/" />
<vlc id="end" /> <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" /> <vlc id="set" param1="sout" param2="string" />
</head> </head>
<body> <body>
...@@ -51,10 +51,12 @@ ...@@ -51,10 +51,12 @@
<div class="sectitle">VLC Playlist</div> <div class="sectitle">VLC Playlist</div>
<div class="section"> <div class="section">
<form method="get" action="">
<table> <table>
<vlc id="foreach" param1="pl" param2="playlist" /> <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" />"> <tr class="<vlc id="if" param1="2 pl.index % 0 =" />ligne1<vlc id="else" />ligne2<vlc id="end" />">
<td> <td>
<input type=checkbox name="item" value="<vlc id="value" param1="pl.index" />">
<vlc id="if" param1="pl.current" /> <vlc id="if" param1="pl.current" />
<b> <b>
<vlc id="end" /> <vlc id="end" />
...@@ -64,6 +66,8 @@ ...@@ -64,6 +66,8 @@
</td></tr> </td></tr>
<vlc id="end" /> <vlc id="end" />
</table> </table>
<td><input type="submit" name="control" value="delete" /></td>
</form>
</div> </div>
<hr/> <hr/>
<p> <vlc id="value" param1="copyright" /> </p> <p> <vlc id="value" param1="copyright" /> </p>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment