summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorMichael Albinus <michael.albinus@gmx.de>2018-05-22 11:32:33 +0200
committerMichael Albinus <michael.albinus@gmx.de>2018-05-22 11:32:33 +0200
commit19e642fdb07b0b6522983e2fa35872ba5fb9f75e (patch)
treec2d2b58641c92c3295c376507deefeb9a1b38f55 /lisp
parentd2d35febf28632aafb087952fd4c07c2899e21c5 (diff)
downloademacs-19e642fdb07b0b6522983e2fa35872ba5fb9f75e.tar.gz
Extend secrets.el by searching for object paths.
* lisp/net/secrets.el (secrets-search-item-paths): New function. (secrets-search-items): Use it. (secrets-create-item): Adapt docstring. * test/lisp/net/secrets-tests.el (secrets-test04-search): Extend test.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/net/secrets.el43
1 files changed, 25 insertions, 18 deletions
diff --git a/lisp/net/secrets.el b/lisp/net/secrets.el
index 45c98cae60d..ca75d953c43 100644
--- a/lisp/net/secrets.el
+++ b/lisp/net/secrets.el
@@ -602,16 +602,16 @@ If successful, return the object path of the collection."
(secrets-get-item-property item-path "Label"))
(secrets-get-items collection-path)))))
-(defun secrets-search-items (collection &rest attributes)
+(defun secrets-search-item-paths (collection &rest attributes)
"Search items in COLLECTION with ATTRIBUTES.
ATTRIBUTES are key-value pairs. The keys are keyword symbols,
starting with a colon. Example:
- (secrets-search-items \"Tramp collection\" :user \"joe\")
+ (secrets-search-item-paths \"Tramp collection\" :user \"joe\")
-The object labels of the found items are returned as list."
+The object paths of the found items are returned as list."
(let ((collection-path (secrets-unlock-collection collection))
- result props)
+ props)
(unless (secrets-empty-path collection-path)
;; Create attributes list.
(while (consp (cdr attributes))
@@ -626,23 +626,30 @@ The object labels of the found items are returned as list."
,(cadr attributes))))
attributes (cddr attributes)))
;; Search. The result is a list of object paths.
- (setq result
- (dbus-call-method
- :session secrets-service collection-path
- secrets-interface-collection "SearchItems"
- (if props
- (cons :array props)
- '(:array :signature "{ss}"))))
- ;; Return the found items.
- (mapcar
- (lambda (item-path) (secrets-get-item-property item-path "Label"))
- result))))
+ (dbus-call-method
+ :session secrets-service collection-path
+ secrets-interface-collection "SearchItems"
+ (if props
+ (cons :array props)
+ '(:array :signature "{ss}"))))))
+
+(defun secrets-search-items (collection &rest attributes)
+ "Search items in COLLECTION with ATTRIBUTES.
+ATTRIBUTES are key-value pairs. The keys are keyword symbols,
+starting with a colon. Example:
+
+ (secrets-search-items \"Tramp collection\" :user \"joe\")
+
+The object labels of the found items are returned as list."
+ (mapcar
+ (lambda (item-path) (secrets-get-item-property item-path "Label"))
+ (apply 'secrets-search-item-paths collection attributes)))
(defun secrets-create-item (collection item password &rest attributes)
"Create a new item in COLLECTION with label ITEM and password PASSWORD.
-The label ITEM must not be unique in COLLECTION. ATTRIBUTES are
-key-value pairs set for the created item. The keys are keyword
-symbols, starting with a colon. Example:
+The label ITEM does not have to be unique in COLLECTION.
+ATTRIBUTES are key-value pairs set for the created item. The
+keys are keyword symbols, starting with a colon. Example:
(secrets-create-item \"Tramp collection\" \"item\" \"geheim\"
:method \"sudo\" :user \"joe\" :host \"remote-host\")