From cfb12b7da67841e011a94f5db8adb6d896575480 Mon Sep 17 00:00:00 2001 From: hummypkg Date: Sun, 11 Sep 2011 21:23:42 +0000 Subject: [PATCH] move scheduling code to class, support split events git-svn-id: file:///root/webif/svn/humax/pkg/src/webif/trunk@384 2a923420-c742-0410-a762-8d5b09965624 --- var/mongoose/cgi-bin/epg_schedule.jim | 44 ++---------------------- var/mongoose/cgi-bin/sched_info.jim | 2 +- var/mongoose/include/epg.jim | 3 +- var/mongoose/include/sched.jim | 34 +++++++++++-------- var/mongoose/lib/epg.class | 5 +++ var/mongoose/lib/rsv.class | 49 +++++++++++++++++++++++++-- 6 files changed, 76 insertions(+), 61 deletions(-) diff --git a/var/mongoose/cgi-bin/epg_schedule.jim b/var/mongoose/cgi-bin/epg_schedule.jim index e6b986f..a24e3c8 100755 --- a/var/mongoose/cgi-bin/epg_schedule.jim +++ b/var/mongoose/cgi-bin/epg_schedule.jim @@ -10,10 +10,6 @@ puts "" cgi_input #cgi_dump -#set _cgi(service) 4170 -#set _cgi(event) 38584 -#set _cgi(type) 2 - if {![dict exists $_cgi service] || ![dict exists $_cgi event]} { puts "Error, insufficient parameters passed." exit @@ -35,44 +31,8 @@ if {[$event percent] > 0} { exit } -$event get_channel_info - -set args {} - -set args(ersvtype) 3 -set args(hsvc) [$event get channel_hsvc] -set args(nsttime) [$event get start] -set args(nduration) [$event get duration] -set args(usevtid) [$event get event_id] -set args(szevtname) "\025[$event get name]" -set args(eReady) 30 - -set ccrid [$event get channel_crid] - -if {$type == 1} { - # Event - set args(ucCRIDType) 49 - set args(ucRecKind) 1 - set args(szCRID) "$ccrid[$event get event_crid]" - set args(szEventToRecord) "1$args(szCRID)|" -} else { - # Series - set args(ucCRIDType) 50 - set args(ucRecKind) 4 - set args(szCRID) "$ccrid[$event get series_crid]" - set args(szFPBRecPath) "$args(szevtname)" - set progs [lmap i [epg fetch dump -scrid [$event get series_crid]] { - if {[set ecrid [$i get event_crid]] eq ""} { continue } - list "1$::ccrid$ecrid" - }] - set args(szEventToRecord) "[join $progs "|"]|" -} - -#puts $args - -set msg "" -#if {![file exists /mod/.schedule.testing]} { set msg "Disabled during testing" } -if {$msg ne "" || [catch {[rsv new $args] insert} msg]} { +set r [rsv construct $event $type] +if {[catch {$r insert} msg]} { puts "Error encountered while scheduling the recording: $msg" } else { puts "Successfully scheduled recording of [$event get name]" diff --git a/var/mongoose/cgi-bin/sched_info.jim b/var/mongoose/cgi-bin/sched_info.jim index 2b838e2..958254a 100755 --- a/var/mongoose/cgi-bin/sched_info.jim +++ b/var/mongoose/cgi-bin/sched_info.jim @@ -2,7 +2,7 @@ package require cgi source /mod/var/mongoose/lib/setup -require rsv.class +require rsv.class progressbar puts "Content-Type: text/html" puts "" diff --git a/var/mongoose/include/epg.jim b/var/mongoose/include/epg.jim index 8d6749b..e420b85 100755 --- a/var/mongoose/include/epg.jim +++ b/var/mongoose/include/epg.jim @@ -44,8 +44,9 @@ foreach record [lsort -command rsort $records] { if {$favlist != "" && [$record get service_id] ni $favlist} { continue } - altrow set num [$record get channel_num] + if {$num == 0 || $num >= 800} { continue } + altrow puts "$num" puts "[$record channel_icon 50] diff --git a/var/mongoose/include/sched.jim b/var/mongoose/include/sched.jim index 7ca66d3..e911199 100755 --- a/var/mongoose/include/sched.jim +++ b/var/mongoose/include/sched.jim @@ -173,25 +173,29 @@ proc eventrow {event {table TBL_RESERVATION}} { set e $($s + $d) set n [clock seconds] - if { $n > $e } { - puts "" - } else { - puts "" - } - puts "[clock format $s -format "%a %d %b %Y"]
+ set ds "[clock format $s -format "%a %d %b %Y"]
[clock format $s -format "%H:%M %Z"]" - if {$d > 0 && $n > $s && $n < $e} { - puts "
" - set perc [expr [expr $n - $s] * 100 / $d] - puts "" - puts [progressbar $perc] + if { $n > $e && [$event get ersvtype] <= 3} { + puts " + --- -- --- ----
--:--" + puts "--:--:--" + } else { + puts " $e} { puts " blood" } + puts "\">$ds" + if {$d > 0 && $n > $s && $n < $e} { + puts "
" + set perc [expr [expr $n - $s] * 100 / $d] + puts "" + puts [progressbar $perc] + } + puts "" + puts "[clock format [$event get nduration] -format %T]" } - puts "" - - puts "[clock format [$event get nduration] -format %T]" - puts "$rsvicon $RKIcon" if {[$event get aulEventToRecordInfo] != ""} { puts "" } + if {[string match {/*#?} $event_crid]} { + lappend set \ + "" + } + return $set } diff --git a/var/mongoose/lib/rsv.class b/var/mongoose/lib/rsv.class index 8e8c3c6..241c748 100755 --- a/var/mongoose/lib/rsv.class +++ b/var/mongoose/lib/rsv.class @@ -193,11 +193,13 @@ proc {rsv list} {{table tbl_reservation}} { set res [$::rsvdb query " select $table.*, channel.TBL_SVC.szSvcName, channel.TBL_SVC.usLcn, - case when ersvtype > 3 then 1 else 0 end as sort + case when ersvtype > 3 then 1 else 0 end as sort1, + case when nsttime + nduration < [clock seconds] + then 0 else 1 end as sort2 from $table left join channel.TBL_SVC on $table.hSvc = channel.TBL_SVC.hSvc - order by sort, nsttime + order by sort1, sort2 desc, nsttime "] set records {} @@ -293,3 +295,46 @@ proc {rsv commit} {} { $::rsvdb query {commit transaction} } +proc {rsv construct} {event type} { + $event get_channel_info + + set args {} + + set args(ersvtype) 3 + set args(hsvc) [$event get channel_hsvc] + set args(nsttime) [$event get start] + set args(nduration) [$event get duration] + set args(usevtid) [$event get event_id] + set args(szevtname) "\025[$event get name]" + set args(eReady) 30 + + set ccrid [$event get channel_crid] + + if {$type == 1} { + # Event + set args(ucCRIDType) 49 + set args(ucRecKind) 1 + set args(szCRID) "$ccrid[$event get event_crid]" + set args(szEventToRecord) "1$args(szCRID)|" + + # Handle split events + if {[string match {*#?} $args(szCRID)]} { + set args(ucRecKind) 2 + set args(szCRID) [string range $args(szCRID) 0 end-2] + } + } else { + # Series + set args(ucCRIDType) 50 + set args(ucRecKind) 4 + set args(szCRID) "$ccrid[$event get series_crid]" + set args(szFPBRecPath) "$args(szevtname)" + set progs [lmap i [epg fetch dump -scrid [$event get series_crid]] { + if {[set ecrid [$i get event_crid]] eq ""} { continue } + list "1$::ccrid$ecrid" + }] + set args(szEventToRecord) "[join $progs "|"]|" + } + + return [rsv new $args] +} +