; $VER: STFax-Update 1.6 (17.8.99)
;
; Script by Simone Tellini <wiz@vapor.com>
;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;  set initial variables
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(set @app-name     "STFax Professional")
(set OldVersion    "4.1")
(set NewVersion    "4.5")
(set OldFile       "STFax:STFax")
(set OldSize       602116)
(set PatchFile     "STFax.patch")
(set @error-msg    "An unexpected error has occured. Installation aborted.")
(set @default-dest "STFax:")

(if (= (exists OldFile (noreq)) 0)
    (if (= (exists (cat OldFile ".old") (noreq)) 0)
        (abort @app-name OldVersion " has not been found!")
        (set OldFile (cat OldFile ".old"))
    )
)

(if (<> (getsize OldFile) OldSize)
    (abort @app-name " has a different size than the expected one, "
           "patch can't be applied.")
)

(complete 0)

(welcome)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;  Patch the file
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(if (<> OldFile "STFax:STFax.old")
  (
    (if (exists "STFax:STFax.old")
        (delete "STFax:STFax.old")
    )

    (rename OldFile "STFax:STFax.old")

    (set OldFile (cat OldFile ".old"))
  )
)

(complete 20)

(working "Applying the patch...")

(run (cat "Patch " OldFile " STFax:STFax " PatchFile)
    (prompt "Applying the patch...")
)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;  Copy FaxViewer / Phonebook
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(if (exists "Phonebook")
    (copyfiles
        (source "Phonebook")
        (dest "STFax:")
    )
)

(if (exists "FaxViewer")
    (copyfiles
        (source "FaxViewer")
        (dest "STFax:")
    )
)

(complete 25)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;  Copy printer driver
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(if (exists "Devs/Printers/STFaxPrt")
    (copyfiles
        (source "Devs/Printers/STFaxPrt")
        (dest "DEVS:Printers")
    )
)

(complete 33)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;  Copy docs, if they exists
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(if (exists "STFax.guide")
    (copyfiles
        (source "STFax.guide")
        (dest "STFax:")
    )
)

(complete 35)

(if (exists "History.txt")
    (copyfiles
        (source "History.txt")
        (dest "STFax:")
    )
)

(complete 40)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;  Copy modem init strings
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(if (exists "Data/ModemInit.cfg")
    (copyfiles
        (source "Data/ModemInit.cfg")
        (dest "STFax:Data")
    )
)

(complete 45)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;  Install new catalogs
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(if (exists "Catalogs")
    (copyfiles
        (prompt "Updating catalog files")
        (help @copyfiles-help)
        (source "Catalogs")
        (dest "STFax:Catalogs")
        (choices "deutsch" "italiano")
        (confirm)
    )
)

(complete 60)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;  Copy libraries
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(if (exists "libs/STFax.library")
    (copylib
       (prompt "Installing a new STFax library...")
       (help   "This will install the STFax.library")
       (source "libs/STFax.library")
       (dest   "STFax:libs")
       (confirm)
    )
)

(if (exists "libs/vapor_toolkit.library")
    (copylib
       (prompt "Installing a new Vapor Toolkit library...")
       (help   "This will install the vapor_toolkit.library")
       (source "libs/vapor_toolkit.library")
       (dest   "LIBS:")
       (confirm)
    )
)

(complete 70)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;  Copy SpeedBar.mcc
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


(if (exists "MUI/SpeedBar.mcc")
    (
        (copylib
           (prompt "Installing updated MUI classes... (SpeedBar.mcc)")
           (help   "This will install some MUI classes needed by STFax")
           (source "MUI/SpeedBar.mcc")
           (dest   "MUI:Libs/MUI")
           (confirm)
        )

        (copylib
           (prompt "Installing updated MUI classes... (SpeedBar.mcp)")
           (help   "This will install some MUI classes needed by STFax")
           (source "MUI/SpeedBar.mcp")
           (dest   "MUI:Libs/MUI")
           (confirm)
        )

        (copylib
           (prompt "Installing updated MUI classes... (SpeedButton.mcc)")
           (help   "This will install some MUI classes needed by STFax")
           (source "MUI/SpeedButton.mcc")
           (dest   "MUI:Libs/MUI")
           (confirm)
        )

        (copylib
           (prompt "Installing updated MUI classes... (SpeedBarCfg.mcc)")
           (help   "This will install some MUI classes needed by STFax")
           (source "MUI/SpeedBarCfg.mcc")
           (dest   "MUI:Libs/MUI")
           (confirm)
        )
    )
)

(complete 80)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;  Copy Textinput.mcc
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(if (exists "MUI/Textinput.mcc")
    (
        (copylib
           (prompt "Installing updated MUI classes... (Textinput.mcc)")
           (help   "This will install some MUI classes needed by STFax")
           (source "MUI/Textinput.mcc")
           (dest   "MUI:Libs/MUI")
           (confirm)
        )

        (copylib
           (prompt "Installing updated MUI classes... (Textinput.mcp)")
           (help   "This will install some MUI classes needed by STFax")
           (source "MUI/Textinput.mcp")
           (dest   "MUI:Libs/MUI")
           (confirm)
        )

        (copylib
           (prompt "Installing updated MUI classes... (Textinputscroll.mcc)")
           (help   "This will install some MUI classes needed by STFax")
           (source "MUI/Textinputscroll.mcc")
           (dest   "MUI:Libs/MUI")
           (confirm)
        )
    )
)

(complete 90)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;  End
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(message @app-name " has been upgraded from version " OldVersion " to " NewVersion
         "\n\nThe old STFax version has been renamed as STFax:STFax.old")

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;  All done.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(complete 100)

