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, ...@@ -1959,7 +1959,7 @@ static void MacroDo( httpd_file_sys_t *p_args,
/* no args */ /* no args */
"enabled", "disabled", "loop", "unloop", "enabled", "disabled", "loop", "unloop",
/* args required */ /* args required */
"input", "output", "option", "append", "date", "period", "repeat", "input", "output", "option", "date", "period", "repeat", "append",
}; };
vlm_message_t *vlm_answer; vlm_message_t *vlm_answer;
char name[512]; char name[512];
......
...@@ -534,7 +534,7 @@ static char* MessageToString( vlm_message_t* message , int i_level ) ...@@ -534,7 +534,7 @@ static char* MessageToString( vlm_message_t* message , int i_level )
else else
{ {
psz_message = strdup( "" ); 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++ ) for( i = 0 ; i < i_level ; i++ )
{ {
strcat( psz_message , " " ); strcat( psz_message , " " );
......
...@@ -23,21 +23,44 @@ ...@@ -23,21 +23,44 @@
<table> <table>
<tr><td>Name : </td><td><vlc id="value" param1="'name' url_extract"/> </td> </tr> <tr><td>Name : </td><td><vlc id="value" param1="'name' url_extract"/> </td> </tr>
<tr><td>Type: </td><td>Broadcast </td></tr> <tr><td>Type: </td><td>Broadcast </td></tr>
<tr><td>Input: </td> <tr><td valign="top">Inputs: </td>
<td><input type="text" name="input" size="40" value=""/><br /> <td>
<vlc id="foreach" param1="in" param2="el.inputs" /><vlc id="value" param1="in" /><br/><vlc id="end" /></td></tr> <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>Output: </td><td><input type="text" name="output" size="40" value="<vlc id="value" param1="el.output" />"/></td></tr>
<tr><td>Option: </td> <tr><td>Option: </td>
<td><input type="text" name="option" size="40" value=""/><br /> <td>
<vlc id="foreach" param1="op" param2="el.options" /><vlc id="value" param1="op" /><br /><vlc id="end" /></td></tr> <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> </table>
<input type="hidden" name="name" value="<vlc id="value" param1="'name' url_extract"/>" /> <input type="hidden" name="name" value="<vlc id="value" param1="'name' url_extract"/>" />
<input type="submit" name="control" value="vlm_setup"/> <input type="submit" name="control" value="vlm_setup"/>
</form> </form>
<vlc id="else" /> <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" /> <vlc id="end" />
<vlc id="end" /> <vlc id="end" />
......
...@@ -20,8 +20,8 @@ ...@@ -20,8 +20,8 @@
<form method="get" action="" /> <form method="get" action="" />
<input type="test" name="file" size="40"/> <input type="test" name="file" size="40"/>
<input type="submit" name="control" value="vlm_load" /> <button name="control" value="vlm_load">Load</button>
<input type="submit" name="control" value="vlm_save" /> <button name="control" value="vlm_save">Save</button>
</form> </form>
</div> </div>
...@@ -37,55 +37,135 @@ ...@@ -37,55 +37,135 @@
<input type="test" name="name" size="40"/> <input type="test" name="name" size="40"/>
<input type="submit" name="type" value="schedule"/> <input type="submit" name="type" value="schedule"/>
</form> </form>
</div> </div>
<div class="sectitle">VLM - Media</div> <div class="sectitle">VLM - Media</div>
<div class="section"> <div class="section">
<table border="1"> <table border="1">
<tr class="ligne2"> <td>Media</td><td>State</td><td>Control</td></tr> <tr class="ligne2">
<vlc id="foreach" param1="el" param2="vlm" /> <td>Media</td>
<vlc id="if" param1="el.type value 'broadcast' strcmp 0 = " /> <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> <tr>
<td><table><tr> <td width="30%">
<td width="30%"><form method="get" action="" /> <form method="get" action="" />
<input type="submit" name="control" value="vlm_del" /> <button name="control" value="vlm_del">del</button>
<input type="hidden" name="name" value="<vlc id="value" param1="el.name" />" /> <input type="hidden" name="name" value="<vlc id="value" param1="el.name" />" />
</form></td> </form>
<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><a href="/vlm/edit.html?name=<vlc id="value" param1="el.name" />&type=broadcast"><vlc id="value" param1="el.name" /></a></td>
</tr>
</table>
</td> </td>
<td><vlc id="value" param1="el.state" /> </td>
<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="" /> <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" />" /> <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> </form>
</td> </td>
</tr> </tr>
<vlc id="end" />
<vlc id="end" />
</table> </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>
<div class="sectitle">VLM - Schedule</div> <div class="sectitle">VLM - Schedule</div>
<div class="section"> <div class="section">
<table border="1"> <table border="1">
<tr class="ligne2"> <td>Schedule</td></tr> <tr class="ligne2">
<vlc id="foreach" param1="el" param2="vlm" /> <td>Schedule</td>
<vlc id="if" param1="el.type value 'schedule' strcmp 0 =" /> <td>State</td>
</tr>
<vlc id="foreach" param1="el" param2="vlm" />
<vlc id="if" param1="el.type value 'schedule' strcmp 0 = " />
<tr> <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>
<table>
<tr>
<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> </tr>
<vlc id="end" />
<vlc id="end" />
</table> </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> </div>
<hr/> <hr/>
......
...@@ -19,22 +19,36 @@ ...@@ -19,22 +19,36 @@
<form method="get" action="/vlm/" /> <form method="get" action="/vlm/" />
<table> <table>
<tr><td>Name : <vlc id="value" param1="'name' url_extract"/> </td> </tr> <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>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>Output: <input type="text" name="output" size="40" value=""/></td></tr>
<tr><td>Option: <input type="text" name="option" size="40" value=""/></td></tr> <tr><td>Option: <input type="text" name="option" size="40" value=""/></td></tr>
</table> </table>
<input type="hidden" name="enabled" value=""/> <input type="hidden" name="disabled" value=""/>
<input type="hidden" name="type" value="broadcast"/> <input type="hidden" name="type" value="broadcast"/>
<input type="hidden" name="name" value="<vlc id="value" param1="'name' url_extract"/>" /> <input type="hidden" name="name" value="<vlc id="value" param1="'name' url_extract"/>" />
<input type="submit" name="control" value="vlm_new"/> <input type="submit" name="control" value="vlm_new"/>
</form> </form>
<vlc id="else" /> <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" /> <vlc id="end" />
</div> </div>
<hr/> <hr/>
<p> <vlc id="value" param1="copyright" /> </p> <p> <vlc id="value" param1="copyright" /> </p>
</body> </body>
......
...@@ -546,6 +546,8 @@ static int ExecuteCommand( vlm_t *vlm, char *command , vlm_message_t **p_message ...@@ -546,6 +546,8 @@ static int ExecuteCommand( vlm_t *vlm, char *command , vlm_message_t **p_message
{ {
vlm_ScheduleDelete( vlm, vlm->schedule[i], NULL ); vlm_ScheduleDelete( vlm, vlm->schedule[i], NULL );
} }
i_return = 0;
goto end_seq;
} }
else else
{ {
...@@ -1244,6 +1246,7 @@ static vlm_message_t *vlm_Show( vlm_t *vlm, vlm_media_t *media, vlm_schedule_t * ...@@ -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;
vlm_message_t *message_schedule; vlm_message_t *message_schedule;
vlm_message_t *message_child; vlm_message_t *message_child;
char buffer[100];
message = vlm_MessageNew( "show" , NULL ); message = vlm_MessageNew( "show" , NULL );
message_schedule = vlm_MessageAdd( message , vlm_MessageNew( schedule->psz_name , 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 * ...@@ -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 ) 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; time_t i_time = schedule->i_date / (int64_t)1000000;
#ifdef HAVE_CTIME_R #ifdef HAVE_CTIME_R
...@@ -1269,7 +1288,9 @@ static vlm_message_t *vlm_Show( vlm_t *vlm, vlm_media_t *media, vlm_schedule_t * ...@@ -1269,7 +1288,9 @@ static vlm_message_t *vlm_Show( vlm_t *vlm, vlm_media_t *media, vlm_schedule_t *
#else #else
char *psz_date = ctime( &i_time ); char *psz_date = ctime( &i_time );
#endif #endif
*/
vlm_MessageAdd( message_schedule , vlm_MessageNew( "date" , psz_date ) ); vlm_MessageAdd( message_schedule , vlm_MessageNew( "date" , psz_date ) );
free( psz_date );
} }
else else
{ {
...@@ -1278,7 +1299,6 @@ static vlm_message_t *vlm_Show( vlm_t *vlm, vlm_media_t *media, vlm_schedule_t * ...@@ -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 ) if( schedule->i_period != 0 )
{ {
char buffer[100];
time_t i_time = (time_t) ( schedule->i_period / 1000000 ); time_t i_time = (time_t) ( schedule->i_period / 1000000 );
struct tm date; struct tm date;
...@@ -1295,21 +1315,18 @@ static vlm_message_t *vlm_Show( vlm_t *vlm, vlm_media_t *media, vlm_schedule_t * ...@@ -1295,21 +1315,18 @@ static vlm_message_t *vlm_Show( vlm_t *vlm, vlm_media_t *media, vlm_schedule_t *
i_time = i_time / 12; i_time = i_time / 12;
date.tm_year = (int)i_time; date.tm_year = (int)i_time;
sprintf( buffer, "%d years %d months %d days %d hours %d minutes %d seconds", date.tm_year , sprintf( buffer, "%d/%d/%d-%d:%d:%d", date.tm_year, date.tm_mon,
date.tm_mon, date.tm_mday, date.tm_hour, date.tm_min, date.tm_sec);
date.tm_mday,
date.tm_hour,
date.tm_min,
date.tm_sec);
vlm_MessageAdd( message_schedule , vlm_MessageNew( "period" , buffer ) ); vlm_MessageAdd( message_schedule , vlm_MessageNew( "period" , buffer ) );
}
if( schedule->i_repeat >= 0 ) else
{ {
vlm_MessageAdd( message_schedule , vlm_MessageNew( "period" , "0" ) );
}
sprintf( buffer, "%d" , schedule->i_repeat ); sprintf( buffer, "%d" , schedule->i_repeat );
vlm_MessageAdd( message_schedule , vlm_MessageNew( "repeat" , buffer ) ); vlm_MessageAdd( message_schedule , vlm_MessageNew( "repeat" , buffer ) );
}
}
message_child = vlm_MessageAdd( message_schedule , vlm_MessageNew( "commands" , NULL ) ); message_child = vlm_MessageAdd( message_schedule , vlm_MessageNew( "commands" , NULL ) );
...@@ -1464,30 +1481,7 @@ static vlm_message_t *vlm_Help( vlm_t *vlm, char *psz_filter ) ...@@ -1464,30 +1481,7 @@ static vlm_message_t *vlm_Help( vlm_t *vlm, char *psz_filter )
if( psz_filter == NULL ) if( psz_filter == NULL )
{ {
char *help = malloc( strlen( "Commands Syntax:" ) + char *help= strdup(
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,
"Commands Syntax:" "Commands Syntax:"
"\n new (name) vod|broadcast|schedule [properties]" "\n new (name) vod|broadcast|schedule [properties]"
"\n setup (name) (properties)" "\n setup (name) (properties)"
...@@ -1794,7 +1788,7 @@ static vlm_schedule_t *vlm_ScheduleNew( vlm_t *vlm , char *psz_name ) ...@@ -1794,7 +1788,7 @@ static vlm_schedule_t *vlm_ScheduleNew( vlm_t *vlm , char *psz_name )
sched->command = NULL; sched->command = NULL;
sched->i_date = 0; sched->i_date = 0;
sched->i_period = 0; sched->i_period = 0;
sched->i_repeat = 0; sched->i_repeat = -1;
TAB_APPEND( vlm->i_schedule , vlm->schedule , sched ); TAB_APPEND( vlm->i_schedule , vlm->schedule , sched );
...@@ -2085,6 +2079,8 @@ static int Manage( vlc_object_t* p_object ) ...@@ -2085,6 +2079,8 @@ static int Manage( vlc_object_t* p_object )
{ {
mtime_t i_real_date = vlm->schedule[i]->i_date; mtime_t i_real_date = vlm->schedule[i]->i_date;
if( vlm->schedule[i]->b_enabled == VLC_TRUE )
{
if( vlm->schedule[i]->i_date == 0 ) // now ! if( vlm->schedule[i]->i_date == 0 ) // now !
{ {
vlm->schedule[i]->i_date = (i_time / 1000000) * 1000000 ; vlm->schedule[i]->i_date = (i_time / 1000000) * 1000000 ;
...@@ -2102,8 +2098,6 @@ static int Manage( vlc_object_t* p_object ) ...@@ -2102,8 +2098,6 @@ static int Manage( vlc_object_t* p_object )
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 ) if( i_real_date <= i_time && i_real_date > i_lastcheck )
{ {
for( j = 0 ; j < vlm->schedule[i]->i_command ; j++ ) 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