Commit 29b3fcdf authored by Simon Latapie's avatar Simon Latapie

* vlm.c: a few bug fixes, cleaning, and maid vlm more http-intf

   compatible
 * http.c: a little bug fix ( append vlm command )
 * telnet.c: 4 spaces indentation on show command (much more readable)
 * share/http/vlm/edit.html, index.html, new.html: cleaning, esthetic
   modifications
parent 753e14b8
......@@ -1959,7 +1959,7 @@ static void MacroDo( httpd_file_sys_t *p_args,
/* no args */
"enabled", "disabled", "loop", "unloop",
/* args required */
"input", "output", "option", "append", "date", "period", "repeat",
"input", "output", "option", "date", "period", "repeat", "append",
};
vlm_message_t *vlm_answer;
char name[512];
......
......@@ -534,10 +534,10 @@ static char* MessageToString( vlm_message_t* message , int i_level )
else
{
psz_message = strdup( "" );
psz_message = realloc( psz_message , strlen( psz_message ) + strlen( message->psz_name ) + i_level + 1 );
psz_message = realloc( psz_message , strlen( psz_message ) + strlen( message->psz_name ) + i_level * 4 + 1 );
for( i = 0 ; i < i_level ; i++ )
{
strcat( psz_message , " " );
strcat( psz_message , " " );
}
strcat( psz_message , message->psz_name );
if( message->psz_value )
......
......@@ -23,21 +23,44 @@
<table>
<tr><td>Name : </td><td><vlc id="value" param1="'name' url_extract"/> </td> </tr>
<tr><td>Type: </td><td>Broadcast </td></tr>
<tr><td>Input: </td>
<td><input type="text" name="input" size="40" value=""/><br />
<vlc id="foreach" param1="in" param2="el.inputs" /><vlc id="value" param1="in" /><br/><vlc id="end" /></td></tr>
<tr><td valign="top">Inputs: </td>
<td>
<vlc id="foreach" param1="in" param2="el.inputs" /><vlc id="value" param1="in" /><br/><vlc id="end" />
<input type="text" name="input" size="40" value=""/><br />
</td></tr>
<tr><td>Output: </td><td><input type="text" name="output" size="40" value="<vlc id="value" param1="el.output" />"/></td></tr>
<tr><td>Option: </td>
<td><input type="text" name="option" size="40" value=""/><br />
<vlc id="foreach" param1="op" param2="el.options" /><vlc id="value" param1="op" /><br /><vlc id="end" /></td></tr>
<td>
<vlc id="foreach" param1="op" param2="el.options" /><vlc id="value" param1="op" /><br /><vlc id="end" />
<input type="text" name="option" size="40" value=""/><br />
</td></tr>
</table>
<input type="hidden" name="name" value="<vlc id="value" param1="'name' url_extract"/>" />
<input type="submit" name="control" value="vlm_setup"/>
</form>
<vlc id="else" />
<p> TODO schedule </p>
<vlc id="if" param1="'type' url_extract 'schedule' strcmp 0 =" />
<form method="get" action="/vlm/" />
<table>
<tr><td>Name : </td><td><vlc id="value" param1="'name' url_extract"/> </td> </tr>
<tr><td>Type: </td><td>Schedule </td></tr>
<tr><td valign="top">Commands: </td>
<td><vlc id="foreach" param1="in" param2="el.commands" /><vlc id="value" param1="in" /><br/><vlc id="end" />
<input type="text" name="append" size="40" value=""/><br/></td></tr>
<tr><td>Date: </td>
<td><input type="text" name="date" size="40" value="<vlc id="value" param1="el.date" />"/></td>
</tr>
<tr><td>Period: </td>
<td><input type="text" name="period" size="40" value="<vlc id="value" param1="el.period" />"/></td>
</tr>
<tr><td>Repeat: </td>
<td><input type="text" name="repeat" size="40" value="<vlc id="value" param1="el.repeat" />"/></td>
</table>
<input type="hidden" name="name" value="<vlc id="value" param1="'name' url_extract"/>" />
<input type="submit" name="control" value="vlm_setup"/>
</form>
<vlc id="end" />
<vlc id="end" />
<vlc id="end" />
<vlc id="end" />
......
......@@ -20,8 +20,8 @@
<form method="get" action="" />
<input type="test" name="file" size="40"/>
<input type="submit" name="control" value="vlm_load" />
<input type="submit" name="control" value="vlm_save" />
<button name="control" value="vlm_load">Load</button>
<button name="control" value="vlm_save">Save</button>
</form>
</div>
......@@ -37,55 +37,135 @@
<input type="test" name="name" size="40"/>
<input type="submit" name="type" value="schedule"/>
</form>
</div>
<div class="sectitle">VLM - Media</div>
<div class="section">
<table border="1">
<tr class="ligne2"> <td>Media</td><td>State</td><td>Control</td></tr>
<vlc id="foreach" param1="el" param2="vlm" />
<vlc id="if" param1="el.type value 'broadcast' strcmp 0 = " />
<tr class="ligne2">
<td>Media</td>
<td>State</td>
<td>Control</td>
</tr>
<vlc id="foreach" param1="el" param2="vlm" />
<vlc id="if" param1="el.type value 'broadcast' strcmp 0 = " />
<tr>
<td>
<table>
<tr>
<td><table><tr>
<td width="30%"><form method="get" action="" />
<input type="submit" name="control" value="vlm_del" />
<input type="hidden" name="name" value="<vlc id="value" param1="el.name" />" />
</form></td>
<td><a href="/vlm/edit.html?name=<vlc id="value" param1="el.name" />&type=broadcast"><vlc id="value" param1="el.name" /></a></td></table>
</td>
<td><vlc id="value" param1="el.state" /> </td>
<td>
<form method="get" action="" />
<input type="submit" name="control" value="vlm_play" />
<input type="submit" name="control" value="vlm_pause" />
<input type="submit" name="control" value="vlm_stop" />
<input type="hidden" name="name" value="<vlc id="value" param1="el.name" />" />
</form>
</td>
<td width="30%">
<form method="get" action="" />
<button name="control" value="vlm_del">del</button>
<input type="hidden" name="name" value="<vlc id="value" param1="el.name" />" />
</form>
</td>
<td><a href="/vlm/edit.html?name=<vlc id="value" param1="el.name" />&type=broadcast"><vlc id="value" param1="el.name" /></a></td>
</tr>
<vlc id="end" />
<vlc id="end" />
</table>
</td>
<td>
<vlc id="if" param1="el.enabled value 'yes' strcmp 0 = " />
<table>
<tr>
<td>
<vlc id="value" param1="el.state" />
</td>
<td align="right">
<form method="get" action="" />
<input type="hidden" name="name" value="<vlc id="value" param1="el.name" />" />
<input type="hidden" name="disabled" value="" />
<button name="control" value="vlm_setup">disable</button>
</form>
</td>
</tr>
</table>
<vlc id="else" />
<table>
<tr>
<td>disabled</td>
<td align="right">
<form method="get" action="" />
<input type="hidden" name="name" value="<vlc id="value" param1="el.name" />" />
<input type="hidden" name="enabled" value="" />
<button name="control" value="vlm_setup">enable</button>
</form>
</td>
</tr>
</table>
<vlc id="end" />
</td>
<td>
<vlc id="if" param1="el.enabled value 'yes' strcmp 0 = " />
<form method="get" action="" />
<input type="hidden" name="name" value="<vlc id="value" param1="el.name" />" />
<button name="control" value="vlm_stop">stop</button>
<button name="control" value="vlm_play">play</button>
<button name="control" value="vlm_pause">pause</button>
</form>
<vlc id="end" />
</td>
</tr>
<vlc id="end" />
<vlc id="end" />
</table>
</div>
<div class="sectitle">VLM - Schedule</div>
<div class="section">
<table border="1">
<tr class="ligne2"> <td>Schedule</td></tr>
<vlc id="foreach" param1="el" param2="vlm" />
<vlc id="if" param1="el.type value 'schedule' strcmp 0 =" />
<tr class="ligne2">
<td>Schedule</td>
<td>State</td>
</tr>
<vlc id="foreach" param1="el" param2="vlm" />
<vlc id="if" param1="el.type value 'schedule' strcmp 0 = " />
<tr>
<td>
<table>
<tr>
<td><a href="/vlm/edit.html?name=<vlc id="value" param1="el.name" />&type=schedule"><vlc id="value" param1="el.name" /></a> </td>
<td width="30%">
<form method="get" action="" />
<button name="control" value="vlm_del">del</button>
<input type="hidden" name="name" value="<vlc id="value" param1="el.name" />" />
</form>
</td>
<td><a href="/vlm/edit.html?name=<vlc id="value" param1="el.name" />&type=schedule"><vlc id="value" param1="el.name" /></a></td>
</tr>
<vlc id="end" />
<vlc id="end" />
</table>
</td>
<td>
<vlc id="if" param1="el.enabled value 'yes' strcmp 0 = " />
<table>
<tr>
<td>enabled</td>
<td align="right">
<form method="get" action="" />
<input type="hidden" name="name" value="<vlc id="value" param1="el.name" />" />
<input type="hidden" name="disabled" value="" />
<button name="control" value="vlm_setup">disable</button>
</form>
</td>
</tr>
</table>
<vlc id="else" />
<table>
<tr>
<td>disabled</td>
<td align="right">
<form method="get" action="" />
<input type="hidden" name="name" value="<vlc id="value" param1="el.name" />" />
<input type="hidden" name="enabled" value="" />
<button name="control" value="vlm_setup">enable</button>
</form>
</td>
</tr>
</table>
<vlc id="end" />
</td>
</tr>
<vlc id="end" />
<vlc id="end" />
</table>
</div>
<hr/>
......
......@@ -19,22 +19,36 @@
<form method="get" action="/vlm/" />
<table>
<tr><td>Name : <vlc id="value" param1="'name' url_extract"/> </td> </tr>
<tr><td>Type: Broadcast </td></tr>
<tr><td>Type: Schedule </td></tr>
<tr><td>Input: <input type="text" name="input" size="40" value=""/></td></tr>
<tr><td>Output: <input type="text" name="output" size="40" value=""/></td></tr>
<tr><td>Option: <input type="text" name="option" size="40" value=""/></td></tr>
</table>
<input type="hidden" name="enabled" value=""/>
<input type="hidden" name="disabled" value=""/>
<input type="hidden" name="type" value="broadcast"/>
<input type="hidden" name="name" value="<vlc id="value" param1="'name' url_extract"/>" />
<input type="submit" name="control" value="vlm_new"/>
</form>
<vlc id="else" />
<p> TODO schedule </p>
<vlc id="if" param1="'type' url_extract 'schedule' strcmp 0 =" />
<form method="get" action="/vlm/" />
<table>
<tr><td>Name : <vlc id="value" param1="'name' url_extract"/> </td> </tr>
<tr><td>Type: Schedule </td></tr>
<tr><td>Command: <input type="text" name="append" size="40" value=""/></td></tr>
<tr><td>Date: <input type="text" name="date" size="40" value=""/></td></tr>
<tr><td>Period: <input type="text" name="period" size="40" value=""/></td></tr>
<tr><td>Repeat: <input type="text" name="repeat" size="40" value=""/></td></tr>
</table>
<input type="hidden" name="disabled" value=""/>
<input type="hidden" name="type" value="schedule"/>
<input type="hidden" name="name" value="<vlc id="value" param1="'name' url_extract"/>" />
<input type="submit" name="control" value="vlm_new"/>
</form>
<vlc id="end" />
<vlc id="end" />
</div>
</div>
<hr/>
<p> <vlc id="value" param1="copyright" /> </p>
</body>
......
......@@ -546,6 +546,8 @@ static int ExecuteCommand( vlm_t *vlm, char *command , vlm_message_t **p_message
{
vlm_ScheduleDelete( vlm, vlm->schedule[i], NULL );
}
i_return = 0;
goto end_seq;
}
else
{
......@@ -1244,6 +1246,7 @@ static vlm_message_t *vlm_Show( vlm_t *vlm, vlm_media_t *media, vlm_schedule_t *
vlm_message_t *message;
vlm_message_t *message_schedule;
vlm_message_t *message_child;
char buffer[100];
message = vlm_MessageNew( "show" , NULL );
message_schedule = vlm_MessageAdd( message , vlm_MessageNew( schedule->psz_name , NULL ) );
......@@ -1261,6 +1264,22 @@ static vlm_message_t *vlm_Show( vlm_t *vlm, vlm_media_t *media, vlm_schedule_t *
if( schedule->i_date != 0 )
{
struct tm date;
time_t i_time = (time_t) ( schedule->i_date / 1000000 );
char *psz_date = malloc( strlen( "//-::" ) + 14 );
#ifdef HAVE_LOCALTIME_R
localtime_r( &i_time, &date);
#else
struct tm *p_date = localtime( &i_time );
date = *p_date;
#endif
sprintf( psz_date, "%d/%d/%d-%d:%d:%d",
date.tm_year + 1900, date.tm_mon + 1, date.tm_mday,
date.tm_hour, date.tm_min, date.tm_sec );
/*
time_t i_time = schedule->i_date / (int64_t)1000000;
#ifdef HAVE_CTIME_R
......@@ -1269,7 +1288,9 @@ static vlm_message_t *vlm_Show( vlm_t *vlm, vlm_media_t *media, vlm_schedule_t *
#else
char *psz_date = ctime( &i_time );
#endif
*/
vlm_MessageAdd( message_schedule , vlm_MessageNew( "date" , psz_date ) );
free( psz_date );
}
else
{
......@@ -1278,7 +1299,6 @@ static vlm_message_t *vlm_Show( vlm_t *vlm, vlm_media_t *media, vlm_schedule_t *
if( schedule->i_period != 0 )
{
char buffer[100];
time_t i_time = (time_t) ( schedule->i_period / 1000000 );
struct tm date;
......@@ -1295,22 +1315,19 @@ static vlm_message_t *vlm_Show( vlm_t *vlm, vlm_media_t *media, vlm_schedule_t *
i_time = i_time / 12;
date.tm_year = (int)i_time;
sprintf( buffer, "%d years %d months %d days %d hours %d minutes %d seconds", date.tm_year ,
date.tm_mon,
date.tm_mday,
date.tm_hour,
date.tm_min,
date.tm_sec);
sprintf( buffer, "%d/%d/%d-%d:%d:%d", date.tm_year, date.tm_mon,
date.tm_mday, date.tm_hour, date.tm_min, date.tm_sec);
vlm_MessageAdd( message_schedule , vlm_MessageNew( "period" , buffer ) );
if( schedule->i_repeat >= 0 )
{
sprintf( buffer, "%d" , schedule->i_repeat );
vlm_MessageAdd( message_schedule , vlm_MessageNew( "repeat" , buffer ) );
}
}
else
{
vlm_MessageAdd( message_schedule , vlm_MessageNew( "period" , "0" ) );
}
sprintf( buffer, "%d" , schedule->i_repeat );
vlm_MessageAdd( message_schedule , vlm_MessageNew( "repeat" , buffer ) );
message_child = vlm_MessageAdd( message_schedule , vlm_MessageNew( "commands" , NULL ) );
for( i=0 ; i < (schedule->i_command) ; i++ )
......@@ -1464,30 +1481,7 @@ static vlm_message_t *vlm_Help( vlm_t *vlm, char *psz_filter )
if( psz_filter == NULL )
{
char *help = malloc( strlen( "Commands Syntax:" ) +
strlen( "\n new (name) vod|broadcast|schedule [properties]" ) +
strlen( "\n setup (name) (properties)" ) +
strlen( "\n show [(name)|media|schedule]" ) +
strlen( "\n del (name)|all|media|schedule" ) +
strlen( "\n control (name) (command)" ) +
strlen( "\n save (config_file)" ) +
strlen( "\n load (config_file)" ) +
strlen( "\nMedia Proprieties Syntax:" ) +
strlen( "\n input (input_name)" ) +
strlen( "\n output (output_name)" ) +
strlen( "\n option (option_name)[=value]" ) +
strlen( "\n enabled|disabled" ) +
strlen( "\n loop|unloop (broadcast only)" ) +
strlen( "\nSchedule Proprieties Syntax:" ) +
strlen( "\n enabled|disabled" ) +
strlen( "\n append (command_until_rest_of_the_line)" ) +
strlen( "\n date (year)/(month)/(day)-(hour):(minutes):(seconds)|now" ) +
strlen( "\n period (years_aka_12_months)/(months_aka_30_days)/(days)-(hours):(minutes):(seconds)" ) +
strlen( "\n repeat (number_of_repetitions)" ) +
strlen( "\nControl Commands Syntax:" ) +
strlen( "\n play\n pause\n stop\n seek (percentage)\n" ) + 1 );
sprintf( help,
char *help= strdup(
"Commands Syntax:"
"\n new (name) vod|broadcast|schedule [properties]"
"\n setup (name) (properties)"
......@@ -1794,7 +1788,7 @@ static vlm_schedule_t *vlm_ScheduleNew( vlm_t *vlm , char *psz_name )
sched->command = NULL;
sched->i_date = 0;
sched->i_period = 0;
sched->i_repeat = 0;
sched->i_repeat = -1;
TAB_APPEND( vlm->i_schedule , vlm->schedule , sched );
......@@ -2085,25 +2079,25 @@ static int Manage( vlc_object_t* p_object )
{
mtime_t i_real_date = vlm->schedule[i]->i_date;
if( vlm->schedule[i]->i_date == 0 ) // now !
{
vlm->schedule[i]->i_date = (i_time / 1000000) * 1000000 ;
i_real_date = i_time;
}
else if( vlm->schedule[i]->i_period != 0 )
if( vlm->schedule[i]->b_enabled == VLC_TRUE )
{
int j = 0;
while( vlm->schedule[i]->i_date + j * vlm->schedule[i]->i_period <= i_lastcheck &&
( vlm->schedule[i]->i_repeat > j || vlm->schedule[i]->i_repeat == -1 ) )
if( vlm->schedule[i]->i_date == 0 ) // now !
{
j++;
vlm->schedule[i]->i_date = (i_time / 1000000) * 1000000 ;
i_real_date = i_time;
}
else if( vlm->schedule[i]->i_period != 0 )
{
int j = 0;
while( vlm->schedule[i]->i_date + j * vlm->schedule[i]->i_period <= i_lastcheck &&
( vlm->schedule[i]->i_repeat > j || vlm->schedule[i]->i_repeat == -1 ) )
{
j++;
}
i_real_date = vlm->schedule[i]->i_date + j * vlm->schedule[i]->i_period;
}
i_real_date = vlm->schedule[i]->i_date + j * vlm->schedule[i]->i_period;
}
if( vlm->schedule[i]->b_enabled == VLC_TRUE )
{
if( i_real_date <= i_time && i_real_date > i_lastcheck )
{
for( j = 0 ; j < vlm->schedule[i]->i_command ; j++ )
......
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