/*
**$VER: DzA_PGP5  (26.04.1998) CopyRight (C) DzAŠ
**
**  $Date:26.04.1998$
**  $:SoLoNGAmiGA:$
*/
Options failat 21
NL = '0a'x
IF ~SHOW('LIBRARIES','rexxreqtools.library') THEN DO
IF ~ADDLIB('rexxreqtools.library',10,-30,0) THEN DO
SAY 'Cant Find <RexxReqtools.library> Please Install...=('
EXIT(10)
END
END               
if exists('c:pgpe') then call npcommand
call nocommand
npcommand: 
if exists('c:pgpv') then call nppcommand
call nocommand
nppcommand:
if exists('c:pgpk') then call stcommand
nocommand:
call rtezrequest("PGP Files are Missing in C...",, 
                 "Hmm","DzA",'rt_reqpos=reqpos_centerscr rtez_flags=ezreqf_centertext')
/* DzAŠ Start */
stcommand:
call rtezrequest("Welcome to GUI for PGP5",, 
                      "DzA","DzA",'rt_reqpos=reqpos_centerscr rtez_flags=ezreqf_centertext')
acommand:
call rtezrequest("Choose...",, 
                      "PGP|Options|_Quit","DzA",'rt_reqpos=reqpos_centerscr rtez_flags=ezreqf_centertext')

if rtresult == 0 then exit
if rtresult == 2 then call keycommand 
if rtresult == 1 then call pgpcommand

/* PGP */
pgpcommand:
call rtezrequest("Choose Method...",, 
                      "_Encrypt|_Decrypt|_Cancel","DzA",'rt_reqpos=reqpos_centerscr rtez_flags=ezreqf_centertext')

if rtresult == 0 then call acommand
if rtresult == 1 then call encommand
if rtresult == 2 then call decommand


/* KEY */
keycommand:
call rtezrequest("Key Options...",, 
                      "_Add|_Generate|_Extract|_Edit|_List|_Remove|_Cancel","DzA",'rt_reqpos=reqpos_centerscr rtez_flags=ezreqf_centertext')

if rtresult == 0 then call acommand
if rtresult == 1 then call addcommand
if rtresult == 2 then call gencommand
if rtresult == 3 then call excommand
if rtresult == 4 then call edcommand
if rtresult == 5 then call licommand
if rtresult == 6 then call recommand

/* Commands */

/**/
encommand:
a=ab
file = rtfilerequest('Ram:', , "Choose File to Encrypt", ,,
             "rt_reqpos=reqpos_centerscr rtfi_flags = freqf_patgad|freqf_selectdirs|
freqf_selectdirs|freqf_multiselect rtfi_matchpat=#?|#?.info")

if file = '' then call errcommand

rfile = left(file,9)
if rfile='Ram Disk:' then file = delstr(file,4,5)

idcommand:
user = rtgetstring("", , "EnteR Key File to Use","DzA")
if user == "" then
  call rtezrequest("You Entered Nothing!", "Hmm","DzA")
if user = '' then call idcommand

fcommand:
a=aa
dir = rtfilerequest('Ram:', , "Path for File", ,,
            "rt_reqpos=reqpos_centerscr rtfi_flags = freqf_save|freqf_selectdirs")

if dir = '' then call errcommand
if dir ='Ram:' then call errcommand

ldir = left(dir,9)
if ldir='Ram Disk:' then dir = delstr(dir,4,5)
address command
'pgpe -r' user file '-o' dir
call gocommand
end
/**/
decommand:
a=ac
file = rtfilerequest('Ram:', , "Choose File to Decrypt", ,,
             "rt_reqpos=reqpos_centerscr rtfi_flags = freqf_patgad|freqf_selectdirs|
freqf_selectdirs|freqf_multiselect rtfi_matchpat=#?|#?.info")

if file = '' then call errcommand

rfile = left(file,9)
if rfile='Ram Disk:' then file = delstr(file,4,5)

ffcommand:
a=bb
dir = rtfilerequest('Ram:', , "Path for File", ,,
            "rt_reqpos=reqpos_centerscr rtfi_flags = freqf_save|freqf_selectdirs")

if dir = '' then call errcommand
if dir ='Ram:' then call errcommand

ldir = left(dir,9)
if ldir='Ram Disk:' then dir = delstr(dir,4,5)
address command
'pgpv' file '-o' dir
call gocommand
end
/**/
addcommand:
a=ad
file = rtfilerequest('Ram:', , "Choose Key File(s) to Add", ,,
             "rt_reqpos=reqpos_centerscr rtfi_flags = freqf_patgad|freqf_selectdirs|
freqf_selectdirs|freqf_multiselect rtfi_matchpat=#?|#?.info")

if file = '' then call errcommand

rfile = left(file,9)
if rfile='Ram Disk:' then file = delstr(file,4,5)

address command
'pgpk -a' file 
call gocommand
end
/**/
gencommand:
address command
'pgpk -g' 
call gocommand 
end
/**/
excommand:
a=ae
user = rtgetstring("", , "EnteR Key File to Use","DzA")
if user == "" then
  call rtezrequest("You Entered Nothing!", "Hmm","DzA")
if user = '' then call errcommand

fffcommand:
a=cc
dir = rtfilerequest('Ram:', , "Path for File", ,,
            "rt_reqpos=reqpos_centerscr rtfi_flags = freqf_save|freqf_selectdirs")

if dir = '' then call errcommand
if dir ='Ram:' then call errcommand

ldir = left(dir,9)
if ldir='Ram Disk:' then dir = delstr(dir,4,5)
address command
'pgpk -x' user '-o' dir 
call gocommand 
end
/**/
edcommand:
address command
'pgpk -e' 
call gocommand 
end
/**/
licommand:
address command
'pgpk -l' 
call gocommand 
end
/**/
recommand:
address command
'pgpk -r' 
call gocommand 
end

/* Error */
errcommand:
call rtfreefilebuffer()
call rtezrequest("Hmm... Don't Think So...",,
      "_Oops|_Cancel","DzA",'rt_reqpos=reqpos_centerscr')

if rtresult == 0 then call acommand
select
when a=ab then call encommand
when a=ac then call decommand
when a=ad then call addcommand
when a=ae then call excommand
when a=aa then call fcommand
when a=bb then call ffcommand
when a=cc then call fffcommand
otherwise
end

/* GoAgain */
gocommand:
call rtfreefilebuffer()
call rtezrequest("Continue...",,
      "_Sure|_Quit","DzA",'rt_reqpos=reqpos_centerscr')

if rtresult == 0 then exit
if rtresult == 1 then call acommand 
end
exit
