Compare commits

...

14 Commits

Author SHA1 Message Date
hummypkg
f6bf03691d use findhsvc class
git-svn-id: file:///root/webif/svn/humax/pkg/src/webif/trunk@352 2a923420-c742-0410-a762-8d5b09965624
2011-09-03 23:26:54 +00:00
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
hummypkg
3559a430ab add epg -day and rsv commit when necessary
git-svn-id: file:///root/webif/svn/humax/pkg/src/webif/trunk@305 2a923420-c742-0410-a762-8d5b09965624
2011-08-25 20:30:13 +00:00
hummypkg
945c6d1b4b use pending table for scheduling
git-svn-id: file:///root/webif/svn/humax/pkg/src/webif/trunk@296 2a923420-c742-0410-a762-8d5b09965624
2011-08-22 20:55:06 +00:00
hummypkg
81c3ef4f73 support same directory symlinks
git-svn-id: file:///root/webif/svn/humax/pkg/src/webif/trunk@294 2a923420-c742-0410-a762-8d5b09965624
2011-08-20 21:30:43 +00:00
hummypkg
2c61281b09 skip non-directory links
git-svn-id: file:///root/webif/svn/humax/pkg/src/webif/trunk@292 2a923420-c742-0410-a762-8d5b09965624
2011-08-20 20:50:40 +00:00
hummypkg
d5b27acd46 fix minor file browser bugs
git-svn-id: file:///root/webif/svn/humax/pkg/src/webif/trunk@291 2a923420-c742-0410-a762-8d5b09965624
2011-08-20 20:45:23 +00:00
hummypkg
767021557f download decrypted fiels
git-svn-id: file:///root/webif/svn/humax/pkg/src/webif/trunk@285 2a923420-c742-0410-a762-8d5b09965624
2011-08-13 00:18:42 +00:00
22 changed files with 712 additions and 202 deletions

View File

@@ -1,11 +1,11 @@
Package: webif
Priority: optional
Section: web
Version: 0.6.3-3
Version: 0.6.8
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

@@ -3,7 +3,7 @@
package require cgi
source /mod/var/mongoose/lib/setup
require rsv.class
require rsv.class findhsvc
set dir /mod/var/backup
@@ -33,24 +33,6 @@ if {[catch { set fd [open $ffile r] } msg]} {
exit
}
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
}
}
puts "Restoring scheduled events..."
$rsvdb query {begin transaction;}
@@ -111,7 +93,7 @@ foreach line $data {
set group [lindex $vals 1]
set type [lindex $vals 2]
set chan [lindex $vals 3]
set hsvc [findhsvc $chan]
set hsvc [get_channel_attr $chan]
if {$grp != $group} {
set grp $group

View File

@@ -5,6 +5,8 @@ package require sqlite3
source /mod/var/mongoose/lib/setup
require ts.class
#puts "Content-Type: text/plain\r\n\r\n"
cgi_input
#cgi_dump
@@ -21,8 +23,7 @@ if {[file exists $dmsfile]} {
set muri [$db query "
select tblresource.mimetype, contenturi
from tblresource join tblmedia using (mediaid)
where localurl = '$rfile'
"]
where localurl = '%s'" $rfile]
if {$muri != ""} {
set rec [lindex $muri 0]
set xuri [lindex $rec 3]

View File

@@ -2,6 +2,7 @@
package require cgi
#puts "Content-Type: text/plain"
puts "Content-Type: application/json"
puts ""
@@ -18,9 +19,28 @@ puts "{"
foreach line [split [exec /mod/bin/busybox/du -h "$dir/"] "\n"] {
set fields [split $line "\t"]
set size [lindex $fields 0]
set node [lindex [split [lindex $fields 1] /] end]
set node [file tail [lindex $fields 1]]
# set node [lindex [split [lindex $fields 1] /] end]
puts "\"$node\" : \"$size\","
}
# Handle symbolic links.
foreach file [glob -nocomplain "$dir/*"] {
if {[catch {set lk [file readlink $file]}]} continue
if {![string match "/*" $lk]} { set lk "$dir/$lk" }
if {![file isdirectory $lk]} continue
foreach line [split [exec /mod/bin/busybox/du -h "$lk"] "\n"] {
set fields [split $line "\t"]
if {[lindex $fields 1] eq $lk} {
set node [file tail $file]
set size [lindex $fields 0]
puts "\"$node\" : \"@$size\","
}
}
}
puts "\"dummy\" : \"\""
puts "}"

View File

@@ -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

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

@@ -1,9 +1,56 @@
#!/mod/bin/jimsh
package require cgi
source /mod/var/mongoose/lib/setup
require rsv.class system.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."
system reboot
exit
}
file delete /tmp/.restartpending
header
# Commit pending reservations on older mod versions.
if {![file exists /sbin/rsvsync] && ![file exists /mod/boot/rsvsync]} {
rsv commit
}
puts {
<link href=/css/jquery.progressbar.css rel=stylesheet type=text/css />
<script type="text/javascript" src="/js/jquery.progressbar.js"></script>
<script type=text/javascript>
var handle = 0;
var pct = 0;
function update()
{
$('#progressbar').reportprogress(++pct);
if (pct == 100)
{
clearInterval(handle);
pct = 0;
window.location = '/';
}
}
$(document).ready(function() {
$('#progressbar').reportprogress(0);
handle = setInterval("update()", 300);
$.get('/cgi-bin/restart.jim?now=yes');
});
</script>
Please wait while the Humax restarts...<br>
<div id=progressbar></div>
}
footer

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>"

View File

@@ -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;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

View File

@@ -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 class='progress'></div>");
div.append("<div class='text'>&nbsp;</div>");
$("<span class='text'>&nbsp;</span>").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);

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,15 +33,8 @@ 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?'))
{
$.ajax({
url: '/cgi-bin/restart.jim',
success: function() {
window.location.reload(true);
}
});
}
if (confirm('Are you sure you wish to perform a restart now?'))
window.location = '/cgi-bin/restart.jim';
});
</script>
}

View File

@@ -3,9 +3,8 @@
source /mod/var/mongoose/lib/setup
require altrow rsv.class progressbar
set events [rsv list]
puts {
<div id=dialogue></div>
<script type=text/javascript>
$.tablesorter.addParser({
@@ -28,7 +27,7 @@ $.tablesorter.addParser({
});
$(document).ready(function() {
$('#schedtable').tablesorter({
$('table.tablesorter').tablesorter({
headers: {
1: { sorter: false },
3: { sorter: 'programme' },
@@ -40,58 +39,108 @@ $(document).ready(function() {
}
});
});
</script>
<table id=schedtable class="borders tablesorter">
<thead>
<tr>
<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>
$(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>
}
foreach event $events {
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>
</tr>
</thead>
<tbody>
}
}
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>"
@@ -109,7 +158,10 @@ foreach event $events {
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]
@@ -136,41 +188,40 @@ foreach event $events {
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>"
}
puts "</tbody></table>"
puts "<font class=footnote>Click on the CRID to view episodes.</font>"
proc eventfooter {} {
puts "</tbody></table>"
}
set events [rsv list pending]
if {[llength $events] > 0} {
puts "<h2>Pending Schedule Events</h2>"
eventheader pending
foreach event $events {eventrow $event pending}
eventfooter
puts {
<small>
<button onclick="window.location='/cgi-bin/db.jim?db=rsvp.db&tab=pending';">
Raw database view
</button>
</small>
}
}
puts "<h2>Scheduled Events</h2>"
set events [rsv list]
eventheader
foreach event $events {eventrow $event}
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)
@@ -291,6 +291,7 @@ proc {epg exec} {mode args} {
-service { lappend cmd -S $args($arg) }
-event { lappend cmd -E $args($arg) }
-time { lappend cmd -@ $args($arg) }
-day { lappend cmd -/ $args($arg) }
-extra { set extra $args($arg) }
default { error "Invalid option, $arg" }
}

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

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

View File

@@ -6,7 +6,20 @@ 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 {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
@@ -38,6 +51,11 @@ class rsv {
szSvcName {}
usLcn 0
sort 0
action 0
}
rsv method clear_ulslot {} {
set ulslot -1
}
rsv method name {} {
@@ -50,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 ---" }
}
}
@@ -62,16 +80,54 @@ rsv method channel_name {} {
return [string range $szSvcName 1 end]
}
rsv method icon {} {
set rsvicon ""
switch $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 {} {
switch $ucRecKind {
2 { set RKIcon "178_1_26_Icon_Split.png" }
4 { set RKIcon "175_1_11_Series_Record.png" }
default {
switch $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 = $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]
@@ -81,25 +137,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]]
@@ -109,6 +167,11 @@ rsv method insert {} {
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.
@@ -117,7 +180,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 +189,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 +209,67 @@ 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]]
}
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]]
@@ -182,3 +281,15 @@ proc {rsv cleanup} {} {
catch {$::rsvdb close}
}
proc {rsv commit} {} {
$::rsvdb query {begin transaction}
foreach rec [rsv list pending] {
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]
}