From 42b5805c45d425be19b00124aeaac723008813ce Mon Sep 17 00:00:00 2001 From: hummypkg Date: Fri, 8 Jul 2011 20:39:57 +0000 Subject: [PATCH] finish restart git-svn-id: file:///root/webif/svn/humax/pkg/src/webif/trunk@253 2a923420-c742-0410-a762-8d5b09965624 --- var/mongoose/cgi-bin/backup/backup.js | 5 +- var/mongoose/cgi-bin/backup/restore.jim | 6 + var/mongoose/cgi-bin/browse.jim | 40 ++---- var/mongoose/cgi-bin/browse/browse.js | 45 +++++++ var/mongoose/cgi-bin/browse/enc.jim | 27 ++++ var/mongoose/cgi-bin/browse/new.jim | 27 ++++ var/mongoose/cgi-bin/restart.jim | 8 ++ var/mongoose/cgi-bin/restartblock.jim | 7 ++ var/mongoose/cgi-bin/settings.jim | 9 +- var/mongoose/html/css/jquery.contextMenu.css | 124 +++++++++---------- var/mongoose/html/css/style.css | 12 ++ var/mongoose/html/img/Video_Other.png | Bin 0 -> 4838 bytes var/mongoose/html/img/Video_Other_New.png | Bin 0 -> 5218 bytes var/mongoose/html/img/Video_TS.png | Bin 0 -> 6592 bytes var/mongoose/html/img/Video_TS_New.png | Bin 0 -> 6771 bytes var/mongoose/html/img/redshade.png | Bin 0 -> 361 bytes var/mongoose/html/index.shtml | 6 +- var/mongoose/include/backup.jim | 11 ++ var/mongoose/include/restart.jim | 52 ++++++-- var/mongoose/lib/ts.class | 26 +++- 20 files changed, 298 insertions(+), 107 deletions(-) create mode 100755 var/mongoose/cgi-bin/browse/enc.jim create mode 100755 var/mongoose/cgi-bin/browse/new.jim create mode 100755 var/mongoose/cgi-bin/restart.jim create mode 100755 var/mongoose/cgi-bin/restartblock.jim create mode 100644 var/mongoose/html/img/Video_Other.png create mode 100644 var/mongoose/html/img/Video_Other_New.png create mode 100644 var/mongoose/html/img/Video_TS.png create mode 100644 var/mongoose/html/img/Video_TS_New.png create mode 100644 var/mongoose/html/img/redshade.png diff --git a/var/mongoose/cgi-bin/backup/backup.js b/var/mongoose/cgi-bin/backup/backup.js index be7b6d5..906bd44 100755 --- a/var/mongoose/cgi-bin/backup/backup.js +++ b/var/mongoose/cgi-bin/backup/backup.js @@ -48,8 +48,9 @@ $(document).ready(function() { $('#results').slideDown(function() { $('#restore_working').slideUp(); refresh_files(); - alert('!!!!!!!!!!!!!! PLEASE NOTE !!!!!!!!!!!!!!\n\nAfter a restore you must restart the box using the link at the top of the screen or via the remote control and then add at least one scheduled entry using the remote control (which you can then delete).'); - window.location.reload(true); + $('#restore_warning').slideDown(); + $('#restart_block').load( + '/cgi-bin/restartblock.jim'); }); }); } diff --git a/var/mongoose/cgi-bin/backup/restore.jim b/var/mongoose/cgi-bin/backup/restore.jim index 3a0bbe3..e87b021 100755 --- a/var/mongoose/cgi-bin/backup/restore.jim +++ b/var/mongoose/cgi-bin/backup/restore.jim @@ -99,6 +99,7 @@ foreach line $data { puts "Restoring favourite channels..." $rsvdb query {delete from channel.TBL_FAV} +set grp 0 foreach line $data { set vals [split $line "\t"] if {[lindex $vals 0] ne "fav"} { continue } @@ -108,6 +109,11 @@ foreach line $data { set chan [lindex $vals 3] set hsvc [findhsvc $chan] + if {$grp != $group} { + set grp $group + puts " Group $grp" + } + puts " $chan" if {!$hsvc} { diff --git a/var/mongoose/cgi-bin/browse.jim b/var/mongoose/cgi-bin/browse.jim index e9d3372..95b9d05 100755 --- a/var/mongoose/cgi-bin/browse.jim +++ b/var/mongoose/cgi-bin/browse.jim @@ -46,15 +46,11 @@ proc entry {file} {{i 0}} { if {$ext eq ".ts" && [file exists "${base}.nts"]} { set type ts set ts [ts fetch $file 1] - set img 741_1_10_Video_Title.png - set pad 0 - set newpad "top: -6; left: 4;" + set img Video_TS } else { set type gen set ts 0 - set img 743_4_10_Video_Xvid_File.png - set pad "2" - set newpad "top: -2; left: 2;" + set img Video_Other } puts " @@ -69,26 +65,9 @@ proc entry {file} {{i 0}} { if {![file exists "[file rootname $file].hmi"]} { set new 1 } } - if {$new} { - # Overlay the new image over the media one. - puts " - - - - - " - } else { - puts " - - " - } + if {$new} { append img _New } + + puts "" puts " $bfile @@ -101,11 +80,15 @@ proc entry {file} {{i 0}} { # Icons set locked 0 + set encd 0 + set def unknown if {$type eq "ts"} { # HD / SD if {[$ts get definition] eq "HD"} { + set def HD set img "172_1_00_HD" } else { + set def SD set img "172_1_26_SD" } puts "" @@ -119,6 +102,7 @@ proc entry {file} {{i 0}} { # Encrypted if {[$ts flag "Encrypted"] > 0} { + set encd 1 puts "" @@ -137,7 +121,7 @@ proc entry {file} {{i 0}} { puts "
@@ -163,6 +147,8 @@ puts { diff --git a/var/mongoose/cgi-bin/browse/browse.js b/var/mongoose/cgi-bin/browse/browse.js index 1977de0..e0c0461 100755 --- a/var/mongoose/cgi-bin/browse/browse.js +++ b/var/mongoose/cgi-bin/browse/browse.js @@ -69,6 +69,18 @@ function lock_callback(file, type, id) $.get(url, function() { window.location.reload(true); }); } +function enc_callback(file, type, id) +{ + var url = '/cgi-bin/browse/enc.jim?file=' + encodeURIComponent(file); + $.get(url, function() { window.location.reload(true); }); +} + +function new_callback(file, type, id) +{ + var url = '/cgi-bin/browse/new.jim?file=' + encodeURIComponent(file); + $.get(url, function() { window.location.reload(true); }); +} + function rename_submit() { var s = $('#renameform_form').serialize(); @@ -98,6 +110,26 @@ function preparemenu(el, menu) { if (el.attr('type') == 'ts') { + if (el.attr('def') == 'HD') + { + $('#optmenu').enableContextMenuItems('#enc'); + if (el.attr('encd') == 1) + $(menu).changeContextMenuItem('#enc', + 'Remove ENC'); + else + $(menu).changeContextMenuItem('#enc', + 'Set ENC'); + } + else + $('#optmenu').disableContextMenuItems('#enc'); + + $('#optmenu').enableContextMenuItems('#new'); + if (el.attr('new') == 1) + $(menu).changeContextMenuItem('#new', 'Mark watched'); + else + $(menu).changeContextMenuItem('#new', 'Mark new'); + + $('#optmenu').enableContextMenuItems('#lock'); if (el.attr('locked') == 1) { @@ -114,7 +146,10 @@ function preparemenu(el, menu) { $('#optmenu').enableContextMenuItems('#delete'); $('#optmenu').disableContextMenuItems('#lock'); + $('#optmenu').disableContextMenuItems('#enc'); + $('#optmenu').disableContextMenuItems('#new'); } + } @@ -139,6 +174,16 @@ var menuclick = function(action, el, pos) file, type, id); break; + case 'enc': + confirm_action('change the ENC flag on', enc_callback, + file, type, id); + break; + + case 'new': + confirm_action('change the New flag on', new_callback, + file, type, id); + break; + case 'rename': $('#rename').val(bfile); $('#renameorig').val(file); diff --git a/var/mongoose/cgi-bin/browse/enc.jim b/var/mongoose/cgi-bin/browse/enc.jim new file mode 100755 index 0000000..a1f4ea6 --- /dev/null +++ b/var/mongoose/cgi-bin/browse/enc.jim @@ -0,0 +1,27 @@ +#!/mod/bin/jimsh + +package require cgi +source /mod/var/mongoose/lib/ts.class + +puts "Content-Type: text/html" +puts "" + +cgi_input +#cgi_dump + +#set _cgi(file) "/media/My Video/The Walking Dead/The Walking Dead S01E06.ts" + +set file [dict get $_cgi file] +set ts [ts fetch $file] +if {[set ts [ts fetch $file]] != 0} { + set action enc + if {[$ts flag "Encrypted"]} { set action unenc } + + if {[$ts $action]} { + puts "Successfully [set action]ed $file." + } else { + puts "Problem [set action]ing $file, + [$ts get error]" + } +} + diff --git a/var/mongoose/cgi-bin/browse/new.jim b/var/mongoose/cgi-bin/browse/new.jim new file mode 100755 index 0000000..4496009 --- /dev/null +++ b/var/mongoose/cgi-bin/browse/new.jim @@ -0,0 +1,27 @@ +#!/mod/bin/jimsh + +package require cgi +source /mod/var/mongoose/lib/ts.class + +puts "Content-Type: text/html" +puts "" + +cgi_input +#cgi_dump + +#set _cgi(file) "/media/My Video/The Walking Dead/The Walking Dead S01E06.ts" + +set file [dict get $_cgi file] +set ts [ts fetch $file] +if {[set ts [ts fetch $file]] != 0} { + set action new + if {[$ts flag "New"]} { set action watched } + + if {[$ts set_$action]} { + puts "Successfully marked $file as $action." + } else { + puts "Problem marking $file as $action, + [$ts get error]" + } +} + diff --git a/var/mongoose/cgi-bin/restart.jim b/var/mongoose/cgi-bin/restart.jim new file mode 100755 index 0000000..8f2fd37 --- /dev/null +++ b/var/mongoose/cgi-bin/restart.jim @@ -0,0 +1,8 @@ +#!/mod/bin/jimsh + +puts "Content-Type: text/html" +puts "" + +puts [exec /etc/init.d/S90settop restart] +file delete /tmp/.restartpending + diff --git a/var/mongoose/cgi-bin/restartblock.jim b/var/mongoose/cgi-bin/restartblock.jim new file mode 100755 index 0000000..3d3b1df --- /dev/null +++ b/var/mongoose/cgi-bin/restartblock.jim @@ -0,0 +1,7 @@ +#!/mod/bin/jimsh + +puts "Content-Type: text/html" +puts "" + +source /mod/var/mongoose/include/restart.jim + diff --git a/var/mongoose/cgi-bin/settings.jim b/var/mongoose/cgi-bin/settings.jim index 2f30fac..3cf857d 100755 --- a/var/mongoose/cgi-bin/settings.jim +++ b/var/mongoose/cgi-bin/settings.jim @@ -56,9 +56,6 @@ header puts {} puts { -

Backup/Restore

+
+ +
To create a backup of your current favourite channel configuration and diff --git a/var/mongoose/include/restart.jim b/var/mongoose/include/restart.jim index 76d4b68..61cd171 100755 --- a/var/mongoose/include/restart.jim +++ b/var/mongoose/include/restart.jim @@ -1,16 +1,52 @@ #!/mod/bin/jimsh -if {![file exists /tmp/.restartpending]} { exit } +if {[file exists /tmp/.restartpending]} { puts {
-
-
- A restart is required in order to complete a scheduling operation. -
-
-
+
+ A warm restart is required in order to complete a scheduling operation. +
+ +} + +# 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} { + puts "Cannot restart whilst box is busy." +} else { + puts { + Restart via the remote control or + + } +} + +puts { + +
+
+ + +} + } diff --git a/var/mongoose/lib/ts.class b/var/mongoose/lib/ts.class index 3844ce2..15da24c 100644 --- a/var/mongoose/lib/ts.class +++ b/var/mongoose/lib/ts.class @@ -45,14 +45,36 @@ ts method flag {f} { ts method unlock {} { set cmd [list /mod/bin/hmt -lock $file] - #puts "CMD: $cmd" exec {*}$cmd return 1 } ts method lock {} { set cmd [list /mod/bin/hmt +lock $file] - #puts "CMD: $cmd" + exec {*}$cmd + return 1 +} + +ts method unenc {} { + set cmd [list /mod/bin/hmt -protect $file] + exec {*}$cmd + return 1 +} + +ts method enc {} { + set cmd [list /mod/bin/hmt +protect $file] + exec {*}$cmd + return 1 +} + +ts method set_new {} { + set cmd [list /mod/bin/hmt +new $file] + exec {*}$cmd + return 1 +} + +ts method set_watched {} { + set cmd [list /mod/bin/hmt -new $file] exec {*}$cmd return 1 }