* net/secrets.el (secrets-struct-secret-content-type): Replace

check of introspection data by a test call of "CreateItem".  Some
servers do not offer introspection.
This commit is contained in:
Michael Albinus 2013-06-19 08:24:12 +02:00
parent 178ba3e6f5
commit e59dfb0ecd
2 changed files with 41 additions and 6 deletions

View file

@ -1,3 +1,9 @@
2013-06-19 Michael Albinus <michael.albinus@gmx.de>
* net/secrets.el (secrets-struct-secret-content-type): Replace
check of introspection data by a test call of "CreateItem". Some
servers do not offer introspection.
2013-06-19 Stefan Monnier <monnier@iro.umontreal.ca>
* electric.el (electric-pair-mode): Improve interaction with

View file

@ -310,13 +310,42 @@ It returns t if not."
(defconst secrets-interface-item-type-generic "org.freedesktop.Secret.Generic"
"The default item type we are using.")
;; We cannot use introspection, because some servers, like
;; mate-keyring-daemon, don't provide relevant data. Once the dust
;; has settled, we shall assume the new interface, and get rid of the test.
(defconst secrets-struct-secret-content-type
(when (string-equal
(dbus-introspect-get-signature
:session secrets-service secrets-path secrets-interface-service
"GetSecrets" "out")
"a{o(oayays)}")
'("text/plain"))
(ignore-errors
(let ((content-type "text/plain")
(path (cadr
(dbus-call-method
:session secrets-service secrets-path
secrets-interface-service
"OpenSession" "plain" '(:variant ""))))
result)
;; Create a dummy item.
(setq result
(dbus-call-method
:session secrets-service secrets-session-collection-path
secrets-interface-collection "CreateItem"
;; Properties.
`(:array
(:dict-entry ,(concat secrets-interface-item ".Label")
(:variant "dummy"))
(:dict-entry ,(concat secrets-interface-item ".Type")
(:variant ,secrets-interface-item-type-generic)))
;; Secret.
`(:struct :object-path ,path
(:array :signature "y")
,(dbus-string-to-byte-array " ")
:string ,content-type)
;; Don't replace.
nil))
;; Remove it.
(dbus-call-method
:session secrets-service (car result)
secrets-interface-item "Delete")
;; Result.
`(,content-type)))
"The content_type of a secret struct.
It must be wrapped as list, because we add it via `append'. This
is an interface introduced in 2011.")