[Init]
  set APP_TITTLE "SCOL Engine"
  set APP_VERSION_SUP "3"
  set APP_VERSION_INF "2c"
  set APP_RELEASE "(p10)"
  set APP_VERSION APP_VERSION_SUP 
  strcat APP_VERSION "."
  strcat APP_VERSION APP_VERSION_INF
  set PROGRAMGROUP "Scol"
  set SCOLDIR ""
  set VERSION "2000-03-21"

  set NEEDEDSPACE "50000000"

[Setup]
  GetSystemVars
  goto "Init"
  include languagefile "InitInstall"

  set EXENAME "usmwin.exe"
  set EXEARGS "/INSTALL"

  strcat INTRO APP_TITTLE
  strcat INTRO " v "
  strcat INTRO APP_VERSION_SUP
  strcat INTRO "."
  strcat INTRO APP_VERSION_INF
  strcat INTRO APP_RELEASE

  strcat INTRO INTRO2

  set rootSRCDIR SRCDIR
  strcat SRCDIR SCOLDIR
  set DSTDIR PROGRAMFILES
  strcmp DSTDIR ""
  if
    set DSTDIR "c:\SCOL"
  else
    strcat DSTDIR "SCOL"
  endif

  DetectTCPIP
  if
  else
    Quit NOTCPIP ABORT_TTL 
  endif

  CheckForDLL "WININET.DLL"
  if
  else
    Quit NOWININET ABORT_TTL
  endif


  IsScolRunning
  if
    Quit SCOLRUNNING ABORT_TTL
  endif

  ShowFile "Licence.txt"
  if
  else
    Quit ABORT_MSG ABORT_TTL
  endif

  DetectSCOL
  if
    set DSTDIR SCOLpath
    set INSTYPE "UPDATE"
    MsgBoxOk CLOSEBROWSERBEFORE ADVISE_TTL 
    goto "CheckUsmDotIni"
  else
    set INSTYPE "INSTALL"
    goto "ScolInstall"
  endif

[CheckUsmDotIni]
;  set USM_INI DSTDIR
;  strcat USM_INI "\usm.ini"
;  exist USM_INI
;  if
;  else
    goto "AskNewest"
;  endif

[AskNewest]
  IsScolUpdated VERSION
  if
    quit ABORTUPDATE_MSG ABORTUPDATE_TTL
  else
    goto "Update"
  endif

[Update]
  Goto "UpdateFiles"

[UpdateFiles]
  MkDir DSTDIR
;  CopyDir2Dest "Cache"
  CopyDir2Dest "Plugins"
  CopyDir2Dest "Partition"
  ParseFile "usmress.diff" "ParseUsmRess"
  goto "CommonFiles"

[ParseUsmRess]
  set usmress_ini DSTDIR
  strcat usmress_ini "\usmress.ini"
  findInFile TempStripped usmress_ini
  if
  else
    appendFile TempLine usmress_ini
  endif

[ScolInstall]
  ShowWindow
  IShowInstallDlg
  if 
    set tmp DSTDIR
    strcat tmp "\usm.ini"
    delete tmp
    goto "ScolInstallOk"
  else
    Quit ABORT_MSG ABORT_TTL
  endif

[ScolInstallOk]
  Goto "ScolInstallFiles"

[ScolInstallFiles]
  MkDir DSTDIR
  CopyDir2Dest "Cache"
  CopyDir2Dest "Plugins"
  CopyDir2Dest "Partition"
  Copy "UsmRess.ini"
  Copy "NSproto.exe"
  strcmp INSTYPE "UPDATE"
  if
  else
    GetScolSettings
  endif

  IsSilent
  if
  else
    goto "RegNSProto"
  endif

  goto "CommonFiles"

[RegNSProto]
;  strcmp NETSCAPEDEFAULT "YES"
;  if
    set EXENAME DSTDIR
    strcat EXENAME "\"
    strcat EXENAME "NSproto.exe"
    set EXEARGS "/RegServer"
    SetText REGNETSCAPE_MSG
    runwait EXENAME EXEARGS
;  endif


[CommonFiles]
; List of common operations :

;prepare for copying bookmarks and customs if not present

  set tempDSTDIR DSTDIR
  set ETC DSTDIR
  strcat ETC "\Partition\locked\etc"
  set DSTDIR ETC
;copy customs if not present
  set FIND ETC
  strcat FIND "\custom.txt"
  exist FIND
  if
  else
    Copy "custom.txt"
  endif
;copy bookmarks if not present
  set FIND ETC
  strcat FIND "\bookmark.txt"
  exist FIND
  if
  else
    Copy "bookmark.txt"
  endif
;cleaning
  set DSTDIR tempDSTDIR

  Copy "UsmWin.exe"
  Copy "licence.txt"

  set temp SRCDIR
  set SRCDIR rootSRCDIR
  Copy "scolsetup.exe"
  Copy "setup.ini"
  Copy "setup.English.txt"
  Copy "setup.French.txt"
  Copy "setup.German.txt"
  Copy "setup.Dutch.txt"
  Copy "setup.Spanish.txt"
  Copy "setup.Italian.txt"
  Copy "setup.ini"
  set SRCDIR temp

  ; copy the netscape files for further use... (eventually a manual install...)
  Copy "npScol.dll"
  Copy "ScolNet.class"
  Copy "ScolObserver.class"
  Copy "ScolTest.class"  
  ; most important : DllScol.dll
  Copy "scol-2000-03-21-p10.dll"
  Copy "AXScol.dll"
  ; uninstall any previous instance of the scol dll, it does no more have to be in the system dir
  delete "DllScol.dll" SYSDIR

  goto "NetscapeInstall"

  Register "AXscol.dll" DSTDIR
;  Register "plugins\xtension.dll" DSTDIR
  MkPgmGroup PROGRAMGROUP
  MkLink "usmwin.exe" "Scol"
  CreateDesktopLink "usmwin.exe" "Scol"
  set LINKARG "/autostart"
  CreateStartLink "usmwin.exe" "Scol"
  MkLink "licence.txt" Licence_agreement_LNK
  MkLink "scolsetup.exe" Uninstall_SCOL_LNK
  set uninstall DSTDIR
  strcat uninstall "\scolsetup.exe "
  strcat uninstall DSTDIR
  SetUninstall "Cryo-Networks - SCOL" uninstall
  set setup DSTDIR
  strcat setup "\setup.txt"
  appendfile "Installed OK" setup
  set setup DSTDIR
  strcat setup "\scolapp.ini"
  exist setup
  if
  else
    appendfile "[uninstall]" setup
    appendfile ";Any scol application should set its uninstall script here:" setup
    appendfile "" setup
  endif
  ImportOldScol "scol-2000-03-21-p10.dll SCOLWinMain" VERSION
  goto "FinalRun"
  InstallSuccess
  quit SUCCESS_MSG SUCCESS_TTL

[NetscapeInstall]
  ; Install Plugin for Communicator :
  set temp DSTDIR
  strcmp NETSCAPEPATH ""
  if
  else
    set DSTDIR NETSCAPEPATH
    strcat DSTDIR "\Program"
    goto "NetscapeFiles"
    goto "TestSearchNetscape"
  endif
  set DSTDIR temp

[TestSearchNetscape]
IsSilent
if 
else
  goto "SearchNetscape"
endif

[SearchNetscape]
  ; Search all occurrences of Netscape :
  set nsfound NETSCAPENOTFOUND1_MSG
  strcat nsfound DSTDIR
  strcat nsfound NETSCAPENOTFOUND2_MSG
  MsgBoxYesNo nsfound NETSCAPENOTFOUND_TTL
  if 
    ApplyOnFiles "netscape.exe" "_NetscapeFiles"
  endif

[NetscapeFiles]
  ; Files to copy for the netscape plugin:
  strcat DSTDIR "\plugins"
  Copy "npScol.dll"
  Copy "ScolNet.class"
  Copy "ScolObserver.class"
  Copy "ScolTest.class"

[_NetscapeFiles]
  set nstst NETSCAPEPATH 
  strcat nstst "\Program"
  stricmp nstst DSTDIR
  if
  else
    goto "__NetscapeFiles"
  endif

[__NetscapeFiles]
  set msg INSTALLTHISNETSCAPE_MSG1
  strcat msg DSTDIR
  strcat msg INSTALLTHISNETSCAPE_MSG2
  MsgBoxOKCancel msg INSTALLTHISNETSCAPE_TTL
  if
    goto "NetscapeFiles"
  endif

[FinalRun]
  set EXENAME "usmwin.exe"
  set EXEARGS "/INSTALL"
  run EXENAME EXEARGS

;**********************************************************
[Uninstall]
  GetSystemVars
  goto "Init"

  include languagefile "InitUninstall"

  MsgBoxOKCancel UNINSTALL_MSG SETUPNAME
  If
    ; Default variables set :
    Goto "UFiles"
    DelUninstall "Cryo-Networks - SCOL"
    quit SUCCESFULL_MSG SUCCESFULL_TTL
  Else
    quit ABORT_MSG ABORT_TTL
  Endif

[UFiles]
  IsScolRunning
  if
    Quit SCOLRUNNING ABORT_TTL
  endif

  ; List of file operations :
  UnRegister "AXscol.dll" SRCDIR
;  UnRegister "plugins\xtension.dll" SRCDIR
  delete "dllscol.dll" SYSDIR

  set EXENAME DSTDIR
  strcat EXENAME "\"
  strcat EXENAME "NSproto.exe"
  set EXEARGS "/UnRegServer"
  SetText REGNETSCAPE_MSG
  runwait EXENAME EXEARGS

  ; Uninstall Netscape Files:
  goto "NetscapeUninstall"

  DelPgmGroup PROGRAMGROUP
  DestroyStartLink "Scol"
  DestroyDesktopLink "Scol"

  Deltree "plugins"
  Deltree "Cache"
  Deltree "partition\Locked"
  Deltree "partition\Comm"
  DeleteAllFiles SRCDIR
  CleanRegistry

[NetscapeUninstall]
  ; Uninstall Plugin for Communicator :
  set temp DSTDIR
  strcmp NETSCAPEPATH ""
  if
  else
    set DSTDIR NETSCAPEPATH
    strcat DSTDIR "\Program"
    goto "UNetscapeFiles"
    goto "SearchDelNetscape"
  endif
  set DSTDIR temp

[SearchDelNetscape]
  strcat INSTALLTHISNETSCAPE_MSG1 NETSCAPEPATH
  strcat INSTALLTHISNETSCAPE_MSG1 INSTALLTHISNETSCAPE_MSG2  
MsgBoxOKCancel INSTALLTHISNETSCAPE_MSG1 SEARCH_TTL
  if
    ApplyOnFiles "netscape.exe" "_UNetscapeFiles"
  endif

[UNetscapeFiles]
  ; Files to delete for the netscape plugin:
  strcat DSTDIR "\plugins"
  delete "npScol.dll" DSTDIR
  delete "ScolNet.class" DSTDIR
  delete "ScolObserver.class" DSTDIR
  delete "ScolTest.class" DSTDIR

[_UNetscapeFiles]
  set nstst NETSCAPEPATH 
  strcat nstst "\Program"
  stricmp nstst DSTDIR
  if
  else
    goto "UNetscapeFiles"
  endif

