2016-11-18 12:25:12 +00:00
|
|
|
;; id-manager extensions
|
|
|
|
|
|
|
|
(defun gpolonkai/idm-record-get-field (record field)
|
|
|
|
"Get FIELD of an id-manager RECORD."
|
|
|
|
(let ((funcname (intern (concat "idm-record-" (symbol-name field)))))
|
|
|
|
(when (fboundp funcname)
|
|
|
|
(funcall funcname record))))
|
|
|
|
|
|
|
|
(defun gpolonkai/idm-get-field-for-account (account field)
|
|
|
|
"Get id-manager password for ACCOUNT."
|
|
|
|
(let ((db (idm-load-db))
|
2016-11-18 13:40:59 +00:00
|
|
|
(lookup-record nil))
|
2016-11-18 12:25:12 +00:00
|
|
|
(dolist (record (funcall db 'get-all-records) password)
|
2016-11-18 13:40:59 +00:00
|
|
|
(when (string= account (idm-record-name record))
|
|
|
|
(setq lookup-record (gpolonkai/idm-record-get-field record field))))
|
|
|
|
lookup-record))
|
2016-11-18 12:25:12 +00:00
|
|
|
|
|
|
|
(defmacro gpolonkai/idm-get-password-for-account (account)
|
|
|
|
`(gpolonkai/idm-get-field-for-account ,account 'password))
|
|
|
|
|
|
|
|
(defmacro gpolonkai/idm-get-id-for-account (account)
|
|
|
|
`(gpolonkai/idm-get-field-for-account ,account 'account-id))
|