; $VER: Install_ASWPOP 1.01 (06.02.96) by Brian Woodward
; Script to install ASWPOP


; Choose default tool for guide, depending on user's OS version
(set osversion  (/ (getversion) 65536))
(if (>= osversion 39)
   (set guide_reader "MultiView") 
   (set guide_reader "AmigaGuide")
)
(set @app-name "ASWPOP")
(set @default-dest "AMITCP:")
(set #about  "\n\n\nWelcome to the ASWPOP v1.2 Installer utility\n\nASWPOP v1.2 by Andrew S. Walker\n\nInstaller by Brian Woodward \n\n\n\n\nSupport webpage: http://homepages.enterprise.net/andyw/asw.html")

(message #about)
(welcome)

(set installed "")

(set aswpop-dest
        (askdir (prompt "Please select directory to put aswpop in\n (a directory will be created)\n")
                        (help @askdir-help)
                        (default @default-dest)
        )
)

(set aswpop_dir (tackon aswpop-dest "aswpop"))

(set @default-dest (tackon aswpop-dest "aswpop"))

(if (NOT (= 2 (exists aswpop_dir)))
        (makedir aswpop_dir (infos))
)

(copyfiles (prompt "Copying aswpop drawer")
                   (help @copyfiles-help)
           (source "aswpop/")
                   (choices "aswpop"
                            "aswpop.acton"
                                    "aswpex.ircmsg"
                                    "aswpin.autorep"
                                    "aswpop.guide"
                   )
                   (dest aswpop_dir)
                   (infos)
                   (optional oknodelete force)
)

(set server (askstring  (prompt "\n\nPlease enter the name of your POP3 mail server\n\nexample: mail.enterprise.net")
                                                (help "\n\n\n\n This is the name of the server to contact for your   mail.  This must be a POP3 server and should have    been given you by your ISP")
                                                (default "")
                        )
)
(set server (cat "POPSERVER " server))
(set popport "POPPORT 110")

(set usrname (askstring (prompt "\n\nPlease enter your username\n This is your ISP login name.\n\nexample: woodward")
                                                (help "\n\n\n\nThis is the username which you use to login to your ISP")
                                                (default "")
                         )
)
(set usrname (cat "USERNAME "usrname))

(set passwrd (askstring (prompt "\n\nPlease enter your password.\n This is the same as your login password\n\nexample: -secret-")
                                                (help "\n\n\n\nThis is the password which you use to login to your ISP")
                                                (default "")
                         )
)
(set passwrd (cat "PASSWORD "passwrd))

(set mailpath (askfile  (prompt "\nPlease select the file to use as a mailbox.\nIf the file doesn't exist, type in a new filename")
                                                (help "\n\n\nThis is a file which aswpop will download your e-mail to")
                                                (default "UUMAIL:")
                          )
)
(set mailpath (cat "MAILBOX "mailpath))

(set aswdir (cat "ASWPOPPATH "aswpop_dir))

(set startmode (askchoice (prompt "\nPlease choose your ASWPOP startup mode :-")
                                                  (help "\n\n\nASWPOP can either be started to check for new mail continuously or just once")
                                                  (choices "Continuous check mode"
                                                                   "Single check mode")
                                                  (default 0)
                           )
)

(if (= startmode "0")
        (set checkdel (asknumber (prompt "\n\nPlease enter the delay (in minutes) between checks")
                                                         (help "\n\nThis is the delay ASWPOP will wait between checks for new mail")
                                                         (default 2)
                                  )
        )
)

(set prepull (askstring (prompt "\nEnter the name of a command for ASWPOP to execute    before pulling your mail.                             \n\nLeave as NONE if you don't want this feature.")
                                                 (help "\n\nThe command entered here will be executed before ASWPOP has been used to pull mail from the server")
                                                 (default "NONE")
                          )
)
(set prepull (cat "PREPULL " prepull))

(set postpull (askstring (prompt "\nEnter the name of a command for ASWPOP to execute after pulling mails.                             \n\nLeave as NONE if you don't want this feature.")
                                                 (help "\n\nThe command entered here will be executed after ASWPOP has been used to pull mail from the server")
                                                 (default "NONE")
                          )
)
(set postpull (cat "POSTPULL " postpull))


(if (= startmode "0")
        (set startmode "STARTUPMODE CONTCHECK")
)

(if (= startmode "STARTUPMODE CONTCHECK")
        (set startopts (cat "STARTUPMODEOPTS " checkdel))
)

(if (= startmode "STARTUPMODE CONTCHECK")
        (message "\n User variables are :-\n\n" server "\n" usrname "\n" passwrd "\n" mailpath "\n" aswdir "\n" startmode "\n" startopts "\n" prepull "\n" postpull "\n\nClick 'Proceed' to write prefs file" )
)
                                                  
(if (= startmode "1")
        (set startmode "STARTUPMODE ONCE")
)

(if (= startmode "STARTUPMODE ONCE")
        (message "\n User variables are :-\n\n" server "\n" usrname "\n" passwrd "\n" mailpath "\n" aswdir "\n" startmode "\n" prepull "\n" postpull "\n\nClick 'Proceed' to write prefs file" )
)

(textfile (prompt "\n\nWriting ASWPOP configuration")
                  (help "\n\nWriting the config file to S:aswpop.prefs")
                  (dest "S:aswpop.prefs")
                  (append server) (append "\n")
                  (append popport) (append "\n")
                  (append usrname) (append "\n")
                  (append passwrd) (append "\n")
                  (append mailpath) (append "\n")
                  (append aswdir) (append "\n")
                  (append startmode) (append "\n")
                  (append startopts) (append "\n")
                  (append prepull) (append "\n")
                  (append postpull) (append "\n")
)

(set installed "YES")   

(if (= installed "YES") 
   (exit ("This installation has only set the variables necessary to run ASWPOP. To fully exploit all of ASWPOP's advanced features please read aswpop.guide\n\nPlease enjoy ASWPOP and watch out for more updates\n\n           Brian Woodward"))
   (exit)
)   

                   
