* EasyPG: Version 0.0.2 released.
[elisp/epg.git] / epg.el
diff --git a/epg.el b/epg.el
index 4604269..d73645a 100644 (file)
--- a/epg.el
+++ b/epg.el
@@ -39,7 +39,7 @@
   :group 'epg
   :type 'string)
 
-(defconst epg-version-number "0.0.1")
+(defconst epg-version-number "0.0.2")
 
 (defvar epg-user-id nil
   "GnuPG ID of your default identity.")
@@ -1045,6 +1045,11 @@ This function is for internal use only."
             (equal (epg-signature-key-id signature) string))
        (epg-signature-set-status signature 'no-pubkey))))
 
+(defun epg--time-from-seconds (seconds)
+  (let ((number-seconds (string-to-number (concat seconds ".0"))))
+    (cons (floor (/ number-seconds 65536))
+         (floor (mod number-seconds 65536)))))
+
 (defun epg--status-ERRSIG (context string)
   (if (string-match "\\`\\([^ ]+\\) \\([0-9]+\\) \\([0-9]+\\) \
 \\([0-9A-Fa-f][0-9A-Fa-f]\\) \\([^ ]+\\) \\([0-9]+\\)"
@@ -1065,7 +1070,7 @@ This function is for internal use only."
         (string-to-number (match-string 4 string) 16))
        (epg-signature-set-creation-time
         signature
-        (match-string 5 string)))))
+        (epg--time-from-seconds (match-string 5 string))))))
 
 (defun epg--status-VALIDSIG (context string)
   (let ((signature (car (epg-context-result-for context 'verify))))
@@ -1080,10 +1085,10 @@ This function is for internal use only."
        (match-string 1 string))
       (epg-signature-set-creation-time
        signature
-       (match-string 2 string))
+       (epg--time-from-seconds (match-string 2 string)))
       (epg-signature-set-expiration-time
        signature
-       (match-string 3 string))
+       (epg--time-from-seconds (match-string 3 string)))
       (epg-signature-set-version
        signature
        (string-to-number (match-string 4 string)))
@@ -1162,7 +1167,8 @@ This function is for internal use only."
 (defun epg--status-KEYEXPIRED (context string)
   (epg-context-set-result-for
    context 'error
-   (cons (list 'key-expired (cons 'expiration-time string))
+   (cons (list 'key-expired (cons 'expiration-time
+                                 (epg--time-from-seconds string)))
         (epg-context-result-for context 'error))))
 
 (defun epg--status-KEYREVOKED (context string)
@@ -1213,7 +1219,7 @@ This function is for internal use only."
              (string-to-number (match-string 2 string))
              (string-to-number (match-string 3 string))
              (string-to-number (match-string 4 string) 16)
-             (match-string 5 string)
+             (epg--time-from-seconds (match-string 5 string))
              (substring string (match-end 0)))
             (epg-context-result-for context 'sign)))))
 
@@ -1351,8 +1357,8 @@ This function is for internal use only."
    (string-to-number (aref line 3))
    (string-to-number (aref line 2))
    (aref line 4)
-   (aref line 5)
-   (aref line 6)))
+   (epg--time-from-seconds (aref line 5))
+   (epg--time-from-seconds (aref line 6))))
 
 ;;;###autoload
 (defun epg-list-keys (context &optional name mode)
@@ -1407,8 +1413,8 @@ signatures should be included."
                          epg-key-validity-alist)))
           (string-to-number (aref (car lines) 3))
           (aref (car lines) 4)
-          (aref (car lines) 5)
-          (aref (car lines) 6)
+          (epg--time-from-seconds (aref (car lines) 5))
+          (epg--time-from-seconds (aref (car lines) 6))
           (aref (car lines) 9)
           (string-to-number (aref (car lines) 10) 16)
           (eq (aref (aref (car lines) 10) 2) ?x))
@@ -1898,7 +1904,9 @@ If you are unsure, use synchronous version of this function
 `epg-import-keys-from-file' or `epg-import-keys-from-string' instead."
   (epg-context-set-operation context 'import-keys)
   (epg-context-set-result context nil)
-  (epg--start context (list "--import" (epg-data-file keys)))
+  (epg--start context (if (epg-data-file keys)
+                         (list "--import" (epg-data-file keys))
+                       (list "--import")))
   (when (epg-data-string keys)
     (if (eq (process-status (epg-context-process context)) 'run)
        (process-send-string (epg-context-process context)