diff --git a/var/mongoose/cgi-bin/db.jim b/var/mongoose/cgi-bin/db.jim index 84880a5..4149264 100755 --- a/var/mongoose/cgi-bin/db.jim +++ b/var/mongoose/cgi-bin/db.jim @@ -62,6 +62,7 @@ proc db_info {db_file} { $db close } +db_info /var/lib/humaxtv/rsvp.db db_info /var/lib/humaxtv/rsv.db db_info /var/lib/humaxtv/setup.db db_info /var/lib/humaxtv/channel.db diff --git a/var/mongoose/cgi-bin/restart.jim b/var/mongoose/cgi-bin/restart.jim index 258a38e..b3e1f96 100755 --- a/var/mongoose/cgi-bin/restart.jim +++ b/var/mongoose/cgi-bin/restart.jim @@ -1,9 +1,55 @@ #!/mod/bin/jimsh +package require cgi +source /mod/var/mongoose/lib/setup +require rsv.class + puts "Content-Type: text/html" puts "" -#puts [exec /etc/init.d/S90settop restart] -#file delete /tmp/.restartpending -puts [exec killall humaxtv] +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 + exit +} + +file delete /tmp/.restartpending +header + +# Commit pending reservations. +rsv commit + +puts { + + + + + +Please wait while the Humax restarts...
+
+} + +footer diff --git a/var/mongoose/html/css/jquery.progressbar.css b/var/mongoose/html/css/jquery.progressbar.css new file mode 100644 index 0000000..495a609 --- /dev/null +++ b/var/mongoose/html/css/jquery.progressbar.css @@ -0,0 +1,31 @@ + +/* progress bar container */ +#progressbar{ + border:1px solid black; + width:200px; + height:20px; + position:relative; + color:black; +} +/* color bar */ +#progressbar div.progress{ + position:absolute; + width:0; + height:100%; + overflow:hidden; + background-color:#369; +} +/* text on bar */ +#progressbar div.progress .text{ + position:absolute; + text-align:center; + color:white; +} +/* text off bar */ +#progressbar div.text{ + position:absolute; + width:100%; + height:100%; + text-align:center; +} + diff --git a/var/mongoose/html/js/jquery.progressbar.js b/var/mongoose/html/js/jquery.progressbar.js new file mode 100644 index 0000000..13dc46b --- /dev/null +++ b/var/mongoose/html/js/jquery.progressbar.js @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2007 Josh Bush (digitalbush.com) + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following + * conditions: + + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +/* + * Progress Bar Plugin for jQuery + * Version: Alpha 2 + * Release: 2007-02-26 + */ +(function($) { + //Main Method + $.fn.reportprogress = function(val,maxVal) { + var max=100; + if(maxVal) + max=maxVal; + return this.each( + function(){ + var div=$(this); + var innerdiv=div.find(".progress"); + + if(innerdiv.length!=1){ + innerdiv=$("
"); + div.append("
 
"); + $(" ").css("width",div.width()).appendTo(innerdiv); + div.append(innerdiv); + } + var width=Math.round(val/max*100); + innerdiv.css("width",width+"%"); + div.find(".text").html(width+" %"); + } + ); + }; +})(jQuery); \ No newline at end of file diff --git a/var/mongoose/include/restart.jim b/var/mongoose/include/restart.jim index f1db4ab..3483b31 100755 --- a/var/mongoose/include/restart.jim +++ b/var/mongoose/include/restart.jim @@ -36,14 +36,7 @@ puts { $('#restart_humaxtv').button(); $('#restart_humaxtv').click(function() { if (confirm('Are you sure you wish to perform a warm restart now?')) - { - $.ajax({ - url: '/cgi-bin/restart.jim', - success: function() { - window.location.reload(true); - } - }); - } + window.location = '/cgi-bin/restart.jim'; }); } diff --git a/var/mongoose/include/sched.jim b/var/mongoose/include/sched.jim index 2c47640..595898d 100755 --- a/var/mongoose/include/sched.jim +++ b/var/mongoose/include/sched.jim @@ -3,8 +3,6 @@ source /mod/var/mongoose/lib/setup require altrow rsv.class progressbar -set events [rsv list] - puts { - - - - - - - - - - - - - - - } -foreach event $events { +proc eventheader {} { + puts { +
 ChannelProgrammeStart TimeDurationModeEvent/Series IDEvents
+ + + + + + + + + + + + + + } +} + +proc eventrow {event} { set name [$event name] altrow @@ -169,8 +171,31 @@ foreach event $events { } puts "" } -puts "
 ChannelProgrammeStart TimeDurationModeEvent/Series IDEvents
" -puts "Click on the CRID to view episodes." + +proc eventfooter {} { + puts "" +} + +set events [rsv list pending] +if {[llength $events] > 0} { + puts "

Pending Scheduled Events

" + eventheader + foreach event $events {eventrow $event} + eventfooter + puts { + + + + } +} + +puts "

Scheduled Events

" +set events [rsv list] +eventheader +foreach event $events {eventrow $event} +eventfooter puts { diff --git a/var/mongoose/lib/rsv.class b/var/mongoose/lib/rsv.class index 6510c7e..da5f0ef 100755 --- a/var/mongoose/lib/rsv.class +++ b/var/mongoose/lib/rsv.class @@ -6,7 +6,16 @@ if {![exists -proc settings ]} { require settings.class } set rsvdb [sqlite3.open /var/lib/humaxtv/rsv.db] $rsvdb query {attach database '/var/lib/humaxtv/channel.db' as channel} -catch { $rsvdb query {.mode tcl} } + +if {![file exists /var/lib/humaxtv/rsvp.db]} { + file copy /var/lib/humaxtv/rsv.db /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 {delete from pending} + $tdb close +} +$rsvdb query {attach database '/var/lib/humaxtv/rsvp.db' as pending} class rsv { ulslot -1 @@ -40,6 +49,10 @@ class rsv { sort 0 } +rsv method clear_ulslot {} { + set ulslot -1 +} + rsv method name {} { set name [string range $szevtname 1 end] if {[string first "i7" $name] == 0} { @@ -81,25 +94,27 @@ rsv method fix_hsvc {} { return $hsvc } -rsv method insert {} { +rsv method insert {{table pending}} { global rsvdb # Find a spare slot. if {$ulslot < 0} { - set slots [lmap i [ - $rsvdb query { - select ulslot FROM TBL_RESERVATION - order by ulslot; - }] {lindex $i 1}] - - set max [lindex $i end] - for {set i 0} {$i < $max} {incr i} { - if {$i ni $slots} { - set ulslot $i - break + set slotlist [$rsvdb query " + select ulslot FROM $table + order by ulslot; + "] + if {[llength $slotlist] > 0} { + set slots [lmap i $slotlist {lindex $i 1}] + set max [lindex $i end] + for {set i 0} {$i < $max} {incr i} { + if {$i ni $slots} { + set ulslot $i + break + } } + if {$ulslot < 0} { set ulslot $($max + 1) } } - if {$ulslot == -1} { set ulslot $($max + 1) } + if {$ulslot < 0} { set ulslot 0 } } set fields [lsort [$self vars]] @@ -117,7 +132,7 @@ rsv method insert {} { #lappend vals "'[$self get $field]'" } - set query "insert into TBL_RESERVATION(" + set query "insert into ${table}(" append query [join $fields ","] append query ") values(" append query [join $vals ","] @@ -126,16 +141,16 @@ rsv method insert {} { $rsvdb query $query } -proc {rsv list} {} { - set res [$::rsvdb query { - select tbl_reservation.*, +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 - from tbl_reservation + from $table left join channel.TBL_SVC - on main.TBL_RESERVATION.hSvc = channel.TBL_SVC.hSvc + on $table.hSvc = channel.TBL_SVC.hSvc order by sort, nsttime - }] + "] set records {} foreach rec $res { @@ -146,31 +161,32 @@ proc {rsv list} {} { } proc {rsv lookuptab} {} { - set res [$::rsvdb query { - select tbl_reservation.szCRID, channel.TBL_SVC.hSvc - from tbl_reservation left join channel.TBL_SVC - on main.TBL_RESERVATION.hSvc = channel.TBL_SVC.hSvc - where ersvtype <= 3 - }] - - set records {} - foreach rec $res { - lappend records "$rec(hSvc)/[file tail $rec(szCRID)]" + foreach tab {tbl_reservation pending} { + set res [$::rsvdb query " + select $tab.szCRID, channel.TBL_SVC.hSvc + from $tab left join channel.TBL_SVC + on $tab.hSvc = channel.TBL_SVC.hSvc + where ersvtype <= 3 + "] + + foreach rec $res { + lappend records "$rec(hSvc)/[file tail $rec(szCRID)]" + } } return $records } -proc {rsv entry} {crid svc} { - set res [$::rsvdb query { - select tbl_reservation.*, +proc {rsv entry} {{table TBL_RESERVATION} crid svc} { + set res [$::rsvdb query " + select $table.*, channel.TBL_SVC.szSvcName, channel.TBL_SVC.usLcn - from tbl_reservation + from $table left join channel.TBL_SVC - on main.TBL_RESERVATION.hSvc = channel.TBL_SVC.hSvc - where szCRID like '%%%s' and tbl_reservation.hsvc = '%s' - } $crid $svc] + on $table.hSvc = channel.TBL_SVC.hSvc + where szCRID like '%%%s' and $table.hsvc = '%s' + " $crid $svc] if {[llength $res] > 0} { return [rsv new [lindex $res 0]] @@ -182,3 +198,13 @@ proc {rsv cleanup} {} { catch {$::rsvdb close} } +proc {rsv commit} {} { + $::rsvdb query {begin transaction} + foreach rec [rsv list pending] { + $rec clear_ulslot + $rec insert TBL_RESERVATION + } + $::rsvdb query {delete from pending} + $::rsvdb query {commit transaction} +} +