From a9f7ba3ff2eaa3a997f24d874b529b47563f8ffe Mon Sep 17 00:00:00 2001 From: hummypkg Date: Fri, 14 Aug 2015 19:33:25 +0000 Subject: [PATCH] 1.2.4 git-svn-id: file:///root/webif/svn/pkg/webif/trunk@2451 2a923420-c742-0410-a762-8d5b09965624 --- CONTROL/control | 6 +++--- webif/cgi-bin/idle.jim | 28 ++++++++++++++++++++++++++++ webif/cgi-bin/status.jim | 27 ++++++++++++++++++--------- webif/html/browse/index.jim | 23 +++++++++++++++++------ webif/html/css/style.css | 15 +++++++++++++++ webif/html/diag/diag.jim | 6 ++---- webif/html/diag/script.js | 18 +++++++++++++++--- webif/html/edit/edit.jim | 1 + webif/html/edit/perms.jim | 25 +++++++++++++++++++++++++ webif/html/edit/script.js | 33 +++++++++++++++++++++++++++++++-- webif/html/js/topbar.js | 14 ++++++++++++++ webif/html/lib/topbar.jim | 1 + webif/html/play/play.jim | 10 +++++----- webif/lib/bin/auto | 7 ++++--- webif/lib/system.class | 27 +++++++++++++++++++++++---- webif/lib/ts.class | 4 ++++ 16 files changed, 206 insertions(+), 39 deletions(-) create mode 100755 webif/cgi-bin/idle.jim create mode 100755 webif/html/edit/perms.jim diff --git a/CONTROL/control b/CONTROL/control index 8bfd077..9318728 100644 --- a/CONTROL/control +++ b/CONTROL/control @@ -1,10 +1,10 @@ Package: webif Priority: optional Section: web -Version: 1.2.3-5 +Version: 1.2.4 Architecture: mipsel Maintainer: af123@hummypkg.org.uk -Depends: webif-channelicons(>=1.1.18),lighttpd(>=1.4.35-2),jim(>=0.76),jim-oo,jim-sqlite3(>=0.76),jim-cgi(>=0.7),jim-binary(>=0.76),service-control(>=2.1),busybox(>=1.20.2-1),lsof(>=4.87),epg(>=1.2.0),hmt(>=2.0.3),ssmtp,anacron,trm(>=1.1),openssl-command,nicesplice,id3v2,file,rsvsync(>=1.0.2),webif-charts(>=1.2-1),stripts(>=1.2.5-3),smartmontools,tmenu(>=1.08),ffmpeg,id3v2,multienv(>=1.6),tcpping(>=1.1),e2fsprogs,wireless-tools(>=29-1),dbupdate,recmon(>2.0.3-3),auto-unprotect(>=2.0.0-1) +Depends: webif-channelicons(>=1.1.18),lighttpd(>=1.4.35-2),jim(>=0.76),jim-oo,jim-sqlite3(>=0.76),jim-cgi(>=0.7),jim-binary(>=0.76),service-control(>=2.1),busybox(>=1.20.2-1),lsof(>=4.87),epg(>=1.2.0),hmt(>=2.0.5),ssmtp,anacron,trm(>=1.1),openssl-command,nicesplice,id3v2,file,rsvsync(>=1.0.2),webif-charts(>=1.2-1),stripts(>=1.2.5-3),smartmontools,tmenu(>=1.08),ffmpeg,id3v2,multienv(>=1.6),tcpping(>=1.1),e2fsprogs,wireless-tools(>=29-1),dbupdate,recmon(>=2.0.7) Suggests: Description: An evolving web interface for the Humax. -Tags: http://hummy.tv/forum/threads/5866/ +Tags: http://hummy.tv/forum/threads/6484/ diff --git a/webif/cgi-bin/idle.jim b/webif/cgi-bin/idle.jim new file mode 100755 index 0000000..dd544f6 --- /dev/null +++ b/webif/cgi-bin/idle.jim @@ -0,0 +1,28 @@ +#!/mod/bin/jimsh + +source /mod/webif/lib/setup +require system.class + +httpheader + +set idle [system idletime] +if {$idle > 0} { + lassign [clock format $idle -format {%H %M}] h m + set s "Idle: " +# switch $h { +# 1 { append s "1 hour, " } +# 0 {} +# default { append s "$($h + 0) hours, " } +# } +# switch $m { +# 1 { append s "1 min" } +# default { append s "$($m + 0) mins" } +# } + + if {$h > 0} { append s "$($h + 0)h, " } + append s "$($m + 0)m" + puts $s +} else { + puts "" +} + diff --git a/webif/cgi-bin/status.jim b/webif/cgi-bin/status.jim index 3400b6c..48cae18 100755 --- a/webif/cgi-bin/status.jim +++ b/webif/cgi-bin/status.jim @@ -75,7 +75,7 @@ proc get_data {} { } } } - if {$opfile ne "" && $opfile ni $ret} { + if {$opfile ne "" && $opfile ni $ret && [file exists $opfile]} { set ret($opfile) [file size $opfile] } } @@ -241,15 +241,17 @@ if {![system instandby] && $play < 1} { } if {$runmode eq "cgi"} { - lappend output [concat \ - "\n" \ - " [epg channelicon $name 30 \ - {vertical-align: middle; padding: 0 4px 0 2px}]\n" \ - " Watching $lcn: $name $prog\n" \ - "\n" \ - ] + set s " + + [epg channelicon $name 30 \ + {vertical-align: middle; padding: 0 4px 0 2px}] + Watching $lcn: $name $prog + " + append s "" + lappend output $s } else { - lappend output "Watching $lcn: $name $prog" + set s "Watching $lcn: $name $prog" + lappend output $s } } } @@ -298,6 +300,13 @@ foreach event $events { } } +###################################################################### +# Idle Time + +if {$runmode ne "cgi"} { + lappend output "Idle: [clock format [system idletime] -format %T]" +} + ###################################################################### # Output diff --git a/webif/html/browse/index.jim b/webif/html/browse/index.jim index 9678d8c..2beb0f5 100755 --- a/webif/html/browse/index.jim +++ b/webif/html/browse/index.jim @@ -40,6 +40,8 @@ set nofcount [$config nounwatchedcount] set model [system model] set dustbin [system dustbin 1] +set dlnaok [system dlnastatus] + proc icon {img {hover ""} {extra ""} {class "va"}} { puts -nonewline " + Note: Content Sharing is disabled on this system. + + } +} + puts " $dir $mroot diff --git a/webif/html/css/style.css b/webif/html/css/style.css index c5d4b4d..738ee48 100644 --- a/webif/html/css/style.css +++ b/webif/html/css/style.css @@ -75,6 +75,15 @@ div.container .usb top: 8px; } +#idletime +{ + position: absolute; + left: 50px; + top: 45px; + font-style: italic; + font-size: 12px; +} + div.footer { clear: both; @@ -239,6 +248,12 @@ pre, .pre background: transparent; } +.idletime +{ + font-size: 70%; + font-style: italic; +} + .filesize { color: #6a6aff; diff --git a/webif/html/diag/diag.jim b/webif/html/diag/diag.jim index 22e1bf3..22a62bc 100755 --- a/webif/html/diag/diag.jim +++ b/webif/html/diag/diag.jim @@ -51,6 +51,8 @@ puts { + + @@ -181,10 +183,6 @@ foreach file [lsort -command logsort $loglist] { puts { - - - } footer diff --git a/webif/html/diag/script.js b/webif/html/diag/script.js index f147de5..9092cc2 100644 --- a/webif/html/diag/script.js +++ b/webif/html/diag/script.js @@ -3,14 +3,26 @@ $(function() { $('button').button(); +$('#rundiag').button({icons: {primary: "ui-icon-play"}}); +$('#runfopkg').button({icons: {primary: "ui-icon-play"}}); +$('#runedit').button({icons: {primary: "ui-icon-folder-open"}}); +$('#dbinfo').button({icons: {primary: "ui-icon-wrench"}}); +$('#channelinfo').button({icons: {primary: "ui-icon-script"}}); +$('#diskdiag').button({icons: {primary: "ui-icon-disk"}}); +$('#dlna').button({icons: {primary: "ui-icon-video"}}); +$('#dspace').button({icons: {primary: "ui-icon-search"}}); +$('#reboot').button({icons: {primary: "ui-icon-power"}}); +//$('#runreset').button({icons: {primary: "ui-icon-radio-on"}}); +//$('#runrma').button({icons: {primary: "ui-icon-radio-on"}}); + $('#rundiag').click(function() { var val = $('#diagsel').val(); if (val == '0') val = $('#seq').val(); $('#results') .slideDown() - .html('

' + - 'Running diagnostic, please wait...') + .html(' ' + + 'Running diagnostic, please wait...') .load('rundiag.jim?diag=' + encodeURIComponent(val), function() { $('#results').wrapInner('
');
 	    });
@@ -57,7 +69,7 @@ $('#dspace').click(function(e) {
 	window.location = 'dspace/index.jim';
 });
 
-$('#reboot').button({icons:{primary:"ui-icon-power"}}).click(function(e) {
+$('#reboot').click(function(e) {
 	e.preventDefault();
 	window.location = '/restart/index.jim';
 });
diff --git a/webif/html/edit/edit.jim b/webif/html/edit/edit.jim
index 4c3ca9f..f83c61b 100755
--- a/webif/html/edit/edit.jim
+++ b/webif/html/edit/edit.jim
@@ -32,6 +32,7 @@ class="ui-widget ui-corner-all">
 
 
 
+
 
 
 }
 source /mod/webif/include/toolbar.jim
diff --git a/webif/html/play/play.jim b/webif/html/play/play.jim
index 7f4a22f..67d9fe6 100755
--- a/webif/html/play/play.jim
+++ b/webif/html/play/play.jim
@@ -13,11 +13,11 @@ if {[catch {$ts get file}]} {
 	exit
 }
 
-if {![$ts flag "ODEncrypted"]} {
-	set url $rfile
-} else {
-	lassign [$ts dlnaloc] url
-	if {$url eq ""} {
+lassign [$ts dlnaloc] url
+if {$url eq ""} {
+	if {![$ts flag "ODEncrypted"]} {
+		set url $rfile
+	} else {
 		puts "Media is encrypted and not indexed by the DLNA Server."
 		exit
 	}
diff --git a/webif/lib/bin/auto b/webif/lib/bin/auto
index b0e5728..b24614f 100755
--- a/webif/lib/bin/auto
+++ b/webif/lib/bin/auto
@@ -135,13 +135,13 @@ eval_plugins auto 1
 set scanstart [clock milliseconds]
 log "-------------------------------------------------------"
 
-# is_listening is relatively expensive so it is checked once globally at
+# dlnastatus is relatively expensive so it is checked once globally at
 # the start and then if the server is not listening then no decrypt
 # operations will be attempted for this run, even if the server starts
 # up halfway through. Otherwise the server is checked for every decryption
 # and if it goes away then decryption will not be attempted for the rest
 # of the run.
-if {[system is_listening 9000]} {
+if {[system dlnastatus]} {
 	set dlnaok 1
 	log "DLNA Server is running." 2
 } else {
@@ -333,7 +333,7 @@ proc do_decrypt {ts} {
 		return
 	}
 
-	if {![system is_listening 9000]} {
+	if {![system dlnastatus]} {
 		log "  $file - DLNA Server not running." 2
 		set ::dlnaok 0
 		return
@@ -445,6 +445,7 @@ proc do_decrypt {ts} {
 	}
 	log "Done... [endclock $size]" 0
 	lappend processed_files [$ts get file]
+	$ts unflag "ODEncrypted"
 	runplugin postdecrypt $ts
 	endop
 }
diff --git a/webif/lib/system.class b/webif/lib/system.class
index 23599a0..839db4c 100644
--- a/webif/lib/system.class
+++ b/webif/lib/system.class
@@ -74,6 +74,13 @@ proc {system lastbootreason} {{descr 1}} {{lbr -1}} {
 	return "Unknown ($lbr)"
 }
 
+proc {system idletime} {} {
+	if {[file exists "/tmp/.lastir"]} {
+		return $([clock seconds] - [file mtime "/tmp/.lastir"])
+	}
+	return 0
+}
+
 proc {system fhtcpversion} {} {{ver ""}} {
 	if {$ver ne ""} { return $ver }
 	set file "/etc/fhtcpversion"
@@ -153,6 +160,10 @@ proc {system mediaroot} {} {
 	return ""
 }
 
+proc {system dlnastatus} {} {
+	return [system is_listening 9000]
+}
+
 proc {system dlnadb} {} {
 	switch [system model] {
 		HDR { return "/mnt/hd2/dms_cds.db" }
@@ -163,7 +174,9 @@ proc {system dlnadb} {} {
 
 proc {system _dlnaurl} {file urlbase} {
 	set mime "video/ts"
-	set db [sqlite3.open [system dlnadb]]
+	if {[catch {set db [sqlite3.open [system dlnadb]]}]} {
+		return {}
+	}
 	set muri [$db query {
 	    select tblresource.mimetype, contenturi
 	    from tblresource join tblmedia using (mediaid)
@@ -300,11 +313,17 @@ proc {system diskspace} {{raw 0}} {
 	set fperc $(100 - $perc)
 
 	switch [system model] {
-		HDR { set tsrdir "/mnt/hd2/Tsr" }
-		HD { set tsrdir "/media/drive1/.tsr" }
+		HDR {
+			set tsrdir "/mnt/hd2/Tsr"
+			set tsrok [file isdirectory $tsrdir]
+		}
+		HD {
+			set tsrdir "/media/drive1/.tsr"
+			set tsrok [file exists "$tsrdir/0.ts"]
+		}
 	}
 
-	if {[file exists "$tsrdir/0.ts"]} {
+	if {$tsrok} {
 		set tsrbuf 21474836480
 		lassign [exec du -ks $tsrdir] tsrused
 		set tsrused $($tsrused * 1024)
diff --git a/webif/lib/ts.class b/webif/lib/ts.class
index dbc7849..74967d7 100644
--- a/webif/lib/ts.class
+++ b/webif/lib/ts.class
@@ -87,6 +87,10 @@ ts method flag {f} {
 	if {$f in $flags} {return 1} else {return 0}
 }
 
+ts method unflag {f} {
+	lremove flags $f
+}
+
 ts method unlock {} {
 	set cmd [list /mod/bin/hmt -lock $file]
 	exec {*}$cmd