re-implemented package management. Initial suppor for remote scheduling
git-svn-id: file:///root/webif/svn/humax/pkg/src/webif/trunk@265 2a923420-c742-0410-a762-8d5b09965624
This commit is contained in:
parent
2a224c1055
commit
ded9495595
@ -6,7 +6,7 @@ source /mod/var/mongoose/lib/setup
|
||||
set dir /mod/var/backup
|
||||
|
||||
puts "Content-Type: text/html"
|
||||
puts "Pragma: nocache"
|
||||
puts "Pragma: no-cache"
|
||||
puts "Expires: Thu, 01 Jan 1970 00:00:00 GMT"
|
||||
puts ""
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
package require cgi
|
||||
|
||||
puts "Content-Type: text/html"
|
||||
puts "Pragma: nocache"
|
||||
puts "Pragma: no-cache"
|
||||
puts "Expires: Thu, 01 Jan 1970 00:00:00 GMT"
|
||||
puts ""
|
||||
|
||||
|
45
var/mongoose/cgi-bin/db.jim
Executable file
45
var/mongoose/cgi-bin/db.jim
Executable file
@ -0,0 +1,45 @@
|
||||
#!/mod/bin/jimsh
|
||||
|
||||
package require sqlite3
|
||||
source /mod/var/mongoose/lib/setup
|
||||
require altrow
|
||||
|
||||
proc db_info {db_file} {
|
||||
if {![file exists $db_file]} { return }
|
||||
set db [sqlite3.open $db_file]
|
||||
set tables [$db query {SELECT name FROM sqlite_master WHERE type='table' ORDER BY name}]
|
||||
|
||||
puts "<h1>$db_file</h1>"
|
||||
|
||||
foreach table $tables {
|
||||
set table_name [lindex $table 1]
|
||||
set columns [$db query "pragma table_info($table_name)"]
|
||||
set datas [$db query "SELECT * FROM $table_name"]
|
||||
|
||||
puts "<h2>$table_name</h2>"
|
||||
puts "<table>"
|
||||
puts " <tr>"
|
||||
foreach column $columns {
|
||||
puts " <th>[lindex $column 3]</th>"
|
||||
}
|
||||
puts " </tr>"
|
||||
foreach data $datas {
|
||||
altrow
|
||||
|
||||
for {set i 1} {$i < [llength $data]} {incr i 2} {
|
||||
puts " <td>[lindex $data $i]</td>"
|
||||
}
|
||||
puts " </tr>"
|
||||
}
|
||||
puts "</table>"
|
||||
}
|
||||
|
||||
$db close
|
||||
}
|
||||
|
||||
puts {<style type="text/css">table, td, th {border-collapse:collapse; border:1px solid black;}</style>}
|
||||
db_info /var/lib/humaxtv/rsv.db
|
||||
db_info /var/lib/humaxtv/setup.db
|
||||
db_info /var/lib/humaxtv/channel.db
|
||||
#db_info /mnt/hd2/dms_cds.db
|
||||
|
@ -35,7 +35,13 @@ puts "
|
||||
<td>[clock format [$record get start] -format {%c %Z}]</td>
|
||||
</tr><tr>
|
||||
<th>Duration</th>
|
||||
<td>[clock format [$record get duration] -format %T]</td>
|
||||
<td>[clock format [$record get duration] -format %T]
|
||||
"
|
||||
if {[$record showing]} {
|
||||
puts [progressbar [$record percent]]
|
||||
}
|
||||
puts "
|
||||
</td>
|
||||
</tr><tr>
|
||||
<th>Type</th>
|
||||
<td>[$record get content_type] ([$record get content_code])</td>
|
||||
@ -103,6 +109,8 @@ puts "
|
||||
</a>
|
||||
"
|
||||
|
||||
puts "<div id=epginfo_extra class=footnote></div>"
|
||||
|
||||
epg cleanup
|
||||
if {! [dict exists $_cgi bare]} { footer }
|
||||
|
||||
|
73
var/mongoose/cgi-bin/epg_schedule.jim
Executable file
73
var/mongoose/cgi-bin/epg_schedule.jim
Executable file
@ -0,0 +1,73 @@
|
||||
#!/mod/bin/jimsh
|
||||
|
||||
package require cgi
|
||||
source /mod/var/mongoose/lib/setup
|
||||
require epg.class
|
||||
|
||||
puts "Content-Type: text/html"
|
||||
puts ""
|
||||
|
||||
cgi_input
|
||||
#cgi_dump
|
||||
|
||||
#set _cgi(service) 4351
|
||||
#set _cgi(event) 41795
|
||||
#set _cgi(type) 1
|
||||
|
||||
if {![dict exists $_cgi service] || ![dict exists $_cgi event]} {
|
||||
puts "Error, insufficient parameters passed."
|
||||
exit
|
||||
}
|
||||
|
||||
set service $_cgi(service)
|
||||
set event $_cgi(event)
|
||||
set type 1
|
||||
if {[dict exists $_cgi type]} { set type $_cgi(type) }
|
||||
|
||||
set event [lindex [epg fetch dump -service $service -event $event] 0]
|
||||
if {$event eq ""} {
|
||||
puts "Error, cannot find event to schedule."
|
||||
exit
|
||||
}
|
||||
if {[$event percent] > 0} {
|
||||
puts "Error, cannot record programme which has already started showing."
|
||||
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
|
||||
|
||||
if {$type == 1} {
|
||||
# Event
|
||||
set args(ucCRIDType) 49
|
||||
set args(ucRecKind) 1
|
||||
set args(szCRID) "[$event get channel_crid][$event get event_crid]"
|
||||
set args(szEventToRecord) "1$args(szCRID)|"
|
||||
} else {
|
||||
# Series
|
||||
set args(ucCRIDType) 50
|
||||
set args(ucRecKind) 4
|
||||
set args(szCRID) "[$event get channel_crid][$event get series_crid]"
|
||||
set args(szFPBRecPath) "$args(szevtname)"
|
||||
}
|
||||
|
||||
set msg ""
|
||||
#set msg "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]
|
||||
}
|
||||
|
||||
epg cleanup
|
||||
|
@ -54,6 +54,7 @@ puts {
|
||||
set i 0
|
||||
foreach record $records {
|
||||
altrow
|
||||
$record get_channel_info
|
||||
if {[$record showing]} {
|
||||
puts "<td><img src=/images/111_1_00_Cursor_2R_Arrow.png></td>"
|
||||
} else { puts "<td></td>" }
|
||||
|
@ -1,8 +1,11 @@
|
||||
#!/mod/bin/jimsh
|
||||
|
||||
package require cgi
|
||||
source /mod/var/mongoose/lib/setup
|
||||
require pkg.class
|
||||
|
||||
puts "Content-Type: text/html"
|
||||
puts "Transfer-Encoding: chunked"
|
||||
puts ""
|
||||
|
||||
cgi_input
|
||||
@ -10,9 +13,33 @@ cgi_input
|
||||
|
||||
#set _cgi(cmd) {remove binutils}
|
||||
|
||||
if {![dict exists $_cgi cmd]} { set _cgi(cmd) status }
|
||||
if {![dict exists $_cgi cmd]} { set _cgi(cmd) update }
|
||||
|
||||
set cmd [dict get $_cgi cmd]
|
||||
|
||||
puts [exec /mod/var/mongoose/lib/opkg {*}$cmd]
|
||||
proc chunk {chk} {
|
||||
puts -nonewline [format "%x\r\n" [string length $chk]]
|
||||
puts -nonewline "$chk\r\n"
|
||||
flush stdout
|
||||
}
|
||||
|
||||
# Kick the browser into life...
|
||||
chunk [string range [format "%301d" 0] 1 end-1]
|
||||
|
||||
#puts [exec /mod/var/mongoose/lib/opkg {*}$cmd]
|
||||
set bcmd "|/mod/var/mongoose/lib/opkg $cmd"
|
||||
set fd [open $bcmd r]
|
||||
while {[gets $fd line] >= 0} {
|
||||
chunk "$line\r\n"
|
||||
}
|
||||
close $fd
|
||||
|
||||
if {$cmd eq "update"} {
|
||||
chunk "Updating package meta information\r\n"
|
||||
pkg fetchmeta
|
||||
chunk "Done.\r\n"
|
||||
}
|
||||
|
||||
chunk ""
|
||||
puts "\r\n"
|
||||
|
||||
|
98
var/mongoose/cgi-bin/pkg.jim
Executable file
98
var/mongoose/cgi-bin/pkg.jim
Executable file
@ -0,0 +1,98 @@
|
||||
#!/mod/bin/jimsh
|
||||
|
||||
package require cgi
|
||||
source /mod/var/mongoose/lib/setup
|
||||
require settings.class pkg.class altrow
|
||||
|
||||
if {[[settings] pkgdev]} { set filter 0 } else { set filter 1 }
|
||||
|
||||
puts "Content-Type: text/html"
|
||||
puts "Pragma: no-cache"
|
||||
puts "Expires: Thu, 01 Jan 1970 00:00:00 GMT"
|
||||
puts ""
|
||||
|
||||
cgi_input
|
||||
#cgi_dump
|
||||
if {![dict exists $_cgi type]} { set _cgi(type) avail }
|
||||
|
||||
proc pkgrow {pkg} {
|
||||
set name [$pkg get name]
|
||||
altrow
|
||||
puts "
|
||||
<td nowrap>$name</td>
|
||||
"
|
||||
|
||||
if {$::type eq "avail"} {
|
||||
puts "<td nowrap>[$pkg get latest]</td>"
|
||||
} else {
|
||||
puts "<td nowrap>[$pkg get installed]</td>"
|
||||
}
|
||||
|
||||
if {$::type eq "upgr"} {
|
||||
puts "<td nowrap>[$pkg get latest]</td>"
|
||||
}
|
||||
|
||||
if {[dict exists $::pkgmeta $name]} {
|
||||
puts "<td>$::pkgmeta($name)</td>"
|
||||
} else {
|
||||
puts "<td>[$pkg get descr]</td>"
|
||||
}
|
||||
|
||||
if {![$pkg is installed]} {
|
||||
set type Install
|
||||
} elseif {$::type eq "upgr" && [$pkg is upgradable]} {
|
||||
set type Upgrade
|
||||
} else {
|
||||
set type Remove
|
||||
}
|
||||
|
||||
puts "<td align=center><small><button id=\"[$pkg get name]\"
|
||||
action=[string tolower $type]
|
||||
class=[string tolower $type]>$type</button></small></td>"
|
||||
|
||||
puts "</tr>"
|
||||
}
|
||||
|
||||
pkg loadmeta
|
||||
|
||||
set type $_cgi(type)
|
||||
|
||||
set pkgs [pkg $type]
|
||||
|
||||
if {[llength $pkgs] > 0} {
|
||||
puts "<table><tr><th>Package</th>"
|
||||
|
||||
if {$type eq "avail"} {
|
||||
puts "<th>Available</th>"
|
||||
} else {
|
||||
puts "<th>Installed</th>"
|
||||
}
|
||||
|
||||
if {$type eq "upgr"} {
|
||||
puts "<th>Avail</th>"
|
||||
}
|
||||
|
||||
puts "
|
||||
<th>Description</th>
|
||||
<th> Action </th>
|
||||
</tr>
|
||||
"
|
||||
|
||||
foreach pkg $pkgs {
|
||||
if {$filter && ![dict exists $::pkgmeta $pkg]} { continue }
|
||||
pkgrow [pkg load $pkg]
|
||||
}
|
||||
puts "</table>"
|
||||
if {$filter} {
|
||||
puts "<font class=footnote>This is a filtered package list. To show all packages, enable the <i>Show development and advanced packages</i> in the settings screen.</font>"
|
||||
}
|
||||
} else {
|
||||
puts "<i>No packages "
|
||||
switch $type {
|
||||
inst { puts "are installed." }
|
||||
upgr { puts "are available for upgrade." }
|
||||
avail { puts "are available for installation." }
|
||||
}
|
||||
puts "</i>"
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ set settings [settings new]
|
||||
set hostname [$settings hostname]
|
||||
set smtp_server [$settings smtp_server]
|
||||
set channel_group [$settings channel_group]
|
||||
set pkgdev [$settings pkgdev]
|
||||
|
||||
# Handle updates
|
||||
|
||||
@ -50,6 +51,10 @@ proc handle_str_update {var old {text "Value"}} {
|
||||
handle_str_update hostname $hostname Hostname
|
||||
_handle_update ascii smtp_server $smtp_server "SMTP Server"
|
||||
handle_int_update channel_group $channel_group "Channel Group"
|
||||
if {[dict exists $_cgi pkgdevoff] && ![dict exists $_cgi pkgdev]} {
|
||||
set _cgi(pkgdev) 0
|
||||
}
|
||||
handle_int_update pkgdev $pkgdev "Development Package Display"
|
||||
|
||||
header
|
||||
|
||||
@ -76,6 +81,9 @@ puts {
|
||||
}
|
||||
|
||||
puts "
|
||||
<link href=/css/iphone-style-checkboxes.css rel=stylesheet type=text/css />
|
||||
<script type=\"text/javascript\" src=\"/js/iphone-style-checkboxes.js\">
|
||||
</script>
|
||||
<fieldset style=\"display: inline\">
|
||||
<legend>
|
||||
General Settings
|
||||
@ -155,6 +163,34 @@ puts "
|
||||
</tr>
|
||||
"
|
||||
|
||||
puts "
|
||||
</table>
|
||||
</fieldset>
|
||||
<br><br>
|
||||
<fieldset style=\"display: inline\">
|
||||
<legend> Advanced Settings </legend>
|
||||
<table>
|
||||
"
|
||||
|
||||
puts "
|
||||
<tr>
|
||||
<form class=auto id=pkgdev method=get action=$env(REQUEST_URI)>
|
||||
<th class=key>Show development and advanced packages?</th>
|
||||
<td><input name=pkgdevoff value=0 type=hidden>
|
||||
<input name=pkgdev id=pkgdev value=1 type=checkbox
|
||||
"
|
||||
if {$pkgdev} { puts " checked" }
|
||||
puts {
|
||||
>
|
||||
<small>
|
||||
<input id=pkgdev_submit value="save" type=submit>
|
||||
</small>
|
||||
<div id=pkgdev_output></div>
|
||||
</td>
|
||||
</form>
|
||||
</tr>
|
||||
}
|
||||
|
||||
puts "
|
||||
</table>
|
||||
</fieldset>
|
||||
|
@ -60,7 +60,7 @@ $(document).ready(function() {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style="clear: both">
|
||||
<div style="clear: both; padding-top: 1em">
|
||||
|
||||
<div style="float: left">
|
||||
<center>
|
||||
@ -77,11 +77,11 @@ $(document).ready(function() {
|
||||
|
||||
<div style="float: left">
|
||||
<center>
|
||||
<a href=/packages.shtml>
|
||||
<a href=/pkg.shtml>
|
||||
<img src=/img/packages.jpg border=0 width=217 height=228>
|
||||
</a>
|
||||
<br>
|
||||
<a href=/packages.shtml>
|
||||
<a href=/pkg.shtml>
|
||||
<b>Package Management</b>
|
||||
</a>
|
||||
<br>
|
||||
|
@ -1,33 +0,0 @@
|
||||
|
||||
$(document).ready(function() {
|
||||
$('button').button();
|
||||
|
||||
var $dialog = $('#dialogue').dialog({
|
||||
title: "Package Management Results",
|
||||
modal: false, autoOpen: false,
|
||||
height: 500, width: 700,
|
||||
show: 'scale', hide: 'fade',
|
||||
draggable: true, resizable: true,
|
||||
buttons: { "Close":
|
||||
function() {$(this).dialog('close');}},
|
||||
close: function(e,u) { window.location.reload(true); }
|
||||
});
|
||||
|
||||
var opkg = '/cgi-bin/opkg.jim?cmd=';
|
||||
|
||||
$('#opkgupdate').click(function() {
|
||||
$('#result_txt').load(opkg + 'update');
|
||||
$('#results').show('slow');
|
||||
});
|
||||
|
||||
$('button.remove, button.install, button.upgrade').click(function() {
|
||||
$('#dspinner').show();
|
||||
$('#dresults').load(
|
||||
opkg + encodeURIComponent(
|
||||
$(this).attr('action') + ' ' + $(this).attr('id')
|
||||
),
|
||||
function() { $('#dspinner').hide('slow') });
|
||||
$dialog.dialog('open');
|
||||
});
|
||||
});
|
||||
|
@ -6,8 +6,6 @@ puts {
|
||||
source /mod/var/mongoose/include/model.jim
|
||||
puts {
|
||||
</title>
|
||||
<meta http-equiv="expires" value="Thu, 01 Jan 1970 00:00:00 GMT" />
|
||||
<meta http-equiv="pragma" content="no-cache" />
|
||||
<link rel="shortcut icon" href=/img/favicon.ico />
|
||||
<link href=/css/style.css rel=stylesheet type=text/css />
|
||||
<link type="text/css" href="/css/jquery-ui.css" rel="Stylesheet" />
|
||||
|
@ -1,21 +0,0 @@
|
||||
<!--#include virtual="/lib/header.shtml" -->
|
||||
|
||||
<h1 class=vam>Package Management
|
||||
<button class=vam id=opkgupdate>Update package list from Internet</button>
|
||||
</h1>
|
||||
<div id=results class=shadowbox style="width: 90%; display: none; margin: 1 0 1em 0">
|
||||
<div>
|
||||
<pre id=result_txt>
|
||||
Results...
|
||||
</pre>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id=dialogue style="display: none; align: center">
|
||||
<pre id=dresults></pre>
|
||||
<div id=dspinner><img src=/img/loading.gif>Processing...</div>
|
||||
</div>
|
||||
|
||||
<!--#exec cmd="/mod/var/mongoose/include/packages.jim" -->
|
||||
|
||||
<!--#include virtual="/lib/footer.shtml" -->
|
111
var/mongoose/html/pkg.shtml
Normal file
111
var/mongoose/html/pkg.shtml
Normal file
@ -0,0 +1,111 @@
|
||||
<!--#include virtual="/lib/header.shtml" -->
|
||||
|
||||
<style type=text/css>
|
||||
button.install
|
||||
{
|
||||
display: none;
|
||||
background-image: none;
|
||||
background: #ccff99;
|
||||
}
|
||||
button.remove
|
||||
{
|
||||
display: none;
|
||||
background-image: none;
|
||||
background: #ff6666;
|
||||
}
|
||||
button.upgrade
|
||||
{
|
||||
display: none;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class=va style="padding: 0 0 1em 0">
|
||||
<h1 style="display: inline" class=va>Package Management</h1>
|
||||
<small>
|
||||
<button class=va id=opkgupdate style="display: none">
|
||||
Update package list from Internet
|
||||
</button>
|
||||
</small>
|
||||
</div>
|
||||
|
||||
<div id=results class=shadowbox
|
||||
style="width: 90%; display: none; margin: 1 0 1em 0">
|
||||
<div>
|
||||
<pre id=result_txt>
|
||||
Updating package list...
|
||||
</pre>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id=dialogue style="display: none; align: center">
|
||||
<pre id=dresults></pre>
|
||||
<div id=dspinner><img src=/img/loading.gif>Processing request...</div>
|
||||
</div>
|
||||
|
||||
<script type=text/javascript>
|
||||
|
||||
var opkg = '/cgi-bin/opkg.jim?cmd=';
|
||||
|
||||
$(document).ready(function() {
|
||||
$('#opkgupdate').button().show('slow');
|
||||
|
||||
$('#pkgtabs').tabs({load: setup_buttons});
|
||||
|
||||
var $dialog = $('#dialogue').dialog({
|
||||
title: "Package Management Results",
|
||||
modal: false, autoOpen: false,
|
||||
height: 500, width: 700,
|
||||
show: 'scale', hide: 'fade',
|
||||
draggable: true, resizable: true,
|
||||
buttons: { "Close":
|
||||
function() {$(this).dialog('close');}},
|
||||
close: function(e,u) { window.location.reload(true); }
|
||||
});
|
||||
|
||||
function setup_buttons()
|
||||
{
|
||||
$('button.remove, button.install, button.upgrade')
|
||||
.button()
|
||||
.click(function() {
|
||||
if ($(this).attr('action') == 'remove' &&
|
||||
!confirm('Please confirm removal of the ' +
|
||||
$(this).attr('id') + ' package.'))
|
||||
return;
|
||||
$('#dspinner').show();
|
||||
$('#dresults').load(opkg + encodeURIComponent(
|
||||
$(this).attr('action') + ' ' + $(this).attr('id')),
|
||||
function() { $('#dspinner').hide('slow') });
|
||||
$dialog.dialog('open');
|
||||
}).fadeIn('slow');
|
||||
}
|
||||
|
||||
$('#opkgupdate').click(function() {
|
||||
$('#result_txt').load(opkg + 'update', function() {
|
||||
$('#results').delay(3000).slideUp('slow');
|
||||
});
|
||||
$('#results').slideDown('slow');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<div id=pkgtabs>
|
||||
<ul>
|
||||
<li>
|
||||
<a href=/cgi-bin/pkg.jim?type=inst>
|
||||
<span>Installed</span>
|
||||
</a>
|
||||
</li><li>
|
||||
<a href=/cgi-bin/pkg.jim?type=upgr>
|
||||
<span>Upgrades</span>
|
||||
</a>
|
||||
</li><li>
|
||||
<a href=/cgi-bin/pkg.jim?type=avail>
|
||||
<span>Available</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<!--#include virtual="/lib/footer.shtml" -->
|
@ -6,7 +6,7 @@ if {[os.gethostname] eq "hosting"} {
|
||||
set perc "10"
|
||||
} else {
|
||||
foreach df [split [exec df -h 2>>/dev/null] "\n\r"] {
|
||||
if [string match *sd*2* $df] {
|
||||
if [string match *sd?2* $df] {
|
||||
regsub -all -- {[[:space:]]+} $df " " df
|
||||
set fields [split $df]
|
||||
set size [lindex $fields 1]
|
||||
|
@ -1,59 +0,0 @@
|
||||
#!/mod/bin/jimsh
|
||||
|
||||
source /mod/var/mongoose/lib/setup
|
||||
require pkg.class
|
||||
|
||||
puts {
|
||||
|
||||
<style type=text/css>
|
||||
.ui-button, .ui-button-text { padding: 0; font-size: 12px; }
|
||||
</style>
|
||||
|
||||
<script type=text/javascript src=/js/packages.js></script>
|
||||
|
||||
<table class=borders>
|
||||
<tr>
|
||||
<th>Package</th>
|
||||
<th>Installed</th>
|
||||
<th>Avail</th>
|
||||
<th>Description</th>
|
||||
</tr>
|
||||
|
||||
}
|
||||
|
||||
set avail [pkg avail]
|
||||
foreach name [lsort [array names avail]] {
|
||||
set pkg [pkg load $name $avail($name)]
|
||||
|
||||
if {![$pkg is installed]} {
|
||||
puts "<tr>"
|
||||
} elseif {[$pkg is upgradable]} {
|
||||
puts "<tr class=yellowshade>"
|
||||
} else {
|
||||
puts "<tr class=greenshade>"
|
||||
}
|
||||
|
||||
puts "
|
||||
<td>$name</td>
|
||||
<td>[$pkg get installed]</td>
|
||||
<td>[$pkg get latest]</td>
|
||||
<td>[$pkg get descr]</td>
|
||||
"
|
||||
|
||||
if {![$pkg is installed]} {
|
||||
set type Install
|
||||
} elseif {[$pkg is upgradable]} {
|
||||
set type Upgrade
|
||||
} else {
|
||||
set type Remove
|
||||
}
|
||||
|
||||
puts "<td align=center><button id=\"$name\"
|
||||
action=[string tolower $type]
|
||||
class=[string tolower $type]>$type</button></td>"
|
||||
|
||||
puts "</tr>"
|
||||
}
|
||||
|
||||
puts "</table>"
|
||||
|
46
var/mongoose/include/pkg.jim
Executable file
46
var/mongoose/include/pkg.jim
Executable file
@ -0,0 +1,46 @@
|
||||
#!/mod/bin/jimsh
|
||||
|
||||
source /mod/var/mongoose/lib/setup
|
||||
|
||||
puts {
|
||||
<script type=text/javascript src=/js/packages.js></script>
|
||||
|
||||
<style type=text/css>
|
||||
button.install
|
||||
{
|
||||
display: none;
|
||||
background-image: none;
|
||||
background: #ccff99;
|
||||
}
|
||||
button.remove
|
||||
{
|
||||
display: none;
|
||||
background-image: none;
|
||||
background: #ff6666;
|
||||
}
|
||||
button.upgrade
|
||||
{
|
||||
display: none;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div id=pkgtabs>
|
||||
<ul>
|
||||
<li>
|
||||
<a href=/cgi-bin/pkg.jim?type=inst>
|
||||
<span>Installed</span>
|
||||
</a>
|
||||
</li><li>
|
||||
<a href=/cgi-bin/pkg.jim?type=upgr>
|
||||
<span>Upgrades</span>
|
||||
</a>
|
||||
</li><li>
|
||||
<a href=/cgi-bin/pkg.jim?type=avail>
|
||||
<span>Available</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
}
|
||||
|
||||
|
@ -2,9 +2,8 @@ source /mod/var/mongoose/lib/setup
|
||||
|
||||
if {![exists -proc class ]} { package require oo }
|
||||
if {![exists -proc sqlite3.open ]} { package require sqlite3 }
|
||||
if {![exists -proc settings ]} { require settings.class }
|
||||
|
||||
require progressbar
|
||||
require settings.class progressbar rsv.class
|
||||
|
||||
set ::channeldb 0
|
||||
catch { set ::channeldb [sqlite3.open /var/lib/humaxtv/channel.db] }
|
||||
@ -15,6 +14,8 @@ if {![file exists $::epgpath] && [file exists $::hdepgpath]} {
|
||||
set ::epgpath $::hdepgpath
|
||||
}
|
||||
|
||||
set ::rsvlookup [rsv lookuptab]
|
||||
|
||||
# * service_id, event_id, start, duration, encrypted, name, text
|
||||
# * warning, content code, content type,
|
||||
# * event CRID, series CRID, rec CRID
|
||||
@ -37,6 +38,10 @@ class epg {
|
||||
channel_num 0
|
||||
channel_name ""
|
||||
channel_crid ""
|
||||
channel_hsvc 0
|
||||
|
||||
sched_type 0
|
||||
rsv 0
|
||||
}
|
||||
|
||||
epg method _parse {line} {
|
||||
@ -82,7 +87,7 @@ epg method remaining {} {
|
||||
|
||||
epg method type_icon {} {
|
||||
set img ""
|
||||
switch -- [$self get content_code] {
|
||||
switch -- $content_code {
|
||||
1 { set img "Movie" }
|
||||
2 { set img "News" }
|
||||
3 { set img "Show" }
|
||||
@ -110,7 +115,7 @@ proc {epg channelicon} {name {width 0} {style ""}} {
|
||||
}
|
||||
|
||||
epg method channel_icon {{width 0} {style ""}} {
|
||||
set str "<img src=\"/img/channels/[$self get channel_name].png\"";
|
||||
set str "<img src=\"/img/channels/$channel_name.png\"";
|
||||
if {$width > 0} { append str " width=$width" }
|
||||
if {$style ne ""} { append str " style=\"$style\" }
|
||||
append str " alt=\"\">"
|
||||
@ -122,58 +127,90 @@ epg method get_channel_info {} {
|
||||
|
||||
if {!$channel_num && $channeldb != ""} {
|
||||
set chan [lindex [$channeldb query {
|
||||
select szSvcName, usLcn, aucDefaultAuthority
|
||||
select szSvcName, usLcn, aucDefaultAuthority, hsvc
|
||||
from TBL_SVC
|
||||
where usSvcId = %s} "[$self get service_id]"
|
||||
where usSvcId = %s} $service_id
|
||||
] 0]
|
||||
if {[dict exists $chan usLcn]} {
|
||||
set channel_num $chan(usLcn)
|
||||
set channel_name [string range $chan(szSvcName) 1 end]
|
||||
set channel_crid [string toupper $chan(aucDefaultAuthority)]
|
||||
set channel_hsvc $chan(hSvc)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
epg method get_rsv {} {
|
||||
if {$hsvc == 0} { $self get_channel_info }
|
||||
if {$hsvc == 0} { return }
|
||||
|
||||
if {$rsv == 0 && $event_crid ne ""} {
|
||||
set rsv [rsv entry $event_crid $hsvc]
|
||||
}
|
||||
if {$rsv == 0 && $series_crid ne ""} {
|
||||
set rsv [rsv entry $series_crid $hsvc]
|
||||
}
|
||||
}
|
||||
|
||||
epg method icon_set {{height 0}} {
|
||||
if {$height > 0} { set height "height=$height" } else { set height "" }
|
||||
set icon [$self type_icon]
|
||||
set set ""
|
||||
if {$icon != ""} {
|
||||
lappend set "<img src=$icon $height
|
||||
alt=\"[$self get content_type]\"
|
||||
title=\"[$self get content_type]\">"
|
||||
alt=\"$content_type\" title=\"$content_type\">"
|
||||
}
|
||||
if {[$self get rec_crid] != ""} {
|
||||
|
||||
set sched_type 0
|
||||
if {$event_crid ne "" && "$channel_hsvc$event_crid" in $::rsvlookup} {
|
||||
set sched_type 1
|
||||
lappend set \
|
||||
"<img src=/images/178_1_26_Icon_Recommend.png $height>"
|
||||
"<img src=/images/175_1_11_Reservation_Record.png $height>"
|
||||
} elseif {$series_crid ne "" &&
|
||||
"$channel_hsvc$series_crid" in $::rsvlookup} {
|
||||
set sched_type 2
|
||||
}
|
||||
if {[$self get series_crid] != ""} {
|
||||
|
||||
if {$sched_type == 2} {
|
||||
lappend set \
|
||||
"<img src=/images/175_1_11_Series_Record.png $height>"
|
||||
} elseif {$series_crid ne ""} {
|
||||
lappend set \
|
||||
"<img src=/images/178_1_00_Icon_Serise.png $height>"
|
||||
}
|
||||
|
||||
if {$rec_crid ne ""} {
|
||||
lappend set \
|
||||
"<img src=/images/178_1_26_Icon_Recommend.png $height>"
|
||||
}
|
||||
|
||||
return $set
|
||||
}
|
||||
|
||||
epg method cell {} {
|
||||
set name [$self get name]
|
||||
set text [$self get text]
|
||||
|
||||
set percent [$self percent]
|
||||
|
||||
puts "<td nowrap valign=top title=\"$text\">"
|
||||
|
||||
puts [join [$self icon_set 14] ""]
|
||||
|
||||
if {$series_crid ne ""} {
|
||||
set recopts 2
|
||||
} else {
|
||||
set recopts 1
|
||||
}
|
||||
|
||||
puts "
|
||||
<a class=event href=# xs=[$self get service_id]
|
||||
xe=[$self get event_id]>
|
||||
$name</a>"
|
||||
<a class=event href=# xs=$service_id xe=$event_id
|
||||
sch=$sched_type rec=$recopts>
|
||||
$name</a>
|
||||
"
|
||||
|
||||
puts "<br>"
|
||||
|
||||
puts "<font class=footnote>"
|
||||
puts "[clock format [$self get start] -format %H:%M]"
|
||||
puts " ([clock format [$self get duration] -format %T])"
|
||||
puts "[clock format $start -format %H:%M]"
|
||||
puts " ([clock format $duration -format %T])"
|
||||
if {$percent > 0 && $percent < 100} {
|
||||
puts "<br>[progressbar $percent]"
|
||||
puts "$percent% [clock format [$self elapsed] -format %T] /
|
||||
@ -184,8 +221,8 @@ epg method cell {} {
|
||||
}
|
||||
|
||||
epg method next {} {
|
||||
set tm [expr [$self get start] + [$self get duration] + 60]
|
||||
set nextlist [epg fetch dump -service [$self get service_id] -time $tm]
|
||||
set tm $($start + $duration + 60)
|
||||
set nextlist [epg fetch dump -service $service_id -time $tm]
|
||||
|
||||
if {[llength nextlist] > 0} {
|
||||
return [lindex $nextlist 0]
|
||||
@ -196,9 +233,9 @@ epg method next {} {
|
||||
|
||||
epg method recommended {} {
|
||||
set rec ""
|
||||
if {[$self get rec_crid] != ""} {
|
||||
if {$rec_crid ne ""} {
|
||||
catch { set rec [lindex [
|
||||
epg fetch dump -crid [$self get rec_crid]] 0] }
|
||||
epg fetch dump -crid $rec_crid] 0] }
|
||||
}
|
||||
return $rec
|
||||
}
|
||||
|
@ -2,23 +2,61 @@ puts {
|
||||
<div id=dialogue></div>
|
||||
<script type=text/javascript>
|
||||
$(document).ready(function() {
|
||||
var $buttons1 = {
|
||||
"Close" : function() {$(this).dialog('close');}
|
||||
};
|
||||
var $buttons2 = $.extend(
|
||||
{"Record Programme" : function() {
|
||||
$('#epginfo_extra').load('/cgi-bin/epg_schedule.jim?' +
|
||||
'service=' +
|
||||
encodeURIComponent($('#dialogue').attr('xs')) +
|
||||
'&event=' +
|
||||
encodeURIComponent($('#dialogue').attr('xe')) +
|
||||
'&type=1');
|
||||
$(":button:contains('Record')").fadeOut('slow');
|
||||
}},
|
||||
$buttons1);
|
||||
var $buttons3 = $.extend(
|
||||
{"Record Series" : function() {
|
||||
$('#epginfo_extra').load('/cgi-bin/epg_schedule.jim?' +
|
||||
'service=' +
|
||||
encodeURIComponent($('#dialogue').attr('xs')) +
|
||||
'&event=' +
|
||||
encodeURIComponent($('#dialogue').attr('xe')) +
|
||||
'&type=2');
|
||||
$(":button:contains('Record')").fadeOut('slow');
|
||||
}},
|
||||
$buttons2);
|
||||
|
||||
var $dialog = $('#dialogue').dialog({
|
||||
title: "Programme Details",
|
||||
modal: false, autoOpen: false,
|
||||
height: 500, width: 700,
|
||||
show: 'scale', hide: 'fade',
|
||||
draggable: true, resizable: true,
|
||||
buttons: { "Close":
|
||||
function() {$(this).dialog('close');}},
|
||||
buttons: $buttons1,
|
||||
close: function(e,u) { $('#dialogue').empty().html(
|
||||
'<img src="/img/loading.gif" alt="loading">'); }
|
||||
});
|
||||
$('a.event').click(function(e) {
|
||||
e.preventDefault();
|
||||
var sch = $(this).attr('sch');
|
||||
var rec = $(this).attr('rec');
|
||||
if (sch != 0)
|
||||
$dialog.dialog("option", "buttons", $buttons1);
|
||||
else if (rec == 2)
|
||||
$dialog.dialog("option", "buttons", $buttons3);
|
||||
else if (rec == 1)
|
||||
$dialog.dialog("option", "buttons", $buttons2);
|
||||
else
|
||||
$dialog.dialog("option", "buttons", $buttons1);
|
||||
var url = '/cgi-bin/epg_info.jim?service=' +
|
||||
$(this).attr('xs') + '&event=' +
|
||||
$(this).attr('xe') + '&bare=1';
|
||||
$('#dialogue').load(url);
|
||||
$('#dialogue')
|
||||
.attr('xs', $(this).attr('xs'))
|
||||
.attr('xe', $(this).attr('xe'));
|
||||
$dialog.dialog('open');
|
||||
});
|
||||
});
|
||||
|
@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
|
||||
# stderr is always unbuffered so use that...
|
||||
/bin/opkg "$@" 1>&2
|
||||
/bin/opkg "$@" 2>&1
|
||||
exit 0
|
||||
|
||||
|
@ -3,25 +3,25 @@ if {[expr ! [exists -proc class ]]} { package require oo }
|
||||
|
||||
class pkg {
|
||||
name ""
|
||||
latest ""
|
||||
descr ""
|
||||
installed ""
|
||||
latest ""
|
||||
install_time 0
|
||||
}
|
||||
|
||||
pkg method _load {nm info} {
|
||||
set name $nm
|
||||
set latest [lindex $info 0]
|
||||
set descr [lrange $info 1 end]
|
||||
set ::pkgmeta {}
|
||||
|
||||
foreach line [split [exec /bin/opkg status $name] "\n"] {
|
||||
if {[string match {Version: *} $line]} {
|
||||
set installed [string range $line 9 end]
|
||||
}
|
||||
if {[string match {Installed-Time: } $line]} {
|
||||
set install_time [string range $line 16 end]
|
||||
}
|
||||
}
|
||||
pkg method _load {nm} {
|
||||
set name $nm
|
||||
set info [join [split [exec /bin/opkg list $nm] "\n"] " "]
|
||||
regexp {^([^ ]+) - ([^ ]+) - (.*)$} $info full xname latest descr
|
||||
set info [exec /bin/opkg list-installed $nm]
|
||||
regexp {^([^ ]+) - ([^ ]+)$} $info full xname installed
|
||||
|
||||
return $self
|
||||
}
|
||||
|
||||
proc {pkg load} {nm} {
|
||||
return [[pkg] _load $nm]
|
||||
}
|
||||
|
||||
pkg method is {what} {
|
||||
@ -38,28 +38,19 @@ pkg method is {what} {
|
||||
return 0
|
||||
}
|
||||
|
||||
proc {pkg load} {nm info} {
|
||||
set e [pkg]
|
||||
$e _load $nm $info
|
||||
return $e
|
||||
}
|
||||
|
||||
proc {pkg avail} {} {
|
||||
set inst_pkgs [pkg inst]
|
||||
set avail_pkgs {}
|
||||
foreach pkg [split [exec /bin/opkg list] "\n"] {
|
||||
if [regexp {^ } $pkg] {
|
||||
append descr $pkg
|
||||
} else {
|
||||
if {[regexp {^([^ ]+) - ([^ ]+) - (.*)$} \
|
||||
$pkg full name ver descr] == 0} { continue }
|
||||
}
|
||||
set avail_pkgs($name) [concat $ver "$descr"]
|
||||
#puts "Set: $name = ($ver, $descr)<br>"
|
||||
if [regexp {^ } $pkg] { continue }
|
||||
if {[regexp {^([^ ]+)} $pkg name] == 0} { continue }
|
||||
if {$name ni $inst_pkgs} { lappend avail_pkgs $name }
|
||||
#puts "New: $name<br>"
|
||||
}
|
||||
return $avail_pkgs
|
||||
}
|
||||
|
||||
proc {pkg installed} {} {
|
||||
proc {pkg inst} {} {
|
||||
# Build a list of installed packages - just the names
|
||||
set inst_pkgs {}
|
||||
foreach pkg [split [exec /bin/opkg list-installed] "\n"] {
|
||||
@ -70,15 +61,43 @@ proc {pkg installed} {} {
|
||||
return $inst_pkgs
|
||||
}
|
||||
|
||||
proc {pkg upgradable} {} {
|
||||
proc {pkg upgr} {} {
|
||||
#webif - 0.5.3 - 0.5.7
|
||||
set upgr_pkgs {}
|
||||
foreach pkg [split [exec /bin/opkg list-upgradable] "\n"] {
|
||||
if {[regexp {^([^ ]+) - ([^ ]+) - (.*)$} $pkg \
|
||||
dummy name oldver newver] == 0} { continue }
|
||||
set upgr_pkgs($name) [concat $oldver $newver]
|
||||
#puts "Set: $name = ($oldver, $newver)<br>"
|
||||
if {[regexp {^([^ ]+)} $pkg name] == 0} { continue }
|
||||
lappend upgr_pkgs $name
|
||||
#puts "Upgr: $name<br>"
|
||||
}
|
||||
return $upgr_pkgs
|
||||
}
|
||||
|
||||
proc {pkg loadmeta} {} {
|
||||
if {[llength $::pkgmeta]} { return }
|
||||
if {![file exists "/mod/var/pkg.meta"]} {
|
||||
pkg fetchmeta
|
||||
} else {
|
||||
set meta [open "/mod/var/pkg.meta" r]
|
||||
set ::pkgmeta [read $meta]
|
||||
$meta close
|
||||
}
|
||||
}
|
||||
|
||||
proc {pkg fetchmeta} {} {
|
||||
set f [socket stream hummypkg.org.uk:80]
|
||||
$f puts -nonewline "GET /pkg.meta HTTP/1.1\r\n"
|
||||
$f puts -nonewline "Host: hummypkg.org.uk\r\n"
|
||||
$f puts -nonewline "\r\n"
|
||||
|
||||
set line [string trim [$f gets]]
|
||||
while {[string length $line]} {
|
||||
set line [string trim [$f gets]]
|
||||
}
|
||||
set ::pkgmeta [$f read]
|
||||
$f close
|
||||
|
||||
set ff [open "/mod/var/pkg.meta" w]
|
||||
puts $ff $::pkgmeta
|
||||
$ff close
|
||||
}
|
||||
|
||||
|
@ -6,13 +6,14 @@ 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} }
|
||||
|
||||
class rsv {
|
||||
ulslot -1
|
||||
ersvtype 0
|
||||
hsvc 0
|
||||
nsttime 0
|
||||
szsttime 0
|
||||
szsttime "00000000000000"
|
||||
nduration 0
|
||||
erepeat 0
|
||||
usevtid 0
|
||||
@ -49,6 +50,7 @@ rsv method name {} {
|
||||
5 { set name "--- Wake-up ---" }
|
||||
6 { set name "--- Sleep ---" }
|
||||
7 { set name "--- Auto Update ---" }
|
||||
11 { set name "--- DSO Event? ---" }
|
||||
default { set name "--- Unknown event type $ersvtype ---" }
|
||||
}
|
||||
}
|
||||
@ -81,11 +83,23 @@ rsv method fix_hsvc {} {
|
||||
|
||||
rsv method insert {} {
|
||||
global rsvdb
|
||||
|
||||
# Find a spare slot.
|
||||
if {$ulslot < 0} {
|
||||
set slot [
|
||||
$rsvdb query {select max(ulslot) FROM TBL_RESERVATION;}]
|
||||
set slot [expr 1 + [lindex [lindex $slot 0] 1]]
|
||||
set ulslot $slot
|
||||
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
|
||||
}
|
||||
}
|
||||
if {$ulslot == -1} { set ulslot $($max + 1) }
|
||||
}
|
||||
|
||||
set fields [lsort [$self vars]]
|
||||
@ -113,8 +127,6 @@ rsv method insert {} {
|
||||
}
|
||||
|
||||
proc {rsv list} {} {
|
||||
catch { $::rsvdb query {.mode tcl} }
|
||||
|
||||
set res [$::rsvdb query {
|
||||
select tbl_reservation.*,
|
||||
channel.TBL_SVC.szSvcName, channel.TBL_SVC.usLcn,
|
||||
@ -133,6 +145,39 @@ proc {rsv list} {} {
|
||||
return $records
|
||||
}
|
||||
|
||||
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)]"
|
||||
}
|
||||
|
||||
return $records
|
||||
}
|
||||
|
||||
proc {rsv entry} {crid svc} {
|
||||
set res [$::rsvdb query {
|
||||
select tbl_reservation.*,
|
||||
channel.TBL_SVC.szSvcName, channel.TBL_SVC.usLcn
|
||||
from tbl_reservation
|
||||
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]
|
||||
|
||||
if {[llength $res] > 0} {
|
||||
return [rsv new [lindex $res 0]]
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
proc {rsv cleanup} {} {
|
||||
catch {$::rsvdb close}
|
||||
}
|
||||
|
@ -2,12 +2,25 @@
|
||||
if {![exists -proc class ]} { package require oo }
|
||||
if {![exists -proc sqlite3.open ]} { package require sqlite3 }
|
||||
|
||||
set settingsdb [sqlite3.open /mod/etc/webif.db]
|
||||
if {![file exists /mod/etc/webif.db]} {
|
||||
set settingsdb [sqlite3.open /mod/etc/webif.db]
|
||||
catch {
|
||||
$settingsdb query {
|
||||
CREATE TABLE settings(name text, nval int, tval text);
|
||||
}
|
||||
$settingsdb query {
|
||||
CREATE UNIQUE INDEX key on settings(name);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
set settingsdb [sqlite3.open /mod/etc/webif.db]
|
||||
}
|
||||
|
||||
class settings {
|
||||
hostname ""
|
||||
channel_group 0
|
||||
smtp_server ""
|
||||
pkgdev 0
|
||||
}
|
||||
|
||||
settings method hostname {{name ""}} {
|
||||
@ -86,6 +99,10 @@ settings method channel_group {{group -1}} {
|
||||
return [$self _nval_setting channel_group $group]
|
||||
}
|
||||
|
||||
settings method pkgdev {{val -1}} {
|
||||
return [$self _nval_setting pkgdev $val]
|
||||
}
|
||||
|
||||
settings method channel_groups {} {
|
||||
set ret ""
|
||||
set db [sqlite3.open /var/lib/humaxtv/setup.db]
|
||||
|
Loading…
Reference in New Issue
Block a user