/*

   $VER: PGPDecrypt.intui 1.0 (27.8.95)

   Author:
    Matthias Scheler (tron@lyssa.owl.de)

   Function:
    decrypts the PGP message show in IntuiNews's message window.

   History:
    0.1   initial version
    0.2   decided to get rid of this strange AMOK style header and
          went back to my good old standard
    0.3   uses new "EXEC" command
    1.0   released with IntuiNews 1.3

   Requires:
    PGP 2.6ui (2.3a didn't work in every case) in command path of ARexx

   Example for "ums.config":
    ( IntuiNews.Rexx
	...
        "MessageWindow           F4      PGPDecrypt.intui\n"
	...
    )

*/

/* Exit if Message Window is not active. */

OPTIONS RESULTS

STATUS
IF RESULT~="MESSAGE" THEN EXIT 5

/* Ask the user for the PGP phrase. */

'GETSTRING TITLE "PGP Decrypt" LABEL "_Phrase" SECRET'
IF RESULT="RESULT" THEN EXIT 5
Phrase=RESULT

/* We get IntuiNews's message number, ... */

GETMSGNUM
MsgNum=RESULT

/* ... save the message, ... */

'SAVEMSGBODY' MsgNum 'TO T:IntuiNews.pgp'

/* ... call PGP, ... */

'EXEC SetEnv PGPPASS "'||Phrase||'"'
'EXEC pgp +BATCHMODE T:IntuiNews.pgp -o T:IntuiNews.asc'
'EXEC UnSetEnv PGPPASS'

/* ... and show the decrypted message. */

'REPLACEMSGBODY WITH T:IntuiNews.asc'

/* cleanup */

'EXEC Delete T:IntuiNews.(asc|pgp) QUIET'
