Compare commits

...

7 Commits

Author SHA1 Message Date
hummypkg
b378ec1b9c create system class and use it. Expand rsv fetch to include ersvtype
git-svn-id: file:///root/webif/svn/humax/pkg/src/webif/trunk@344 2a923420-c742-0410-a762-8d5b09965624
2011-09-02 19:50:10 +00:00
hummypkg
df85584352 fix sql queries to use escaped parameters
git-svn-id: file:///root/webif/svn/humax/pkg/src/webif/trunk@339 2a923420-c742-0410-a762-8d5b09965624
2011-09-01 22:20:53 +00:00
hummypkg
b7310e9765 fix rsvp table and allow scheduling
git-svn-id: file:///root/webif/svn/humax/pkg/src/webif/trunk@331 2a923420-c742-0410-a762-8d5b09965624
2011-08-31 21:55:39 +00:00
hummypkg
3f02bf8365 increment version to 0.6.6
git-svn-id: file:///root/webif/svn/humax/pkg/src/webif/trunk@329 2a923420-c742-0410-a762-8d5b09965624
2011-08-31 21:48:15 +00:00
hummypkg
1d6917a782 changes for rs
git-svn-id: file:///root/webif/svn/humax/pkg/src/webif/trunk@328 2a923420-c742-0410-a762-8d5b09965624
2011-08-31 21:47:43 +00:00
hummypkg
0852c70891 improve scheduling screen
git-svn-id: file:///root/webif/svn/humax/pkg/src/webif/trunk@311 2a923420-c742-0410-a762-8d5b09965624
2011-08-29 22:34:26 +00:00
hummypkg
981c8312cd version
git-svn-id: file:///root/webif/svn/humax/pkg/src/webif/trunk@306 2a923420-c742-0410-a762-8d5b09965624
2011-08-25 20:30:48 +00:00
16 changed files with 450 additions and 121 deletions

View File

@@ -1,11 +1,11 @@
Package: webif
Priority: optional
Section: web
Version: 0.6.4-1
Version: 0.6.7
Architecture: mipsel
Maintainer: af123@hummypkg.org.uk
Depends: mongoose(>=3.0-2),jim(>=0.71-1),jim-sqlite3(>=0.71-1),jim-cgi(>=0.4),jim-oo,jim-pack,service-control,busybox(>=1.18.3-1),lsof,epg(>=1.0.2),hmt(>=1.0.6),ssmtp
Depends: mongoose(>=3.0-2),jim(>=0.71-1),jim-sqlite3(>=0.71-1),jim-cgi(>=0.4),jim-oo,jim-pack,service-control,busybox(>=1.18.3-1),lsof,epg(>=1.0.3),hmt(>=1.0.6),ssmtp
Replaces: af123-webif
Conflicts: af123-webif
Suggests: ffmpeg
Suggests: ffmpeg,webif-iphone
Description: An evolving web interface for the Humax.

View File

@@ -10,15 +10,10 @@ puts ""
cgi_input
#cgi_dump
set service 0
catch { set service [dict get $_cgi service] }
set event 0
catch { set event [dict get $_cgi event] }
set service [cgi_get service 0]
set event [cgi_get event 0]
if {! [dict exists $_cgi bare]} { header }
#set service 8448
#set event 30843
set record [lindex [epg fetch dump -service $service -event $event] 0]
$record get_channel_info
set others [$record othertimes]

View File

@@ -2,7 +2,7 @@
package require cgi
source /mod/var/mongoose/lib/setup
require epg.class
require epg.class system.class
puts "Content-Type: text/html"
puts ""
@@ -71,12 +71,12 @@ if {$type == 1} {
#puts $args
set msg ""
if {![file exists /mod/.schedule.testing]} { set msg "Disabled during testing" }
#if {![file exists /mod/.schedule.testing]} { set msg "Disabled during testing" }
if {$msg ne "" || [catch {[rsv new $args] insert} msg]} {
puts "Error encountered while scheduling the recording: <i>$msg</i>"
} else {
puts "Successfully scheduled recording of <i>[$event get name]</i>"
close [open /tmp/.restartpending w]
system restartpending
}
epg cleanup

View File

@@ -2,7 +2,7 @@
package require cgi
source /mod/var/mongoose/lib/setup
require rsv.class
require rsv.class system.class
puts "Content-Type: text/html"
puts ""
@@ -11,8 +11,7 @@ cgi_input
if {[cgi_get now] eq "yes"} {
# - Busybox reboot does sync the disk but may still not be clean enough.
puts "Restarting."
exec /etc/init.d/S90settop shut
exec /sbin/reboot
system reboot
exit
}

View File

@@ -0,0 +1,26 @@
#!/mod/bin/jimsh
package require cgi
source /mod/var/mongoose/lib/setup
require rsv.class
puts "Content-Type: text/html"
puts ""
cgi_input
#cgi_dump
set slot [cgi_get slot 0]
set table [cgi_get table TBL_RESERVATION]
set event [rsv slot $table $slot]
if {$table eq "pending"} {
$event remove_pending
exit
}
$event clear_ulslot
$event set_delete
$event insert

View File

@@ -0,0 +1,123 @@
#!/mod/bin/jimsh
package require cgi
source /mod/var/mongoose/lib/setup
require rsv.class
puts "Content-Type: text/html"
puts ""
cgi_input
#cgi_dump
set table [cgi_get table TBL_RESERVATION]
set slot [cgi_get slot 0]
set event [rsv slot $table $slot]
set rsvicon [$event icon]
if {$rsvicon ne ""} {
set rsvicon "<img src='images/$rsvicon' height=20>
}
set RKIcon [$event RKIcon]
if {$RKIcon ne ""} {
set RKIcon "<img src='images/$RKIcon' height=20>
}
if {[$event get ucRecKind] == 4} {
set series 1
} else {
set series 0
}
puts "
<table class=keyval>
<tr>
<th>Event [$event get ulslot]</th>
<td class=va>$rsvicon $RKIcon</td>
</tr><tr>
<th>Channel</th>
<td class=va>
"
if {[$event get usLcn] ne ""} {
puts "
<img class=va width=50
src=\"/img/channels/[$event channel_name].png\">
- [$event get usLcn] - [$event channel_name]
"
}
puts "
</td>
</tr><tr>
<th>Event Name</th>
<td>[$event name]</td>
</tr><tr>
<th>Start</th>
"
set s [$event get nsttime]
set d [$event get nduration]
set e $($s + $d)
set n [clock seconds]
if { $n > $e } {
puts "<td class=blood nowrap class=va>"
} else {
puts "<td nowrap class=va>"
}
puts "[clock format $s -format "%a %d %b %Y"]
[clock format $s -format "%H:%M %Z"]"
if {$d > 0 && $n > $s && $n < $e} {
puts "<br>"
set perc [expr [expr $n - $s] * 100 / $d]
puts "<img class=va src=/images/745_1_11_Video_1REC.png>"
puts [progressbar $perc]
}
puts "
</td>
</tr><tr>
<th>Duration</th>
<td>[clock format [$event get nduration] -format %T]</td>
</tr>
"
set crid [join [lrange [split [$event get szCRID] /] 1 end]]
if {$crid != ""} {
puts "<tr><th>"
if $series { puts "Series" } else { puts "Event" }
puts " CRID</th><td>"
puts -nonewline "<a href=/cgi-bin/epg_search.jim?"
if $series { puts -nonewline "s" }
puts "crid=/$crid>
<img border=0 src=/images/421_1_00_CH_Title_2R_Arrow.png
height=14>
[$event get szCRID]"
puts "</a></td></tr>"
}
puts "<tr><th>Events</th><td>"
set flag 0
foreach ev [split [$event get szEventToRecord] "|"] {
if {$ev eq ""} { continue }
set ev [string range $ev 1 end]
if {$flag} { puts "<br>" }
incr flag
set crid [join [lrange [split $ev /] 1 end]]
puts -nonewline "<a href=/cgi-bin/epg_search.jim?"
puts "crid=/$crid>
<img border=0 src=/images/421_1_00_CH_Title_2R_Arrow.png
height=14>
$ev"
puts "</a>"
}
puts "</td></tr>"
puts "<tr><th>Accepted</th><td>"
if {[$event get aulEventToRecordInfo] != ""} {
puts "Yes"
}
puts "</td></tr>"
puts "</table>"

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

View File

@@ -1,27 +1,9 @@
#!/mod/bin/jimsh
proc extract {line} {
regsub -all -- {[[:space:]]+} $line " " line
set fields [split $line]
set ::size [lindex $fields 1]
set ::used [lindex $fields 2]
set ::perc [string trimright [lindex $fields 4] "%"]
}
set used 0
set size 0
set perc 0
foreach df [split [exec df -h 2>>/dev/null] "\n\r"] {
if {[string match *sd?2* $df]} {
extract $df
break;
}
if {[string match *media/drive? $df]} {
extract $df
}
}
source /mod/var/mongoose/lib/setup
require system.class
lassign [system diskspace] size used perc
set file [format "%02d" [expr {$perc * 25 / 100 + 1}]]
# The HD model only has the USB images which are blue. I prefer the green

View File

@@ -1,15 +1,7 @@
#!/mod/bin/jimsh
if {[catch {set fp [open /etc/model r]}]} {
set model {HD[R]}
} else {
set model [string trim [read $fp]]
close $fp
}
source /mod/var/mongoose/lib/setup
require system.class
if {[catch {set hostname [string trim [exec hostname]]}]} {
set hostname "humax"
}
puts "Humax $model Fox T2 ($hostname)"
puts "Humax [system model] Fox T2 ([system hostname])"

View File

@@ -1,5 +1,8 @@
#!/mod/bin/jimsh
source /mod/var/mongoose/lib/setup
require system.class
if {[file exists /tmp/.restartpending]} {
puts {
@@ -12,12 +15,7 @@ puts {
<font class=blood>
}
# Is humaxtv doing anything?
set pid [exec pgrep humaxtv]
set c 0
catch { set c [exec /mod/bin/lsof -p $pid | grep Video | fgrep .ts | wc -l] }
if {$c > 0} {
if {[system busy]} {
puts "Cannot restart whilst box is busy."
} else {
puts {
@@ -35,7 +33,7 @@ puts {
<script type=text/javascript>
$('#restart_humaxtv').button();
$('#restart_humaxtv').click(function() {
if (confirm('Are you sure you wish to perform a warm restart now?'))
if (confirm('Are you sure you wish to perform a restart now?'))
window.location = '/cgi-bin/restart.jim';
});
</script>

View File

@@ -4,6 +4,7 @@ source /mod/var/mongoose/lib/setup
require altrow rsv.class progressbar
puts {
<div id=dialogue></div>
<script type=text/javascript>
$.tablesorter.addParser({
@@ -38,62 +39,108 @@ $(document).ready(function() {
}
});
});
$(document).ready(function() {
function docancel()
{
var table = $('#dialogue').attr('table');
var slot = $('#dialogue').attr('slot');
if (confirm('Really remove scheduled event?'))
{
$.get('/cgi-bin/sched_cancel.jim?slot=' + slot +
'&table=' + table, function() {
window.location.reload(true);
});
$('#dialogue').dialog('close');
}
}
var $buttons1 = {
"Close" : function() {$(this).dialog('close');}
};
var $buttons2 = $.extend(
{"Cancel Event": function() { docancel() }},
$buttons1);
var $dialog = $('#dialogue').dialog({
title: "Schedule Details",
modal: false, autoOpen: false,
height: 500, width: 700,
show: 'scale', hide: 'fade',
draggable: true, resizable: true,
buttons: $buttons2,
close: function(e,u) { $('#dialogue').empty().html(
'<img src="/img/loading.gif" alt="loading">'); }
});
function schedpopup(e, o)
{
e.preventDefault();
var slot = o.attr('slot');
var table = o.attr('table');
$('#dialogue').attr('slot', slot).attr('table', table);
var url = '/cgi-bin/sched_info.jim?slot=' + slot +
'&table=' + table;
$('#dialogue').load(url);
$dialog.dialog('open');
}
$('a.schedule').click(function(e) { schedpopup(e, $(this)) });
});
</script>
}
proc eventheader {} {
proc eventheader {{table TBL_RESERVATION}} {
puts {
<table class="borders tablesorter">
<thead>
<tr>
}
if {$table eq "pending" } { puts "<th>Action</th>" }
puts {
<th></th>
<th>&nbsp;</th><th>Channel</th>
<th>Programme</th>
<th>Start Time</th>
<th>Duration</th>
<th>Mode</th>
<th>Event/Series ID</th>
<th>Events</th>
</tr>
</thead>
<tbody>
}
}
proc eventrow {event} {
proc eventrow {event {table TBL_RESERVATION}} {
set name [$event name]
altrow
set rsvicon ""
switch [$event get ersvtype] {
1 { set rsvicon "175_1_00_Reservation_Watch.png" }
2 { set rsvicon "175_1_00_Reservation_Watch.png" }
3 { set rsvicon "175_1_11_Reservation_Record.png" }
5 { set rsvicon "745_1_10_Video_2Live.png" }
6 { set rsvicon "745_1_11_Video_1REC.png" }
7 { set rsvicon "345_6_08_ST_Ad_Hoc.png" }
}
set series 0
set rsvicon [$event icon]
set RKIcon [$event RKIcon]
if {[$event get ucRecKind] == 4} {
set RKIcon "175_1_11_Series_Record.png"
set series 1
} else {
switch [$event get erepeat] {
1 {set RKIcon "521_1_00_RP_Daily_C.png"}
2 {set RKIcon "521_1_00_RP_Weekly_C.png"}
3 {set RKIcon "521_1_00_RP_Weekdays_C.png"}
4 {set RKIcon "521_1_00_RP_Weekend_C.png"}
default {set RKIcon ""}
}
set series 0
}
if {$rsvicon ne ""} {
set rsvicon "<img src='images/$rsvicon' height=20>
set rsvicon "<img src='/images/$rsvicon' height=20>
}
if {$RKIcon ne ""} {
set RKIcon "<img src='images/$RKIcon' height=20>
set RKIcon "<img src='/images/$RKIcon' height=20>
}
if {$table eq "pending"} {
if {[$event get action] == 0} {
set icon "add"
} else {
set icon "close"
}
puts "<td align=center>
<img class=va width=30 src=/img/$icon.png></td>"
}
puts "<td>[$event get ulslot]</td>"
@@ -111,7 +158,10 @@ proc eventrow {event} {
puts "<td>&nbsp;<br><br></td><td>&nbsp;</td>"
}
puts "<td nowrap>$name</td>"
puts "<td nowrap>
<a slot=[$event get ulslot] table=$table
href=# class=schedule>$name</a>
</td>"
set s [$event get nsttime]
set d [$event get nduration]
@@ -138,36 +188,12 @@ proc eventrow {event} {
puts "<td>[clock format [$event get nduration] -format %T]</td>"
puts "<td nowrap>$rsvicon $RKIcon</td>"
puts "<td nowrap>"
set crid [join [lrange [split [$event get szCRID] /] 1 end]]
if {$crid != ""} {
puts -nonewline "<a href=/cgi-bin/epg_search.jim?"
if $series { puts -nonewline "s" }
puts "crid=/$crid>
<img border=0 src=/images/421_1_00_CH_Title_2R_Arrow.png
height=14>
[$event get szCRID]"
puts "</a>"
}
puts "</td>"
puts "<td nowrap>"
set flag 0
foreach ev [split [$event get szEventToRecord] "|"] {
if {$ev eq ""} { continue }
set ev [string range $ev 1 end]
if {$flag} { puts "<br>" }
incr flag
set crid [join [lrange [split $ev /] 1 end]]
puts -nonewline "<a href=/cgi-bin/epg_search.jim?"
puts "crid=/$crid>
<img border=0 src=/images/421_1_00_CH_Title_2R_Arrow.png
height=14>
$ev"
puts "</a>"
}
puts "</td>"
if {[$event get aulEventToRecordInfo] != ""} {
puts "<td>*</td>"
puts "<td><img src=/img/lightning.png
alt=\"Accepted by Humax\"
title=\"Accepted by Humax\"></td>"
} else {
puts "<td>&nbsp;</td>"
}
puts "</tr>"
}
@@ -178,9 +204,9 @@ proc eventfooter {} {
set events [rsv list pending]
if {[llength $events] > 0} {
puts "<h2>Pending Scheduled Events</h2>"
eventheader
foreach event $events {eventrow $event}
puts "<h2>Pending Schedule Events</h2>"
eventheader pending
foreach event $events {eventrow $event pending}
eventfooter
puts {
<small>

View File

@@ -136,7 +136,7 @@ epg method get_channel_info {} {
set chan [lindex [$channeldb query {
select szSvcName, usLcn, aucDefaultAuthority, hsvc
from TBL_SVC
where usSvcId = %s} $service_id
where usSvcId = '%s'} $service_id
] 0]
if {[dict exists $chan usLcn]} {
set channel_num $chan(usLcn)

41
var/mongoose/lib/findhsvc Executable file
View File

@@ -0,0 +1,41 @@
if {![exists -proc findhsvc]} {
require rsv.class
proc findhsvc {channel} {
global rsvdb
set hsvc [$rsvdb query "
select hSvc
from channel.TBL_SVC
where szSvcName = '$channel'
or szSvcname = '\025$channel'
limit 1
"]
if {[llength $hsvc] == 1} {
return [lindex [lindex $hsvc 0] 1]
} else {
return 0
}
}
proc findhsvcbylcn {lcn} {
global rsvdb
set hsvc [$rsvdb query "
select hSvc
from channel.TBL_SVC
where usLcn = $lcn
limit 1
"]
if {[llength $hsvc] == 1} {
return [lindex [lindex $hsvc 0] 1]
} else {
return 0
}
}
}

View File

@@ -12,10 +12,14 @@ if {![file exists /var/lib/humaxtv/rsvp.db]} {
set tdb [sqlite3.open /var/lib/humaxtv/rsvp.db]
$tdb query {drop table TBL_VERSION}
$tdb query {alter table TBL_RESERVATION rename to pending}
$tdb query {alter table pending add column action int}
$tdb query {delete from pending}
$tdb close
}
$rsvdb query {attach database '/var/lib/humaxtv/rsvp.db' as pending}
# This is required to upgrade old tables and will be removed in a future
# version.
catch { $rsvdb query {alter table pending add column action int} }
class rsv {
ulslot -1
@@ -47,6 +51,7 @@ class rsv {
szSvcName {}
usLcn 0
sort 0
action 0
}
rsv method clear_ulslot {} {
@@ -63,7 +68,7 @@ rsv method name {} {
5 { set name "--- Wake-up ---" }
6 { set name "--- Sleep ---" }
7 { set name "--- Auto Update ---" }
11 { set name "--- DSO Event? ---" }
11 { set name "--- DSO Event ---" }
default { set name "--- Unknown event type $ersvtype ---" }
}
}
@@ -75,16 +80,52 @@ rsv method channel_name {} {
return [string range $szSvcName 1 end]
}
rsv method icon {} {
set rsvicon ""
switch [$self get ersvtype] {
1 { set rsvicon "175_1_00_Reservation_Watch.png" }
2 { set rsvicon "175_1_00_Reservation_Watch.png" }
3 { set rsvicon "175_1_11_Reservation_Record.png" }
5 { set rsvicon "745_1_10_Video_2Live.png" }
6 { set rsvicon "745_1_11_Video_1REC.png" }
7 { set rsvicon "345_6_08_ST_Ad_Hoc.png" }
}
return $rsvicon
}
rsv method RKIcon {} {
if {[$self get ucRecKind] == 4} {
set RKIcon "175_1_11_Series_Record.png"
} else {
switch [$self get erepeat] {
1 {set RKIcon "521_1_00_RP_Daily_C.png"}
2 {set RKIcon "521_1_00_RP_Weekly_C.png"}
3 {set RKIcon "521_1_00_RP_Weekdays_C.png"}
4 {set RKIcon "521_1_00_RP_Weekend_C.png"}
default {set RKIcon ""}
}
}
return $RKIcon
}
rsv method set_delete {} {
set action 1
}
rsv method remove_pending {} {
$::rsvdb query "delete from pending where ulslot = [$self get ulslot]"
}
rsv method fix_hsvc {} {
global rsvdb
set _hsvc [$rsvdb query "
set _hsvc [$rsvdb query {
select hSvc
from channel.TBL_SVC
where szSvcName = '$szSvcName'
or szSvcname = '\025$szSvcName'
where szSvcName = '%s'
or szSvcname = '\025%s'
limit 1
"]
} $szSvcName $szSvcName]
if {[llength $_hsvc] == 1} {
set hsvc [lindex [lindex $_hsvc 0] 1]
@@ -124,6 +165,11 @@ rsv method insert {{table pending}} {
set fields [lreplace $fields $df $df]
}
if {$table ne "pending"} {
set df [lsearch $fields "action"]
set fields [lreplace $fields $df $df]
}
set vals {}
foreach field $fields {
# Escape any quotes embedded in the data.
@@ -194,6 +240,41 @@ proc {rsv entry} {{table TBL_RESERVATION} crid svc} {
return 0
}
proc {rsv fetch} {{table TBL_RESERVATION} ersvtype hsvc nsttime usevtid events} {
set res [$::rsvdb query "
select $table.*,
channel.TBL_SVC.szSvcName, channel.TBL_SVC.usLcn
from $table
left join channel.TBL_SVC
on $table.hSvc = channel.TBL_SVC.hSvc
where $table.ersvtype = '%s'
and $table.hsvc = '%s'
and $table.nsttime = '%s'
and $table.usevtid = '%s'
and $table.szEventToRecord = '%s'
" $ersvtype $hsvc $nsttime $usevtid $events]
if {[llength $res] > 0} {
return [rsv new [lindex $res 0]]
}
return 0
}
proc {rsv slot} {{table TBL_RESERVATION} slot} {
set res [$::rsvdb query "
select $table.*,
channel.TBL_SVC.szSvcName, channel.TBL_SVC.usLcn
from $table
left join channel.TBL_SVC
on $table.hSvc = channel.TBL_SVC.hSvc
where ulslot = %s" $slot]
if {[llength $res] > 0} {
return [rsv new [lindex $res 0]]
}
return 0
}
proc {rsv cleanup} {} {
catch {$::rsvdb close}
}
@@ -201,8 +282,10 @@ proc {rsv cleanup} {} {
proc {rsv commit} {} {
$::rsvdb query {begin transaction}
foreach rec [rsv list pending] {
$rec clear_ulslot
$rec insert TBL_RESERVATION
if {[$rec get action] == 0} {
$rec clear_ulslot
$rec insert TBL_RESERVATION
}
}
$::rsvdb query {delete from pending}
$::rsvdb query {commit transaction}

View File

@@ -0,0 +1,64 @@
if {![exists -proc class ]} { package require oo }
class system {}
proc {system model} {} {
if {[catch {set fp [open /etc/model r]}]} {
set model {HD[R]}
} else {
set model [string trim [read $fp]]
close $fp
}
return $model
}
proc {system hostname} {} {
if {[catch {set hostname [string trim [exec hostname]]}]} {
set hostname "humax"
}
return $hostname
}
proc {system diskspace} {} {
switch [system model] {
HDR { set part /mnt/hd2 }
HD { set part /media/drive1 }
}
set size 0
set used 0
set perc 0
foreach line [split [exec df -h $part 2>>/dev/null] "\n\r"] {
if {[string match "/*" $line]} {
regsub -all -- {[[:space:]]+} $line " " line
set fields [split $line]
set size [lindex $fields 1]
set used [lindex $fields 2]
set perc [string trimright [lindex $fields 4] "%"]
break
}
}
return [list $size $used $perc]
}
proc {system busy} {} {
# Is humaxtv doing anything?
set pid [exec pgrep humaxtv]
set c 0
catch { set c [exec /mod/bin/lsof -p $pid | grep Video | fgrep .ts | wc -l] }
if {$c > 0} { return 1 }
return 0
}
proc {system reboot} {} {
exec /etc/init.d/S90settop shut
exec /sbin/reboot
}
proc {system restartpending} {} {
close [open /tmp/.restartpending w]
}