-- Eudora-GPG-Encrypt 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 .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', but still need 'system' to ask for passphrase. -- 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" -- 3. Adds ParseToField subroutine to extract recipient from message -- 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 -- 5. Bug user about empty recipient name 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 & "mesg", OriginalMesg) -- get name of recipient try tell EGPGLib to set recipient to GetRecipient() on error display dialog "Never mind. Your message was not altered." buttons {"OK"} default button "OK" tell EGPGLib to CleanUp(theFolder, "mesg") return end try -- set up GPG command and execute it via "do shell script" command set CleanUpFiles to "mesg output mesg.asc" set doGPG to "cd " & QuotedUnixDir & "; /usr/local/bin/gpg -a -e -r '" & recipient & "' -q --batch mesg >& output" try do shell script doGPG on error tell EGPGLib to set ErrorMesg to ReadUnixFile(theFolder & "output") display dialog "Could not encrypt the message. GPG Output:" & CR & CR & ErrorMesg tell EGPGLib to CleanUp(theFolder, CleanUpFiles) return end try set EncryptedFile to theFolder & "mesg.asc" tell application "Finder" if (file EncryptedFile exists) then tell EGPGLib to set EncryptedMesg to ReadUnixFile(EncryptedFile) tell application "Eudora" to set (body of message 0) to EncryptedMesg else tell application "Eudora" to display dialog "File disappeared: " & EncryptedFile end if end tell tell EGPGLib to CleanUp(theFolder, CleanUpFiles) return