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

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

(set @app-name "STFax Professional")
(set OldVersion "3.0")
(set NewVersion "3.1")
(set OldFile "STFax:STFax")
(set @error-msg "An unexpected error has occured. Installation aborted.")

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

(complete 0)

(welcome)

(if (not (patmatch "68020|68030|68040|68060" (database "cpu")))
    (if (= 1 (askbool
                (prompt "Are you using the 68020 or above version of " @app-name "?\n")
                (help "A 68020 or better processor has been detected in this "
                      "machine. You should answer Yes if you have installed "
                      "the 00 optimized version of " @app-name "\n")
                (default 1)
             )
        )
        (set PatchFile "STFax.020.patch")
        (set PatchFile "STFax.patch")
    )
)

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

(rename OldFile "STFax:STFax.old")

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

(complete 20)

(working "Applying the patch...")

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

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;  Copy History file, if it exists
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

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

(complete 40)

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

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

