# Created by Flash_ to support 6.2 DTiVos MRV setup
# Originally posted by CapablePerson66, updated by alldeadhomiez to
# not nuke all keys, updated by NutKase to remove the event call and
# prevent errors with 6.2x and 7.1x tivo software versions.
# modified by Flash_ to be a callable module for TiVoWebPlus
if {$::version >= 4} {
proc set_mrv_name_67 { chan mrv_name } {
set mfsVerboseG 0
set cname "-12000-32767-00000000"
set k "0x54E956EF0A1745757374616365205068"
set k "${k}656E7465726261636B69616E00700748"
set k "${k}223D2E0C6B91C1A4FA2461E654D4944C"
set k "${k}656C61C9D60054686973207072696D65"
set k "${k}206E756D6265722069732062726F7567"
set k "${k}687420746F20796F7520627920446176"
set k "${k}6520506C617474206F66205469566F20"
set k "${k}496E632E006A50F9DAEFC8E52D19DFE0"
set k "${k}21F6E6C54885F8DA414985B9493E0107"
set k "${k}700634EF7444E99AA9704B451E6709A9"
set k "${k}928D4BCCC32C29A0050C1F940985F7C1"
set k "${k}FB766E104AC21ECB4AF7B09AA87567BC"
set k "${k}8C0A146F123C6F6F87113EEC18B49981"
set k "${k}15F8887052DC4EEC7E6E83B22C517D92"
set k "${k}090DBC2AC1963A3E72115AF7DC79F1F9"
set k "${k}EED80AD4C565E2F85F87DAA63305FE132700"
if [info exists env(HOST)] {set host $env(HOST)}
if [llength $mrv_name] {set host $mrv_name}
if {![info exists host] || $host==""} {
puts $chan "Please specify a name for this tivo"
return 1
}
puts $chan "
Setting nametable for \"$host\"...Please Wait!
"
set gek [eval exec /tvbin/crypto -x -gek]
set hex [eval exec /tvbin/crypto -x -mgc $k 32767 32767 $cname $gek {$host}]
# MfsRubbishTree /State/Keyring
# nuke old NAMETABLE/TIVOVID/MRV keys
set nuke ""
ForeachMfsFile fsid name type /State/Keyring "" {
if { [regexp {^(NAMETABLE|TIVOVID|MRV)} $name] } {
set nuke "$nuke $fsid"
}
}
set db [dbopen]
set cprefix "TIVOVID_2"
RetryTransaction {
set swsys [db $db open /SwSystem/ACTIVE]
set swvers [dbobj $swsys get Name]
}
if { [regexp {^4.0-} $swvers] } {
set cprefix "NAMETABLE-2"
}
set cname "${cprefix}${cname}"
foreach x $nuke {
RetryTransaction {
set obj [db $db openid $x]
dbobj $obj markasrubbish
}
}
RetryTransaction {
set obj [db $db create EncryptionKey]
dbobj $obj set Name $cname
dbobj $obj set Type 2
dbobj $obj set Value $hex
}
# Event system was removed from 6.2x and 7.1x
if {$::version < 6} {
event send $TmkEvent::EVT_DATA_CHANGED $TmkDataChanged::DATA_ENCRYPTION_KEYS
}
# puts $chan "Reboot your tivo for the changes to take effect."
return 0
}
proc action_mrv {chan path env} {
set name ""
eval $env
puts $chan [html_start "MRV Setup"]
puts $chan "
Multi-Room Viewing Name Setup
"
puts $chan "
"
if {$env == "" } {
puts $chan [html_form_start "GET" "/mrv"]
puts $chan "Enter Name for this TiVo : "
puts $chan [html_form_text 1 35 "name" $name]
puts $chan "
"
puts $chan [html_form_input "submit" "submit" "Name it!"]
puts $chan [html_form_end]
} else {
set rc [set_mrv_name_67 $chan $name]
if {$rc == 0} {
puts $chan "
Success"
} else {
puts $chan "
Failed"
}
}
puts $chan [html_end]
}
register_module "mrv" "MRV Setup" "Name this TiVo for Multi-Room Viewing"
}