forked from hummypkg/webif
ded9495595
git-svn-id: file:///root/webif/svn/humax/pkg/src/webif/trunk@265 2a923420-c742-0410-a762-8d5b09965624
185 lines
3.7 KiB
Plaintext
Executable File
185 lines
3.7 KiB
Plaintext
Executable File
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 }
|
|
|
|
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 "00000000000000"
|
|
nduration 0
|
|
erepeat 0
|
|
usevtid 0
|
|
szevtname {}
|
|
ulPreOffset 0
|
|
ulPostOffset 0
|
|
ulProgramId 0
|
|
ulSeriesId 0
|
|
ucVolume 0
|
|
ucInputMode 0
|
|
usChNum 0
|
|
ucRecKind 0
|
|
ucCRIDType 0
|
|
szCRID {}
|
|
szFPBRecPath {}
|
|
szRecordedProgCrid {}
|
|
szEventToRecord {}
|
|
aulEventToRecordInfo {}
|
|
bRecomRsv 0
|
|
usLastRecordedEvtId 0
|
|
eReady 0
|
|
szSvcName {}
|
|
usLcn 0
|
|
sort 0
|
|
}
|
|
|
|
rsv method name {} {
|
|
set name [string range $szevtname 1 end]
|
|
if {[string first "i7" $name] == 0} {
|
|
set name [string range $name 2 end]
|
|
}
|
|
if {$name == ""} {
|
|
switch $ersvtype {
|
|
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 ---" }
|
|
}
|
|
}
|
|
|
|
return $name
|
|
}
|
|
|
|
rsv method channel_name {} {
|
|
return [string range $szSvcName 1 end]
|
|
}
|
|
|
|
rsv method fix_hsvc {} {
|
|
global rsvdb
|
|
|
|
set _hsvc [$rsvdb query "
|
|
select hSvc
|
|
from channel.TBL_SVC
|
|
where szSvcName = '$szSvcName'
|
|
or szSvcname = '\025$szSvcName'
|
|
limit 1
|
|
"]
|
|
|
|
if {[llength $_hsvc] == 1} {
|
|
set hsvc [lindex [lindex $_hsvc 0] 1]
|
|
} else {
|
|
set hsvc 0
|
|
}
|
|
return $hsvc
|
|
}
|
|
|
|
rsv method insert {} {
|
|
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
|
|
}
|
|
}
|
|
if {$ulslot == -1} { set ulslot $($max + 1) }
|
|
}
|
|
|
|
set fields [lsort [$self vars]]
|
|
|
|
foreach field {aulEventToRecordInfo szSvcName usLcn sort} {
|
|
set df [lsearch $fields $field]
|
|
set fields [lreplace $fields $df $df]
|
|
}
|
|
|
|
set vals {}
|
|
foreach field $fields {
|
|
# Escape any quotes embedded in the data.
|
|
regsub -all {'} [$self get $field] {''} f
|
|
lappend vals "'$f'"
|
|
#lappend vals "'[$self get $field]'"
|
|
}
|
|
|
|
set query "insert into TBL_RESERVATION("
|
|
append query [join $fields ","]
|
|
append query ") values("
|
|
append query [join $vals ","]
|
|
append query ");"
|
|
|
|
$rsvdb query $query
|
|
}
|
|
|
|
proc {rsv list} {} {
|
|
set res [$::rsvdb query {
|
|
select tbl_reservation.*,
|
|
channel.TBL_SVC.szSvcName, channel.TBL_SVC.usLcn,
|
|
case when ersvtype > 3 then 1 else 0 end as sort
|
|
from tbl_reservation
|
|
left join channel.TBL_SVC
|
|
on main.TBL_RESERVATION.hSvc = channel.TBL_SVC.hSvc
|
|
order by sort, nsttime
|
|
}]
|
|
|
|
set records {}
|
|
foreach rec $res {
|
|
lappend records [rsv new $rec]
|
|
}
|
|
|
|
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}
|
|
}
|
|
|