#!/tvbin/tivosh
#
# Create a Line-In Source
# (c) 2000, Ricky Beam [cramer]
#
# "If you break it, you own all the peices."
#
source $tcl_library/tv/Inc.itcl
source $tcl_library/tv/mfslib.tcl


set db [dbopen]
transaction {

  set setup [db $db open /Setup]

# Create a Station Reference for the channel menu(s)
#  puts "Creating Station: A/V"
#  set station [db $db create Station]
#  dbobj $station set CallSign "A/V"
#  dbobj $station set Name "Composite Input"
#  dbobj $station set Affiliation TiVo

# [here's the Real Magic(tm)]
#
# Create a new Input SignalSource
# -- SignalType 5 == CableBox
#
# -- Connector 3 == Composite In
# -- Connector 5 == S-Video In
#
# (LineupType is an attempt to make dynlineup.tcl shut up
#  but it needs a Headend to be happy, so screw it.)
#
  puts "Creating SignalSource A/V"
  set source [db $db createsub SignalSource $setup]
  dbobj $source set ProviderName "TiVo A/V In"
  dbobj $source set SignalType 5
  dbobj $source set Connector 3
  dbobj $source set RFChannel 2
  dbobj $source set CableBoxCodeNum 0
# dbobj $source set LineupType 0
  dbobj $setup add Source $source

#
# And then create a channel pointing to the previously 
# creates source...
#
# (Record 0 means it doesn't show up as a recoding source...
#  tune to it before adding a Manual Recording.)
#
#  puts "Creating channel 99"
#  set channel [db $db createsub Channel $setup]
#  dbobj $channel set Station $station
#  dbobj $channel set Number 99
#  dbobj $channel set SourceIndex 1
#  dbobj $channel set Surf 0
#  dbobj $channel set Favorite 0
#  dbobj $channel set Record 0
#  dbobj $source add Channel $channel
}
dbclose $db
unset db

event send 23 16 0
puts "Done"

puts "\n"
puts "You will see messages from the daily update complaining about not"
puts "being able to find/update the Line-up.  It will ask you to repeat"
puts "Guided Setup.  IGNORE THIS.  /tvlib/tcl/dynLineup.tcl is creating"
puts "that message because it doesn't have complete data for the new"
puts "input source."
puts "\n"

puts "If the new input isn't available, REBOOT your Tivo."
sync
