add next return field to defer response. Use more intelligent defer times for decrypt. Support mkdir.hook

git-svn-id: file:///root/webif/svn/pkg/webif/trunk@3503 2a923420-c742-0410-a762-8d5b09965624
This commit is contained in:
hummypkg 2017-01-08 14:29:22 +00:00
parent 53edb41250
commit 26ceff2ad2
8 changed files with 54 additions and 12 deletions

View File

@ -1,10 +1,10 @@
Package: webif
Priority: optional
Section: web
Version: 1.3.5
Version: 1.3.5-1
Architecture: mipsel
Maintainer: af123@hpkg.tv
Depends: tcpfix,webif-channelicons(>=1.1.24),lighttpd(>=1.4.39-1),jim(>=0.77),jim-oo(>=0.77),jim-sqlite3(>=0.76),jim-cgi(>=0.7-1),jim-binary(>=0.76),service-control(>=2.3),busybox(>=1.20.2-1),lsof(>=4.87),epg(>=1.2.5),hmt(>=2.0.10),ssmtp,cron-daemon(>=1.18.3-3),at(>=3.1.18),anacron,trm(>=1.1),openssl-command,nicesplice,id3v2,file,rsvsync(>=1.1.9),webif-charts(>=1.2-1),stripts(>=1.2.5-3),tmenu(>=1.08),ffmpeg,id3v2,multienv(>=1.6),tcpping(>=1.1),e2fsprogs,wireless-tools(>=29-1),dbupdate,recmon(>=2.0.7),hwctl,nugget(>=0.95),sqlite3(>=3.15.1)
Depends: tcpfix,webif-channelicons(>=1.1.24),lighttpd(>=1.4.39-1),jim(>=0.77),jim-oo(>=0.77),jim-sqlite3(>=0.76),jim-cgi(>=0.7-1),jim-binary(>=0.76),service-control(>=2.3),busybox(>=1.20.2-1),lsof(>=4.87),epg(>=1.2.5),hmt(>=2.0.10),ssmtp,cron-daemon(>=1.18.3-3),at(>=3.1.18),anacron,trm(>=1.1),openssl-command,nicesplice,id3v2,file,rsvsync(>=1.1.9),webif-charts(>=1.2-1),stripts(>=1.2.5-3),tmenu(>=1.21),ffmpeg,id3v2,multienv(>=1.6),tcpping(>=1.1),e2fsprogs,wireless-tools(>=29-1),dbupdate,recmon(>=2.0.7),hwctl,nugget(>=0.95),sqlite3(>=3.15.1)
Suggests:
Description: An evolving web interface for the Humax.
Tags: http://hummy.tv/forum/threads/7619/

View File

@ -2,6 +2,7 @@
package require cgi
source /mod/webif/lib/setup
require plugin
httpheader
@ -10,3 +11,7 @@ set name [cgi_get newdirname "New Folder"]
file mkdir "$dir/$name"
set dir "$dir/$name"
eval_plugins mkdir

View File

@ -17,6 +17,9 @@ foreach q [queue all] {
set submitted [clock format [$q get submitted] \
-format {%d/%m/%Y %H:%M:%S}]
set start [$q get start]
if {$start ne "0"} { set start $($start - [clock seconds]) }
if {$flag} { puts "," } else { incr flag }
puts "{"
puts " \"qid\": [$q get id],"
@ -25,6 +28,7 @@ foreach q [queue all] {
puts " \"action\": \"[::json::escape [$q get action]]\","
puts " \"args\": \"[::json::escape [$q get args]]\","
puts " \"status\": \"[$q get status]\","
puts " \"start\": \"$start\","
puts " \"log\": \"[::json::escape [$q get log]]\","
if {[$q get runtime] > 0} {
set time [clock format [lindex [split [$q get runtime] .] 0] \

View File

@ -26,6 +26,8 @@ function load()
'<td class="status ' + v.status + '">' + v.status;
if (v.status == 'RUNNING')
s += ' &nbsp;<img class=va src=/img/loading.gif>';
if ((v.status == 'DEFER' || v.status == 'PENDING') && v.start != '0')
s += ' &nbsp;(' + v.start + 's)';
s += '</td><td>';
if (v.runtime != '0')
s += v.runtime;

View File

@ -140,7 +140,9 @@ The framework will call the following callbacks (if defined within the module):
::module::dequeue <q> <ts>
De-queue the provided queue item and associated ts file object.
The module must return a list containing <result> [message]
The module must return a list containing <result> [message] [next]
The [next] field is applicable to the DEFER result only and indicates
when the next de-queue attempt should occur.
Possible results:
@ -151,8 +153,11 @@ The framework will call the following callbacks (if defined within the module):
Examples:
return "OK"
return {"OK" "Processing was successful."}
return [list "OK" "Processing was successful."]
return [list "DEFER" "File not yet decrypted."]
return [list "FAILED" "File is already decrypted."]
return {"OK" "Processing was successful"}
return [list "OK" "Processing was successful"]
return [list "DEFER" "File not yet decrypted"]
return [list "DEFER" "Recording in progress" +300]
return [list "DEFER" "Recording in progress" \
$([clock seconds] + 300)]
return [list "FAILED" "Could not decrypt file"]

View File

@ -175,11 +175,13 @@ for {set qq [::auto::pending]} {[llength $qq]} {set qq [::auto::pending]} {
set ::auto::logprefix "$plugin:$::auto::logprefix"
set st [clock milliseconds]
lassign [::auto::runplugin $plugin dequeue $q $ts] code msg
lassign [::auto::runplugin $plugin dequeue $q $ts] code msg next
set ::auto::logprefix $ologprefix
set elapsed [::auto::elapsed $st]
::auto::log " $code - $msg" 0
if {[string index $next 0] eq "+"} { incr next [clock seconds] }
::auto::log " $code - $msg - $next" 0
switch -- $code {
"-1" {
::auto::log " Plugin failure." 0
@ -189,7 +191,10 @@ for {set qq [::auto::pending]} {[llength $qq]} {set qq [::auto::pending]} {
$q update "COMPLETE" "[::auto::date] $msg" 1 $elapsed
::auto::runplugins dequeued $plugin $q $ts
}
"DEFER" { $q update "DEFER" $msg 1 $elapsed }
"DEFER" {
if {$next ne ""} { $q set start $next }
$q update "DEFER" $msg 1 $elapsed
}
"FAILED" { $q update "FAILED" $msg 1 $elapsed }
default {
$q update "FAILED" "Unknown response '$code' from plugin"

View File

@ -16,11 +16,31 @@ proc ::decrypt::dequeue {q ts} {
}
if {![system dlnastatus]} {
if {[system instandby]} {
# Prevent polling every minute
return [list "DEFER" "Cannot decrypt in standby" +300]
}
return {"DEFER" "DLNA Server not running"}
}
if {[::auto::inuse $ts]} {
return {"DEFER" "Recording in use"}
if {[clock seconds] < [$ts get end]} {
if {[$ts get scheddur] == 5700} {
# Likely to be instant-recording.
return [list "DEFER" \
"Instant-recording in-progress" +300]
}
# Recording in progress, defer until near expected
# end.
set left $([$ts get end] - [clock seconds])
if {$left > 360} {
return [list "DEFER" "Recording in progress" \
"+$($left - 300)"]
} else {
return [list "DEFER" "Recording in progress"]
}
}
return [list "DEFER" "Recording in use"]
}
# Check that the file is not already decrypted by analysing it.

View File

@ -19,7 +19,8 @@ proc ::mp3::ts {ts} {
}
# Enqueue file
queue insert $ts mp3
set q [queue insert $ts mp3]
#$q set args "-mp2"
::auto::log " $file - Queued for mp3." 0
}