; $VER: STFax-Update 1.5 (11.8.98)
;
; Script by Simone Tellini <wiz@pragmanet.it>
;

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

(set @app-name     "STFax Professional")
(set OldVersion    "3.0")
(set NewVersion    "3.6b")
(set OldFile       "STFax:STFax")
(set OldSize       370772)
(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.\n\n"
           "Make sure you installed the plain 68000 version\n"
           "(the patched one will be a 020+ optimised version anyway)")
)

(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 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 "italiano")
        (confirm)
    )
)

(complete 60)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;  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)
    )

    (complete 70)

    (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)
    )

    (complete 85)

    (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)

