summaryrefslogtreecommitdiff
path: root/lisp/net/secrets.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/net/secrets.el')
-rw-r--r--lisp/net/secrets.el27
1 files changed, 26 insertions, 1 deletions
diff --git a/lisp/net/secrets.el b/lisp/net/secrets.el
index 32659adebcd..c1a670fde8c 100644
--- a/lisp/net/secrets.el
+++ b/lisp/net/secrets.el
@@ -687,13 +687,38 @@ ITEM can also be an object path, which is returned if contained in COLLECTION."
item (secrets-get-item-property item-path "Label"))
(throw 'item-found item-path)))))))
+(defun secrets-lock-item (collection item)
+ "Lock collection item labeled ITEM in COLLECTION.
+If successful, return the object path of the item. Does not lock
+the collection."
+ (let ((item-path (secrets-item-path collection item)))
+ (unless (secrets-empty-path item-path)
+ (secrets-prompt
+ (cadr
+ (dbus-call-method
+ :session secrets-service secrets-path secrets-interface-service
+ "Lock" `(:array :object-path ,item-path)))))
+ item-path))
+
+(defun secrets-unlock-item (collection item)
+ "Unlock item labeled ITEM from collection labeled COLLECTION.
+If successful, return the object path of the item."
+ (let ((item-path (secrets-item-path collection item)))
+ (unless (secrets-empty-path item-path)
+ (secrets-prompt
+ (cadr
+ (dbus-call-method
+ :session secrets-service secrets-path secrets-interface-service
+ "Unlock" `(:array :object-path ,item-path)))))
+ item-path))
+
(defun secrets-get-secret (collection item)
"Return the secret of item labeled ITEM in COLLECTION.
If there are several items labeled ITEM, it is undefined which
one is returned. If there is no such item, return nil.
ITEM can also be an object path, which is used if contained in COLLECTION."
- (let ((item-path (secrets-item-path collection item)))
+ (let ((item-path (secrets-unlock-item collection item)))
(unless (secrets-empty-path item-path)
(dbus-byte-array-to-string
(nth 2