added a function which tries to load the pub key
authorAndrew Engelbrecht <sudoman@ninthfloor.org>
Wed, 22 Jul 2015 23:38:58 +0000 (19:38 -0400)
committerAndrew Engelbrecht <sudoman@ninthfloor.org>
Mon, 7 Dec 2015 18:28:39 +0000 (13:28 -0500)
edward

diff --git a/edward b/edward
index 63cfb0b53c4f6abfd3a034e79688e97ca1a7d09e..510ab0fd83330d5323c85b19b720e3f5e6821948 100755 (executable)
--- a/edward
+++ b/edward
@@ -122,7 +122,7 @@ def main ():
     replyinfo_obj.replies = lang.replies
 
     prepare_for_reply(email_struct, replyinfo_obj)
-
+    encrypt_to_key = get_key_from_fp(replyinfo_obj, gpgme_ctx)
     reply_plaintext = write_reply(replyinfo_obj)
 
     print(reply_plaintext)
@@ -327,6 +327,12 @@ def prepare_for_reply (eddymsg_obj, replyinfo_obj):
 
     do_to_eddys_pieces(prepare_for_reply_pieces, eddymsg_obj, replyinfo_obj)
 
+    if replyinfo_obj.target_key == None:
+        replyinfo_obj.target_key = replyinfo_obj.fallback_target_key
+
+    if replyinfo_obj.target_key == None:
+        replyinfo_obj.no_public_key = True
+
 
 def prepare_for_reply_pieces (eddymsg_obj, replyinfo_obj):
 
@@ -396,6 +402,26 @@ def flatten_payloads (eddymsg_obj):
     return flat_string
 
 
+def get_key_from_fp (replyinfo_obj, gpgme_ctx):
+
+    if replyinfo_obj.target_key != None:
+        try:
+            encrypt_to_key = gpgme_ctx.get_key(replyinfo_obj.target_key)
+            return encrypt_to_key
+
+        except:
+            pass
+
+    # no available key to use
+    replyinfo_obj.target_key = None
+    replyinfo_obj.fallback_target_key = None
+
+    replyinfo_obj.no_public_key = True
+    replyinfo_obj.public_key_received = False
+
+    return None
+
+
 def write_reply (replyinfo_obj):
 
     reply_plain = ""