-- Eudora-GPG-Verify version 0.008 -- Richard Chang -- Read the Notes file. Use at your own risk. -- If you make money with this, give me some. Otherwise free. -- -- Version .001: new -- Version .002: ignores return value from GPG, so BAD signature message -- can be still be appended to the end of the message. -- Version .003: -- 1. Cleaned up code, uses subroutines for reading and writing -- 2. Figured out how to get user's home directory. -- 3. Uses 'do shell script' instead of 'system'. -- 4. Better error checking and reporting. -- Version .004: -- 1. Single quotes around Unix directory name. -- 2. Uses "rm -P" to overwrite and remove files. (Thanks: Fredrik Jonsson.) -- Version .005: -- 1. Uses "POSIX path" to compute UnixDocumentsDir -- 2. Uses "character i" instead of "text item i" -- Version .006 -- Figured out how to make new folder in "Temporary Items" -- Version .007 -- 1. More error checking for 0 length messages and files. -- Version .008 -- 1. Put CleanUp in a function -- 2. Uses shred -uz if available -- 3. Fixed escalating tempxxx directory name problem? -- 4. Moved common functions into a shared file set CR to ASCII character 13 set LF to ASCII character 10 set CR to ASCII character 13 set LF to ASCII character 10 -- Load library tell application "Finder" set EudoraScriptsFolder to folder "Contents:MacOS:Eudora Stuff:Scripts:" of (path to me) set LibFile to file "Eudora-GPG Stuff:Eudora-GPG-Lib" of EudoraScriptsFolder end tell set EGPGLib to load script file (LibFile as string) tell EGPGLib to set {theFolder, QuotedUnixDir} to MakeTempFolder() -- Get body of current message tell application "Eudora" to set OriginalMesg to body of message 0 if length of OriginalMesg = 0 then display dialog "Empty message body! No processing done." buttons {"OK"} default button "OK" return end if tell EGPGLib to WriteUnixFile(theFolder & "verifyme", OriginalMesg) -- set up GPG command and execute it via "do shell script" command -- the trailing "; cd" causes error value returned by gpg to be ignored set doGPG to "cd " & QuotedUnixDir & "; /usr/local/bin/gpg --verify -q --batch verifyme >& output; cd" set CleanUpFiles to "verifyme output" try do shell script doGPG on error -- this shouldn't happen very much with verify tell EudoraGPG to set ErrorMesg to ReadUnixFile(theFolder & "output") display dialog "Warning!. GPG Output:" & CR & CR & ErrorMesg tell EGPGLib to CleanUp(theFolder, CleanUpFiles) return end try set OutputFile to theFolder & "output" tell application "Finder" if (file OutputFile exists) then tell EGPGLib to set response to ReadUnixFile(theFolder & "output") set separator1 to "-----BEGIN GPG OUTPUT-----" & CR set separator2 to "-----END GPG OUTPUT-----" & CR tell application "Eudora" to set (body of message 0) to OriginalMesg & CR & CR & separator1 & response & separator2 else tell application "Eudora" to display dialog "File disappeared: " & OutputFile end if end tell tell EGPGLib to CleanUp(theFolder, CleanUpFiles) return