From a5c65505e4ee55f47f0a89a723af3c5726b0b23c Mon Sep 17 00:00:00 2001 From: hummypkg Date: Wed, 18 Apr 2012 20:26:34 +0000 Subject: [PATCH] show current channel, retain more backups git-svn-id: file:///root/webif/svn/humax/pkg/src/webif/trunk@927 2a923420-c742-0410-a762-8d5b09965624 --- CONTROL/control | 2 +- var/mongoose/cgi-bin/backup/backup.jim | 2 +- var/mongoose/cgi-bin/status.jim | 110 ++++++++++++++++++------- var/mongoose/lib/findhsvc | 16 ++++ var/mongoose/lib/settings.class | 2 +- var/mongoose/lib/system.class | 8 +- 6 files changed, 103 insertions(+), 37 deletions(-) diff --git a/CONTROL/control b/CONTROL/control index 504287f..398c707 100644 --- a/CONTROL/control +++ b/CONTROL/control @@ -1,7 +1,7 @@ Package: webif Priority: optional Section: web -Version: 0.9.5-2 +Version: 0.9.5-3 Architecture: mipsel Maintainer: af123@hummypkg.org.uk Depends: webif-channelicons,mongoose(>=3.0-7),jim(>=0.73-1),jim-oo,jim-sqlite3(>=0.73),jim-cgi(>=0.5),service-control(>=1.2),busybox(>=1.19.3-1),lsof,epg(>=1.0.9),hmt(>=1.1.6),ssmtp,anacron,trm,openssl-command,nicesplice,id3v2,file,rsvsync(>=1.0.1) diff --git a/var/mongoose/cgi-bin/backup/backup.jim b/var/mongoose/cgi-bin/backup/backup.jim index 0150758..47c2c5b 100755 --- a/var/mongoose/cgi-bin/backup/backup.jim +++ b/var/mongoose/cgi-bin/backup/backup.jim @@ -19,7 +19,7 @@ set file [file tail [cgi_get file \ if {[string match {auto-*} $file]} { # Delete any automatic backups over 7 days old. - set mt $(7 * 86400) + set mt $(15 * 86400) foreach af [glob -nocomplain "$dir/auto-*"] { set aft [file mtime $af] set diff $($now - $aft) diff --git a/var/mongoose/cgi-bin/status.jim b/var/mongoose/cgi-bin/status.jim index c4fa54d..d626e0c 100755 --- a/var/mongoose/cgi-bin/status.jim +++ b/var/mongoose/cgi-bin/status.jim @@ -1,49 +1,95 @@ #!/mod/bin/jimsh +source /mod/var/mongoose/lib/setup +require system.class findhsvc epg.class + puts "Content-Type: text/html" puts "" -if {[catch {set pid [exec pgrep humaxtv]}]} { exit } - -if {[catch {set data [exec lsof -p $pid | grep Video | fgrep .ts]} ]} { - exit +if {[catch {set pid [exec pgrep humaxtv]}]} { + puts "Cannot find humaxtv process." + exit } -set lines [split $data "\n"] -foreach line $lines { - regsub -all -- {[[:space:]]+} $line " " line - set fields [split $line " "] - set name [lindex [split $line "/"] end] - set size($name) [lindex $fields 6] - set seen($name) 0 -} +proc get_data {} { + global pid -sleep 2 - -set data [exec lsof -p $pid | grep Video | fgrep .ts] -regsub -all -- {[[:space:]]+} $line " " line -set lines [split $data "\n"] -foreach line $lines { - regsub -all -- {[[:space:]]+} $line " " line - set fields [split $line " "] - set name [lindex [split $line "/"] end] - set size2 [lindex $fields 6] - - if { $size2 > $size($name) && $seen($name) < 1 } { - set mode "Recording" - set icon "745_1_11_Video_1REC.png" + set ret {} + if {[catch {set data \ + [exec /mod/bin/lsof -p $pid | grep Video | fgrep .ts]} ]} { + set ret {} } else { - set mode "Watching" - set icon "745_1_10_Video_2Live.png" + foreach line [split $data "\n"] { + regsub -all -- {[[:space:]]+} $line " " line + set name [file rootname [file tail $line]] + set size [lindex [split $line " "] 6] + set ret($name) $size + } } + return $ret +} - incr seen($name) +set play 0 +set rec 0 +set seen {} - lappend output " - $mode $name
" +set data [get_data] +if {[llength $data]} { + sleep 2 + set ndata [get_data] + foreach name [array names ndata] { + if {![dict exists $seen $name]} { set seen($name) 0 } + if {![dict exists $data $name]} { set data($name) 0 } + if {$ndata($name) > $data($name) && $seen($name) < 1} { + incr rec + set mode "Recording" + set icon "745_1_11_Video_1REC.png" + } else { + incr play + set mode "Playing" + set icon "745_1_10_Video_2Live.png" + } + + incr seen($name) + + lappend output " + $mode $name" + } +} + +if {![system instandby] && $play < 1} { + set hsvc [system param CUR_SVC Value USERCONFIG] + + set ff [$rsvdb query " + select usSvcid as svcid, usLcn as lcn, + substr(szSvcName, 2) as name + from channel.TBL_SVC + where hSvc = $hsvc + limit 1 + "] + + if {[llength $ff] == 1} { + lassign [lindex $ff 0] x svcid x lcn x name + set epgs [epg dbfetch get \ + -service $svcid \ + -time [clock seconds]\ + ] + set prog "" + if {[llength $epgs] == 1} { + lassign $epgs epg + set prog "- [$epg get name] (" + append prog "[clock format [$epg get start] -format %H:%M] - " + append prog "[clock format $([$epg get start] + [$epg get duration]) -format %H:%M]" + append prog ") \[[$epg percent]%\]" + } + + lappend output "[epg channelicon $name 30 \ + {vertical-align: middle; padding: 0 4px 0 2px}] + Watching $lcn: $name $prog" + } } if {[llength $output]} { - puts [join $output " "] + puts [join $output "
"] } diff --git a/var/mongoose/lib/findhsvc b/var/mongoose/lib/findhsvc index ba4a87f..baa36f3 100755 --- a/var/mongoose/lib/findhsvc +++ b/var/mongoose/lib/findhsvc @@ -34,5 +34,21 @@ if {![exists -proc get_channel_attr]} { } return 0 } + + proc get_channel_attr_byhsvc {hsvc {field usLcn}} { + global rsvdb + + set ff [$rsvdb query " + select $field + from channel.TBL_SVC + where hSvc = $hsvc + limit 1 + "] + + if {[llength $ff] == 1} { + return [lindex [lindex $ff 0] 1] + } + return 0 + } } diff --git a/var/mongoose/lib/settings.class b/var/mongoose/lib/settings.class index e18de8d..baf7dc0 100644 --- a/var/mongoose/lib/settings.class +++ b/var/mongoose/lib/settings.class @@ -74,7 +74,7 @@ settings method smtp_server {{server ""}} { } settings method _nval_setting {name {val -1}} { - global settingsdb; + global settingsdb if {$val == -1} { # Get diff --git a/var/mongoose/lib/system.class b/var/mongoose/lib/system.class index 1c2a5d8..080f093 100644 --- a/var/mongoose/lib/system.class +++ b/var/mongoose/lib/system.class @@ -119,14 +119,14 @@ proc {system restartpending} {} { close [open /tmp/.restartpending w] } -proc {system param} {param {type Value}} { +proc {system param} {param {type Value} {tbl MENUCONFIG}} { if {[catch {set db [sqlite3.open /var/lib/humaxtv/setup.db]} msg]} { return 0 } set val 0 set ret [$db query " select item$type - from TBL_MENUCONFIG + from TBL_$tbl where itemName = '$param' "] if {[llength $ret] == 1} { @@ -143,6 +143,10 @@ proc {system padding} {} { ] } +proc {system instandby} {} { + return [system param LAST_STANDBY Value USERCONFIG] +} + proc {system mkdir_p} {dir} { exec /mod/bin/busybox/mkdir -p $dir }