comparison lisp/epg.el @ 97587:8324c394a51c

(epg-make-context, epg-context-set-passphrase-callback) (epg-context-set-progress-callback): Make sure the callback is a cons of a function and a handback. Update all callers.
author Daiki Ueno <ueno@unixuser.org>
date Thu, 21 Aug 2008 03:45:14 +0000
parents ee5932bf781d
children ef3ca5fcb751
comparison
equal deleted inserted replaced
97586:56d71f056b26 97587:8324c394a51c
183 compress-algorithm) 183 compress-algorithm)
184 "Return a context object." 184 "Return a context object."
185 (cons 'epg-context 185 (cons 'epg-context
186 (vector (or protocol 'OpenPGP) armor textmode include-certs 186 (vector (or protocol 'OpenPGP) armor textmode include-certs
187 cipher-algorithm digest-algorithm compress-algorithm 187 cipher-algorithm digest-algorithm compress-algorithm
188 #'epg-passphrase-callback-function 188 (list #'epg-passphrase-callback-function)
189 nil 189 nil
190 nil nil nil nil nil nil))) 190 nil nil nil nil nil nil)))
191 191
192 (defun epg-context-protocol (context) 192 (defun epg-context-protocol (context)
193 "Return the protocol used within CONTEXT." 193 "Return the protocol used within CONTEXT."
326 (defun epg-context-set-passphrase-callback (context 326 (defun epg-context-set-passphrase-callback (context
327 passphrase-callback) 327 passphrase-callback)
328 "Set the function used to query passphrase." 328 "Set the function used to query passphrase."
329 (unless (eq (car-safe context) 'epg-context) 329 (unless (eq (car-safe context) 'epg-context)
330 (signal 'wrong-type-argument (list 'epg-context-p context))) 330 (signal 'wrong-type-argument (list 'epg-context-p context)))
331 (aset (cdr context) 7 passphrase-callback)) 331 (aset (cdr context) 7 (if (consp passphrase-callback)
332 passphrase-callback
333 (list passphrase-callback))))
332 334
333 (defun epg-context-set-progress-callback (context 335 (defun epg-context-set-progress-callback (context
334 progress-callback) 336 progress-callback)
335 "Set the function which handles progress update. 337 "Set the function which handles progress update.
336 If optional argument HANDBACK is specified, it is passed to PROGRESS-CALLBACK." 338 If optional argument HANDBACK is specified, it is passed to PROGRESS-CALLBACK."
337 (unless (eq (car-safe context) 'epg-context) 339 (unless (eq (car-safe context) 'epg-context)
338 (signal 'wrong-type-argument (list 'epg-context-p context))) 340 (signal 'wrong-type-argument (list 'epg-context-p context)))
339 (aset (cdr context) 8 progress-callback)) 341 (aset (cdr context) 8 (if (consp progress-callback)
342 progress-callback
343 (list progress-callback))))
340 344
341 (defun epg-context-set-signers (context signers) 345 (defun epg-context-set-signers (context signers)
342 "Set the list of key-id for signing." 346 "Set the list of key-id for signing."
343 (unless (eq (car-safe context) 'epg-context) 347 (unless (eq (car-safe context) 'epg-context)
344 (signal 'wrong-type-argument (list 'epg-context-p context))) 348 (signal 'wrong-type-argument (list 'epg-context-p context)))
1237 (unwind-protect 1241 (unwind-protect
1238 (condition-case nil 1242 (condition-case nil
1239 (progn 1243 (progn
1240 (setq passphrase 1244 (setq passphrase
1241 (funcall 1245 (funcall
1242 (if (consp (epg-context-passphrase-callback context)) 1246 (car (epg-context-passphrase-callback context))
1243 (car (epg-context-passphrase-callback context))
1244 (epg-context-passphrase-callback context))
1245 context 1247 context
1246 epg-key-id 1248 epg-key-id
1247 (if (consp (epg-context-passphrase-callback context)) 1249 (cdr (epg-context-passphrase-callback context))))
1248 (cdr (epg-context-passphrase-callback context)))))
1249 (when passphrase 1250 (when passphrase
1250 (setq passphrase-with-new-line (concat passphrase "\n")) 1251 (setq passphrase-with-new-line (concat passphrase "\n"))
1251 (epg--clear-string passphrase) 1252 (epg--clear-string passphrase)
1252 (setq passphrase nil) 1253 (setq passphrase nil)
1253 (if epg-passphrase-coding-system 1254 (if epg-passphrase-coding-system
1491 1492
1492 (defun epg--status-PROGRESS (context string) 1493 (defun epg--status-PROGRESS (context string)
1493 (if (and (epg-context-progress-callback context) 1494 (if (and (epg-context-progress-callback context)
1494 (string-match "\\`\\([^ ]+\\) \\([^ ]\\) \\([0-9]+\\) \\([0-9]+\\)" 1495 (string-match "\\`\\([^ ]+\\) \\([^ ]\\) \\([0-9]+\\) \\([0-9]+\\)"
1495 string)) 1496 string))
1496 (funcall (if (consp (epg-context-progress-callback context)) 1497 (funcall (car (epg-context-progress-callback context))
1497 (car (epg-context-progress-callback context))
1498 (epg-context-progress-callback context))
1499 context 1498 context
1500 (match-string 1 string) 1499 (match-string 1 string)
1501 (match-string 2 string) 1500 (match-string 2 string)
1502 (string-to-number (match-string 3 string)) 1501 (string-to-number (match-string 3 string))
1503 (string-to-number (match-string 4 string)) 1502 (string-to-number (match-string 4 string))
1504 (if (consp (epg-context-progress-callback context)) 1503 (cdr (epg-context-progress-callback context)))))
1505 (cdr (epg-context-progress-callback context))))))
1506 1504
1507 (defun epg--status-ENC_TO (context string) 1505 (defun epg--status-ENC_TO (context string)
1508 (if (string-match "\\`\\([0-9A-Za-z]+\\) \\([0-9]+\\) \\([0-9]+\\)" string) 1506 (if (string-match "\\`\\([0-9A-Za-z]+\\) \\([0-9]+\\) \\([0-9]+\\)" string)
1509 (epg-context-set-result-for 1507 (epg-context-set-result-for
1510 context 'encrypted-to 1508 context 'encrypted-to