#!/tvbin/tivosh 
# 
# fixup02c.tcl by khmann 08/02/01 
# 
# based upon info from folks at DealDatabase.com and my 1.3 Philips TiVo 
# Check out SetStatusStringDB2 in /tvlib/tcl/tv/TClient-lib.itcl 
# 
# if this helps you, then great.  if not, oh well.  Please do not consider 
# this script to be a substitute for TiVo service.  It is ONLY a work- 
# around for the manual record bug in 2.0 software.  I really didn't want 
# to release this, but it seems all the info is already out there. 
# 
# Please, show your support for TiVo and purchase service, if for no other 
# reason than to get software updates and support. 
# 
# I took the time to code and release this, so please leave this (lame) 
# comment section intact.  Thankyou. 
#
# Revision by tivo_canada 05/31/02
# - Complete is set to '7' under 2.5
#


# status strings 
source $tcl_library/tv/StatusStrings.itcl 

# source of RetryTransaction function 
tvsource $tcl_library/tv/mfslib.tcl 


proc FIXUP {db} { 
   try { 
       RetryTransaction { 
           set now [clock seconds] 
           set today [expr ($now / 86400)] 
           set stateExpiration [expr ($today + 7)] 
           set nextCall [expr ($stateExpiration * 86400)] 
           set lastCallStatus $StatusStrings::Succeeded 
           set callStatusInfo $StatusStringEnums::Succeeded 

           set sobj [db $db open /Setup] 
           set ssobj [dbobj $sobj get ServiceInfo] 

               # Guided Setup has been completed, use instead of SETUP_BYPASS 
               dbobj $sobj set Complete 7
               dbobj $sobj set DemoMode 0 
               dbobj $sobj set LastCallStatus $lastCallStatus 
               dbobj $sobj set LastCallAttempt $now 
               dbobj $sobj set LastSuccessCall $now 
               dbobj $sobj set NextCallAttempt $nextCall 
               dbobj $sobj set ServiceState 5 
               dbobj $sobj set ServiceStateExpiration $stateExpiration 

               dbobj $ssobj set CallStatusInfo $callStatusInfo 
               dbobj $ssobj set LastDialInUpdateTime $today 

               # 2.0 specific variable, not present under 1.3 
               dbobj $ssobj set LastSuccessPGDCall $now 
       } 
   } catch errCode { 
       puts "Failed to FIXUP, code=($errCode)" 
       return 0 
   } 
   return 1 
} 

set db [dbopen] 
FIXUP $db 
dbclose $db 


