annotate lisp/net/secrets.el @ 111834:6951f234b0c3

* lisp/ansi-color.el (ansi-color-unfontify-region): Replace by trivial def. (ansi-color-filter-apply): Simplify. (ansi-color-apply): Use `font-lock-face' rather than `face'.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Mon, 06 Dec 2010 11:51:37 -0500
parents 69ac0d220a1c
children 68a3b6b312ee
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
107389
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
1 ;;; secrets.el --- Client interface to gnome-keyring and kwallet.
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
2
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
3 ;; Copyright (C) 2010 Free Software Foundation, Inc.
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
4
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
5 ;; Author: Michael Albinus <michael.albinus@gmx.de>
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
6 ;; Keywords: comm password passphrase
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
7
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
8 ;; This file is part of GNU Emacs.
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
9
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
10 ;; GNU Emacs is free software: you can redistribute it and/or modify
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
11 ;; it under the terms of the GNU General Public License as published by
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
12 ;; the Free Software Foundation, either version 3 of the License, or
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
13 ;; (at your option) any later version.
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
14
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
15 ;; GNU Emacs is distributed in the hope that it will be useful,
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
18 ;; GNU General Public License for more details.
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
19
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
22
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
23 ;;; Commentary:
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
24
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
25 ;; This package provides an implementation of the Secret Service API
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
26 ;; <http://www.freedesktop.org/wiki/Specifications/secret-storage-spec>.
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
27 ;; This API is meant to make GNOME-Keyring- and KWallet-like daemons
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
28 ;; available under a common D-BUS interface and thus increase
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
29 ;; interoperability between GNOME, KDE and other applications having
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
30 ;; the need to securely store passwords and other confidential
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
31 ;; information.
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
32
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
33 ;; In order to activate this package, you must add the following code
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
34 ;; into your .emacs:
107396
d5de7ba3f80f * net/secrets.el (top): Register the D-Bus signals only when the
Michael Albinus <albinus@detlef>
parents: 107389
diff changeset
35 ;;
d5de7ba3f80f * net/secrets.el (top): Register the D-Bus signals only when the
Michael Albinus <albinus@detlef>
parents: 107389
diff changeset
36 ;; (require 'secrets)
d5de7ba3f80f * net/secrets.el (top): Register the D-Bus signals only when the
Michael Albinus <albinus@detlef>
parents: 107389
diff changeset
37 ;;
107397
6c48d0b283da * net/secrets.el (secrets-enabled): New variable. Use it instead
Michael Albinus <albinus@detlef>
parents: 107396
diff changeset
38 ;; Afterwards, the variable `secrets-enabled' is non-nil when there is
6c48d0b283da * net/secrets.el (secrets-enabled): New variable. Use it instead
Michael Albinus <albinus@detlef>
parents: 107396
diff changeset
39 ;; a daemon providing this interface.
107389
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
40
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
41 ;; The atomic objects to be managed by the Secret Service API are
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
42 ;; secret items, which are something an application wishes to store
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
43 ;; securely. A good example is a password that an application needs
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
44 ;; to save and use at a later date.
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
45
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
46 ;; Secret items are grouped in collections. A collection is similar
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
47 ;; in concept to the terms 'keyring' or 'wallet'. A common collection
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
48 ;; is called "login". A collection is stored permanently under the
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
49 ;; user's permissions, and can be accessed in a user session context.
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
50
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
51 ;; A collection can have an alias name. The use case for this is to
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
52 ;; set the alias "default" for a given collection, making it
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
53 ;; transparent for clients, which collection is used. Other aliases
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
54 ;; are not supported (yet). Since an alias is visible to all
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
55 ;; applications, this setting shall be performed with care.
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
56
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
57 ;; A list of all available collections is available by
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
58 ;;
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
59 ;; (secrets-list-collections)
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
60 ;; => ("session" "login" "ssh keys")
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
61
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
62 ;; The "default" alias could be set to the "login" collection by
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
63 ;;
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
64 ;; (secrets-set-alias "login" "default")
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
65
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
66 ;; An alias can also be dereferenced
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
67 ;;
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
68 ;; (secrets-get-alias "default")
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
69 ;; => "login"
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
70
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
71 ;; Collections can be created and deleted. As already said,
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
72 ;; collections are used by different applications. Therefore, those
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
73 ;; operations shall also be performed with care. Common collections,
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
74 ;; like "login", shall not be changed except adding or deleting secret
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
75 ;; items.
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
76 ;;
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
77 ;; (secrets-delete-collection "my collection")
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
78 ;; (secrets-create-collection "my collection")
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
79
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
80 ;; There exists a special collection called "session", which has the
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
81 ;; lifetime of the corrresponding client session (aka Emacs'
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
82 ;; lifetime). It is created automatically when Emacs uses the Secret
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
83 ;; Service interface, and it is deleted when Emacs is killed.
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
84 ;; Therefore, it can be used to store and retrieve secret items
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
85 ;; temporarily. This shall be preferred over creation of a persistent
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
86 ;; collection, when the information shall not live longer than Emacs.
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
87 ;; The session collection can be addressed either by the string
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
88 ;; "session", or by `nil', whenever a collection parameter is needed.
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
89
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
90 ;; As already said, a collection is a group of secret items. A secret
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
91 ;; item has a label, the "secret" (which is a string), and a set of
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
92 ;; lookup attributes. The attributes can be used to search and
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
93 ;; retrieve a secret item at a later date.
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
94
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
95 ;; A list of all available secret items of a collection is available by
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
96 ;;
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
97 ;; (secrets-list-items "my collection")
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
98 ;; => ("this item" "another item")
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
99
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
100 ;; Secret items can be added or deleted to a collection. In the
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
101 ;; following examples, we use the special collection "session", which
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
102 ;; is bound to Emacs' lifetime.
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
103 ;;
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
104 ;; (secrets-delete-item "session" "my item")
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
105 ;; (secrets-create-item "session" "my item" "geheim"
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
106 ;; :user "joe" :host "remote-host")
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
107
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
108 ;; The string "geheim" is the secret of the secret item "my item".
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
109 ;; The secret string can be retrieved from items:
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
110 ;;
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
111 ;; (secrets-get-secret "session" "my item")
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
112 ;; => "geheim"
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
113
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
114 ;; The lookup attributes, which are specified during creation of a
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
115 ;; secret item, must be a key-value pair. Keys are keyword symbols,
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
116 ;; starting with a colon; values are strings. They can be retrieved
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
117 ;; from a given secret item:
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
118 ;;
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
119 ;; (secrets-get-attribute "session" "my item" :host)
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
120 ;; => "remote-host"
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
121 ;;
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
122 ;; (secrets-get-attributes "session" "my item")
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
123 ;; => ((:user . "joe") (:host ."remote-host"))
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
124
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
125 ;; The lookup attributes can be used for searching of items. If you,
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
126 ;; for example, are looking for all secret items for the user "joe",
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
127 ;; you would perform
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
128 ;;
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
129 ;; (secrets-search-items "session" :user "joe")
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
130 ;; => ("my item" "another item")
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
131
108653
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
132 ;; Interactively, collections, items and their attributes could be
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
133 ;; inspected by the command `secrets-show-secrets'.
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
134
107389
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
135 ;;; Code:
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
136
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
137 ;; It has been tested with GNOME Keyring 2.29.92. An implementation
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
138 ;; for KWallet will be available at
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
139 ;; svn://anonsvn.kde.org/home/kde/trunk/playground/base/ksecretservice;
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
140 ;; not tested yet.
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
141
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
142 ;; Pacify byte-compiler. D-Bus support in the Emacs core can be
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
143 ;; disabled with configuration option "--without-dbus". Declare used
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
144 ;; subroutines and variables of `dbus' therefore.
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
145 (eval-when-compile
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
146 (require 'cl))
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
147
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
148 (declare-function dbus-call-method "dbusbind.c")
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
149 (declare-function dbus-register-signal "dbusbind.c")
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
150 (defvar dbus-debug)
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
151
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
152 (require 'dbus)
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
153
108699
69ac0d220a1c * net/secrets.el: Autoload the widget functions.
Michael Albinus <michael.albinus@gmx.de>
parents: 108653
diff changeset
154 (autoload 'tree-widget-set-theme "tree-widget")
69ac0d220a1c * net/secrets.el: Autoload the widget functions.
Michael Albinus <michael.albinus@gmx.de>
parents: 108653
diff changeset
155 (autoload 'widget-create-child-and-convert "wid-edit")
69ac0d220a1c * net/secrets.el: Autoload the widget functions.
Michael Albinus <michael.albinus@gmx.de>
parents: 108653
diff changeset
156 (autoload 'widget-default-value-set "wid-edit")
69ac0d220a1c * net/secrets.el: Autoload the widget functions.
Michael Albinus <michael.albinus@gmx.de>
parents: 108653
diff changeset
157 (autoload 'widget-field-end "wid-edit")
69ac0d220a1c * net/secrets.el: Autoload the widget functions.
Michael Albinus <michael.albinus@gmx.de>
parents: 108653
diff changeset
158 (autoload 'widget-member "wid-edit")
108653
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
159 (defvar tree-widget-after-toggle-functions)
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
160
107397
6c48d0b283da * net/secrets.el (secrets-enabled): New variable. Use it instead
Michael Albinus <albinus@detlef>
parents: 107396
diff changeset
161 (defvar secrets-enabled nil
107447
9d443ad80849 Fix unbalanced parenthesis in secrets.el.
Ted Zlatanov <tzz@lifelogs.com>
parents: 107397
diff changeset
162 "Whether there is a daemon offering the Secret Service API.")
107397
6c48d0b283da * net/secrets.el (secrets-enabled): New variable. Use it instead
Michael Albinus <albinus@detlef>
parents: 107396
diff changeset
163
107389
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
164 (defvar secrets-debug t
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
165 "Write debug messages")
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
166
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
167 (defconst secrets-service "org.freedesktop.secrets"
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
168 "The D-Bus name used to talk to Secret Service.")
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
169
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
170 (defconst secrets-path "/org/freedesktop/secrets"
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
171 "The D-Bus root object path used to talk to Secret Service.")
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
172
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
173 (defconst secrets-empty-path "/"
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
174 "The D-Bus object path representing an empty object.")
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
175
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
176 (defsubst secrets-empty-path (path)
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
177 "Check, whether PATH is a valid object path.
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
178 It returns t if not."
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
179 (or (not (stringp path))
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
180 (string-equal path secrets-empty-path)))
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
181
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
182 (defconst secrets-interface-service "org.freedesktop.Secret.Service"
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
183 "The D-Bus interface managing sessions and collections.")
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
184
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
185 ;; <interface name="org.freedesktop.Secret.Service">
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
186 ;; <property name="Collections" type="ao" access="read"/>
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
187 ;; <method name="OpenSession">
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
188 ;; <arg name="algorithm" type="s" direction="in"/>
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
189 ;; <arg name="input" type="v" direction="in"/>
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
190 ;; <arg name="output" type="v" direction="out"/>
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
191 ;; <arg name="result" type="o" direction="out"/>
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
192 ;; </method>
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
193 ;; <method name="CreateCollection">
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
194 ;; <arg name="props" type="a{sv}" direction="in"/>
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
195 ;; <arg name="collection" type="o" direction="out"/>
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
196 ;; <arg name="prompt" type="o" direction="out"/>
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
197 ;; </method>
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
198 ;; <method name="SearchItems">
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
199 ;; <arg name="attributes" type="a{ss}" direction="in"/>
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
200 ;; <arg name="unlocked" type="ao" direction="out"/>
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
201 ;; <arg name="locked" type="ao" direction="out"/>
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
202 ;; </method>
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
203 ;; <method name="Unlock">
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
204 ;; <arg name="objects" type="ao" direction="in"/>
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
205 ;; <arg name="unlocked" type="ao" direction="out"/>
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
206 ;; <arg name="prompt" type="o" direction="out"/>
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
207 ;; </method>
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
208 ;; <method name="Lock">
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
209 ;; <arg name="objects" type="ao" direction="in"/>
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
210 ;; <arg name="locked" type="ao" direction="out"/>
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
211 ;; <arg name="Prompt" type="o" direction="out"/>
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
212 ;; </method>
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
213 ;; <method name="GetSecrets">
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
214 ;; <arg name="items" type="ao" direction="in"/>
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
215 ;; <arg name="session" type="o" direction="in"/>
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
216 ;; <arg name="secrets" type="a{o(oayay)}" direction="out"/>
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
217 ;; </method>
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
218 ;; <method name="ReadAlias">
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
219 ;; <arg name="name" type="s" direction="in"/>
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
220 ;; <arg name="collection" type="o" direction="out"/>
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
221 ;; </method>
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
222 ;; <method name="SetAlias">
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
223 ;; <arg name="name" type="s" direction="in"/>
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
224 ;; <arg name="collection" type="o" direction="in"/>
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
225 ;; </method>
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
226 ;; <signal name="CollectionCreated">
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
227 ;; <arg name="collection" type="o"/>
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
228 ;; </signal>
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
229 ;; <signal name="CollectionDeleted">
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
230 ;; <arg name="collection" type="o"/>
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
231 ;; </signal>
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
232 ;; </interface>
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
233
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
234 (defconst secrets-interface-collection "org.freedesktop.Secret.Collection"
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
235 "A collection of items containing secrets.")
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
236
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
237 ;; <interface name="org.freedesktop.Secret.Collection">
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
238 ;; <property name="Items" type="ao" access="read"/>
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
239 ;; <property name="Label" type="s" access="readwrite"/>
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
240 ;; <property name="Locked" type="s" access="read"/>
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
241 ;; <property name="Created" type="t" access="read"/>
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
242 ;; <property name="Modified" type="t" access="read"/>
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
243 ;; <method name="Delete">
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
244 ;; <arg name="prompt" type="o" direction="out"/>
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
245 ;; </method>
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
246 ;; <method name="SearchItems">
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
247 ;; <arg name="attributes" type="a{ss}" direction="in"/>
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
248 ;; <arg name="results" type="ao" direction="out"/>
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
249 ;; </method>
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
250 ;; <method name="CreateItem">
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
251 ;; <arg name="props" type="a{sv}" direction="in"/>
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
252 ;; <arg name="secret" type="(oayay)" direction="in"/>
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
253 ;; <arg name="replace" type="b" direction="in"/>
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
254 ;; <arg name="item" type="o" direction="out"/>
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
255 ;; <arg name="prompt" type="o" direction="out"/>
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
256 ;; </method>
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
257 ;; <signal name="ItemCreated">
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
258 ;; <arg name="item" type="o"/>
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
259 ;; </signal>
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
260 ;; <signal name="ItemDeleted">
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
261 ;; <arg name="item" type="o"/>
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
262 ;; </signal>
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
263 ;; <signal name="ItemChanged">
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
264 ;; <arg name="item" type="o"/>
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
265 ;; </signal>
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
266 ;; </interface>
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
267
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
268 (defconst secrets-session-collection-path
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
269 "/org/freedesktop/secrets/collection/session"
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
270 "The D-Bus temporary session collection object path.")
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
271
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
272 (defconst secrets-interface-prompt "org.freedesktop.Secret.Prompt"
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
273 "A session tracks state between the service and a client application.")
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
274
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
275 ;; <interface name="org.freedesktop.Secret.Prompt">
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
276 ;; <method name="Prompt">
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
277 ;; <arg name="window-id" type="s" direction="in"/>
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
278 ;; </method>
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
279 ;; <method name="Dismiss"></method>
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
280 ;; <signal name="Completed">
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
281 ;; <arg name="dismissed" type="b"/>
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
282 ;; <arg name="result" type="v"/>
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
283 ;; </signal>
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
284 ;; </interface>
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
285
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
286 (defconst secrets-interface-item "org.freedesktop.Secret.Item"
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
287 "A collection of items containing secrets.")
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
288
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
289 ;; <interface name="org.freedesktop.Secret.Item">
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
290 ;; <property name="Locked" type="b" access="read"/>
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
291 ;; <property name="Attributes" type="a{ss}" access="readwrite"/>
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
292 ;; <property name="Label" type="s" access="readwrite"/>
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
293 ;; <property name="Created" type="t" access="read"/>
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
294 ;; <property name="Modified" type="t" access="read"/>
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
295 ;; <method name="Delete">
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
296 ;; <arg name="prompt" type="o" direction="out"/>
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
297 ;; </method>
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
298 ;; <method name="GetSecret">
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
299 ;; <arg name="session" type="o" direction="in"/>
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
300 ;; <arg name="secret" type="(oayay)" direction="out"/>
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
301 ;; </method>
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
302 ;; <method name="SetSecret">
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
303 ;; <arg name="secret" type="(oayay)" direction="in"/>
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
304 ;; </method>
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
305 ;; </interface>
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
306 ;;
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
307 ;; STRUCT secret
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
308 ;; OBJECT PATH session
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
309 ;; ARRAY BYTE parameters
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
310 ;; ARRAY BYTE value
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
311
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
312 (defconst secrets-interface-item-type-generic "org.freedesktop.Secret.Generic"
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
313 "The default item type we are using.")
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
314
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
315 (defconst secrets-interface-session "org.freedesktop.Secret.Session"
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
316 "A session tracks state between the service and a client application.")
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
317
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
318 ;; <interface name="org.freedesktop.Secret.Session">
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
319 ;; <method name="Close"></method>
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
320 ;; </interface>
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
321
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
322 ;;; Sessions.
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
323
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
324 (defvar secrets-session-path secrets-empty-path
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
325 "The D-Bus session path of the active session.
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
326 A session path `secrets-empty-path' indicates there is no open session.")
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
327
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
328 (defun secrets-close-session ()
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
329 "Close the secret service session, if any."
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
330 (dbus-ignore-errors
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
331 (dbus-call-method
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
332 :session secrets-service secrets-session-path
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
333 secrets-interface-session "Close"))
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
334 (setq secrets-session-path secrets-empty-path))
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
335
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
336 (defun secrets-open-session (&optional reopen)
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
337 "Open a new session with \"plain\" algorithm.
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
338 If there exists another active session, and REOPEN is nil, that
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
339 session will be used. The object path of the session will be
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
340 returned, and it will be stored in `secrets-session-path'."
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
341 (when reopen (secrets-close-session))
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
342 (when (secrets-empty-path secrets-session-path)
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
343 (setq secrets-session-path
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
344 (cadr
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
345 (dbus-call-method
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
346 :session secrets-service secrets-path
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
347 secrets-interface-service "OpenSession" "plain" '(:variant "")))))
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
348 (when secrets-debug
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
349 (message "Secret Service session: %s" secrets-session-path))
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
350 secrets-session-path)
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
351
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
352 ;;; Prompts.
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
353
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
354 (defvar secrets-prompt-signal nil
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
355 "Internal variable to catch signals from `secrets-interface-prompt'.")
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
356
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
357 (defun secrets-prompt (prompt)
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
358 "Handle the prompt identified by object path PROMPT."
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
359 (unless (secrets-empty-path prompt)
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
360 (let ((object
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
361 (dbus-register-signal
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
362 :session secrets-service prompt
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
363 secrets-interface-prompt "Completed" 'secrets-prompt-handler)))
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
364 (dbus-call-method
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
365 :session secrets-service prompt
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
366 secrets-interface-prompt "Prompt" (frame-parameter nil 'window-id))
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
367 (unwind-protect
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
368 (progn
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
369 ;; Wait until the returned prompt signal has put the
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
370 ;; result into `secrets-prompt-signal'.
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
371 (while (null secrets-prompt-signal)
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
372 (read-event nil nil 0.1))
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
373 ;; Return the object(s). It is a variant, so we must use a car.
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
374 (car secrets-prompt-signal))
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
375 ;; Cleanup.
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
376 (setq secrets-prompt-signal nil)
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
377 (dbus-unregister-object object)))))
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
378
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
379 (defun secrets-prompt-handler (&rest args)
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
380 "Handler for signals emitted by `secrets-interface-prompt'."
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
381 ;; An empty object path is always identified as `secrets-empty-path'
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
382 ;; or `nil'. Either we set it explicitely, or it is returned by the
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
383 ;; "Completed" signal.
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
384 (if (car args) ;; dismissed
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
385 (setq secrets-prompt-signal (list secrets-empty-path))
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
386 (setq secrets-prompt-signal (cadr args))))
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
387
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
388 ;;; Collections.
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
389
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
390 (defvar secrets-collection-paths nil
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
391 "Cached D-Bus object paths of available collections.")
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
392
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
393 (defun secrets-collection-handler (&rest args)
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
394 "Handler for signals emitted by `secrets-interface-service'."
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
395 (cond
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
396 ((string-equal (dbus-event-member-name last-input-event) "CollectionCreated")
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
397 (add-to-list 'secrets-collection-paths (car args)))
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
398 ((string-equal (dbus-event-member-name last-input-event) "CollectionDeleted")
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
399 (setq secrets-collection-paths
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
400 (delete (car args) secrets-collection-paths)))))
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
401
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
402 (defun secrets-get-collections ()
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
403 "Return the object paths of all available collections."
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
404 (setq secrets-collection-paths
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
405 (or secrets-collection-paths
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
406 (dbus-get-property
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
407 :session secrets-service secrets-path
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
408 secrets-interface-service "Collections"))))
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
409
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
410 (defun secrets-get-collection-properties (collection-path)
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
411 "Return all properties of collection identified by COLLECTION-PATH."
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
412 (unless (secrets-empty-path collection-path)
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
413 (dbus-get-all-properties
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
414 :session secrets-service collection-path
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
415 secrets-interface-collection)))
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
416
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
417 (defun secrets-get-collection-property (collection-path property)
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
418 "Return property PROPERTY of collection identified by COLLECTION-PATH."
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
419 (unless (or (secrets-empty-path collection-path) (not (stringp property)))
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
420 (dbus-get-property
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
421 :session secrets-service collection-path
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
422 secrets-interface-collection property)))
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
423
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
424 (defun secrets-list-collections ()
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
425 "Return a list of collection names."
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
426 (mapcar
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
427 (lambda (collection-path)
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
428 (if (string-equal collection-path secrets-session-collection-path)
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
429 "session"
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
430 (secrets-get-collection-property collection-path "Label")))
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
431 (secrets-get-collections)))
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
432
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
433 (defun secrets-collection-path (collection)
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
434 "Return the object path of collection labelled COLLECTION.
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
435 If COLLECTION is nil, return the session collection path.
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
436 If there is no such COLLECTION, return nil."
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
437 (or
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
438 ;; The "session" collection.
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
439 (if (or (null collection) (string-equal "session" collection))
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
440 secrets-session-collection-path)
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
441 ;; Check for an alias.
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
442 (let ((collection-path
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
443 (dbus-call-method
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
444 :session secrets-service secrets-path
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
445 secrets-interface-service "ReadAlias" collection)))
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
446 (unless (secrets-empty-path collection-path)
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
447 collection-path))
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
448 ;; Check the collections.
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
449 (catch 'collection-found
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
450 (dolist (collection-path (secrets-get-collections) nil)
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
451 (when
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
452 (string-equal
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
453 collection
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
454 (secrets-get-collection-property collection-path "Label"))
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
455 (throw 'collection-found collection-path))))))
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
456
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
457 (defun secrets-create-collection (collection)
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
458 "Create collection labelled COLLECTION if it doesn't exist.
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
459 Return the D-Bus object path for collection."
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
460 (let ((collection-path (secrets-collection-path collection)))
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
461 ;; Create the collection.
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
462 (when (secrets-empty-path collection-path)
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
463 (setq collection-path
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
464 (secrets-prompt
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
465 (cadr
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
466 ;; "CreateCollection" returns the prompt path as second arg.
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
467 (dbus-call-method
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
468 :session secrets-service secrets-path
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
469 secrets-interface-service "CreateCollection"
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
470 `(:array (:dict-entry "Label" (:variant ,collection))))))))
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
471 ;; Return object path of the collection.
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
472 collection-path))
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
473
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
474 (defun secrets-get-alias (alias)
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
475 "Return the collection name ALIAS is referencing to.
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
476 For the time being, only the alias \"default\" is supported."
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
477 (secrets-get-collection-property
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
478 (dbus-call-method
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
479 :session secrets-service secrets-path
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
480 secrets-interface-service "ReadAlias" alias)
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
481 "Label"))
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
482
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
483 (defun secrets-set-alias (collection alias)
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
484 "Set ALIAS as alias of collection labelled COLLECTION.
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
485 For the time being, only the alias \"default\" is supported."
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
486 (let ((collection-path (secrets-collection-path collection)))
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
487 (unless (secrets-empty-path collection-path)
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
488 (dbus-call-method
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
489 :session secrets-service secrets-path
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
490 secrets-interface-service "SetAlias"
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
491 alias :object-path collection-path))))
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
492
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
493 (defun secrets-unlock-collection (collection)
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
494 "Unlock collection labelled COLLECTION.
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
495 If successful, return the object path of the collection."
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
496 (let ((collection-path (secrets-collection-path collection)))
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
497 (unless (secrets-empty-path collection-path)
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
498 (secrets-prompt
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
499 (cadr
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
500 (dbus-call-method
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
501 :session secrets-service secrets-path secrets-interface-service
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
502 "Unlock" `(:array :object-path ,collection-path)))))
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
503 collection-path))
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
504
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
505 (defun secrets-delete-collection (collection)
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
506 "Delete collection labelled COLLECTION."
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
507 (let ((collection-path (secrets-collection-path collection)))
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
508 (unless (secrets-empty-path collection-path)
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
509 (secrets-prompt
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
510 (dbus-call-method
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
511 :session secrets-service collection-path
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
512 secrets-interface-collection "Delete")))))
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
513
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
514 ;;; Items.
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
515
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
516 (defun secrets-get-items (collection-path)
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
517 "Return the object paths of all available items in COLLECTION-PATH."
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
518 (unless (secrets-empty-path collection-path)
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
519 (secrets-open-session)
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
520 (dbus-get-property
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
521 :session secrets-service collection-path
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
522 secrets-interface-collection "Items")))
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
523
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
524 (defun secrets-get-item-properties (item-path)
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
525 "Return all properties of item identified by ITEM-PATH."
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
526 (unless (secrets-empty-path item-path)
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
527 (dbus-get-all-properties
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
528 :session secrets-service item-path
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
529 secrets-interface-item)))
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
530
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
531 (defun secrets-get-item-property (item-path property)
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
532 "Return property PROPERTY of item identified by ITEM-PATH."
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
533 (unless (or (secrets-empty-path item-path) (not (stringp property)))
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
534 (dbus-get-property
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
535 :session secrets-service item-path
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
536 secrets-interface-item property)))
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
537
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
538 (defun secrets-list-items (collection)
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
539 "Return a list of all item labels of COLLECTION."
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
540 (let ((collection-path (secrets-unlock-collection collection)))
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
541 (unless (secrets-empty-path collection-path)
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
542 (mapcar
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
543 (lambda (item-path)
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
544 (secrets-get-item-property item-path "Label"))
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
545 (secrets-get-items collection-path)))))
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
546
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
547 (defun secrets-search-items (collection &rest attributes)
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
548 "Search items in COLLECTION with ATTRIBUTES.
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
549 ATTRIBUTES are key-value pairs. The keys are keyword symbols,
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
550 starting with a colon. Example:
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
551
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
552 \(secrets-create-item \"Tramp collection\" \"item\" \"geheim\"
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
553 :method \"sudo\" :user \"joe\" :host \"remote-host\"\)
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
554
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
555 The object paths of the found items are returned as list."
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
556 (let ((collection-path (secrets-unlock-collection collection))
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
557 result props)
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
558 (unless (secrets-empty-path collection-path)
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
559 ;; Create attributes list.
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
560 (while (consp (cdr attributes))
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
561 (unless (keywordp (car attributes))
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
562 (error 'wrong-type-argument (car attributes)))
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
563 (setq props (add-to-list
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
564 'props
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
565 (list :dict-entry
108699
69ac0d220a1c * net/secrets.el: Autoload the widget functions.
Michael Albinus <michael.albinus@gmx.de>
parents: 108653
diff changeset
566 (substring (symbol-name (car attributes)) 1)
107389
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
567 (cadr attributes))
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
568 'append)
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
569 attributes (cddr attributes)))
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
570 ;; Search. The result is a list of two lists, the object paths
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
571 ;; of the unlocked and the locked items.
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
572 (setq result
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
573 (dbus-call-method
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
574 :session secrets-service collection-path
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
575 secrets-interface-collection "SearchItems"
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
576 (if props
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
577 (cons :array props)
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
578 '(:array :signature "{ss}"))))
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
579 ;; Return the found items.
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
580 (mapcar
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
581 (lambda (item-path) (secrets-get-item-property item-path "Label"))
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
582 (append (car result) (cadr result))))))
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
583
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
584 (defun secrets-create-item (collection item password &rest attributes)
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
585 "Create a new item in COLLECTION with label ITEM and password PASSWORD.
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
586 ATTRIBUTES are key-value pairs set for the created item. The
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
587 keys are keyword symbols, starting with a colon. Example:
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
588
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
589 \(secrets-create-item \"Tramp collection\" \"item\" \"geheim\"
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
590 :method \"sudo\" :user \"joe\" :host \"remote-host\"\)
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
591
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
592 The object path of the created item is returned."
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
593 (unless (member item (secrets-list-items collection))
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
594 (let ((collection-path (secrets-unlock-collection collection))
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
595 result props)
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
596 (unless (secrets-empty-path collection-path)
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
597 ;; Create attributes list.
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
598 (while (consp (cdr attributes))
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
599 (unless (keywordp (car attributes))
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
600 (error 'wrong-type-argument (car attributes)))
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
601 (setq props (add-to-list
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
602 'props
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
603 (list :dict-entry
108699
69ac0d220a1c * net/secrets.el: Autoload the widget functions.
Michael Albinus <michael.albinus@gmx.de>
parents: 108653
diff changeset
604 (substring (symbol-name (car attributes)) 1)
107389
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
605 (cadr attributes))
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
606 'append)
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
607 attributes (cddr attributes)))
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
608 ;; Create the item.
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
609 (setq result
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
610 (dbus-call-method
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
611 :session secrets-service collection-path
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
612 secrets-interface-collection "CreateItem"
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
613 ;; Properties.
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
614 (append
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
615 `(:array
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
616 (:dict-entry "Label" (:variant ,item))
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
617 (:dict-entry
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
618 "Type" (:variant ,secrets-interface-item-type-generic)))
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
619 (when props
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
620 `((:dict-entry
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
621 "Attributes" (:variant ,(append '(:array) props))))))
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
622 ;; Secret.
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
623 `(:struct :object-path ,secrets-session-path
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
624 (:array :signature "y") ;; no parameters.
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
625 ,(dbus-string-to-byte-array password))
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
626 ;; Do not replace. Replace does not seem to work.
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
627 nil))
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
628 (secrets-prompt (cadr result))
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
629 ;; Return the object path.
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
630 (car result)))))
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
631
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
632 (defun secrets-item-path (collection item)
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
633 "Return the object path of item labelled ITEM in COLLECTION.
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
634 If there is no such item, return nil."
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
635 (let ((collection-path (secrets-unlock-collection collection)))
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
636 (catch 'item-found
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
637 (dolist (item-path (secrets-get-items collection-path))
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
638 (when (string-equal item (secrets-get-item-property item-path "Label"))
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
639 (throw 'item-found item-path))))))
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
640
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
641 (defun secrets-get-secret (collection item)
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
642 "Return the secret of item labelled ITEM in COLLECTION.
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
643 If there is no such item, return nil."
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
644 (let ((item-path (secrets-item-path collection item)))
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
645 (unless (secrets-empty-path item-path)
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
646 (dbus-byte-array-to-string
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
647 (caddr
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
648 (dbus-call-method
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
649 :session secrets-service item-path secrets-interface-item
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
650 "GetSecret" :object-path secrets-session-path))))))
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
651
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
652 (defun secrets-get-attributes (collection item)
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
653 "Return the lookup attributes of item labelled ITEM in COLLECTION.
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
654 If there is no such item, or the item has no attributes, return nil."
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
655 (unless (stringp collection) (setq collection "default"))
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
656 (let ((item-path (secrets-item-path collection item)))
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
657 (unless (secrets-empty-path item-path)
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
658 (mapcar
108699
69ac0d220a1c * net/secrets.el: Autoload the widget functions.
Michael Albinus <michael.albinus@gmx.de>
parents: 108653
diff changeset
659 (lambda (attribute)
69ac0d220a1c * net/secrets.el: Autoload the widget functions.
Michael Albinus <michael.albinus@gmx.de>
parents: 108653
diff changeset
660 (cons (intern (concat ":" (car attribute))) (cadr attribute)))
107389
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
661 (dbus-get-property
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
662 :session secrets-service item-path
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
663 secrets-interface-item "Attributes")))))
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
664
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
665 (defun secrets-get-attribute (collection item attribute)
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
666 "Return the value of ATTRIBUTE of item labelled ITEM in COLLECTION.
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
667 If there is no such item, or the item doesn't own this attribute, return nil."
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
668 (cdr (assoc attribute (secrets-get-attributes collection item))))
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
669
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
670 (defun secrets-delete-item (collection item)
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
671 "Delete ITEM in COLLECTION."
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
672 (let ((item-path (secrets-item-path collection item)))
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
673 (unless (secrets-empty-path item-path)
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
674 (secrets-prompt
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
675 (dbus-call-method
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
676 :session secrets-service item-path
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
677 secrets-interface-item "Delete")))))
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
678
108653
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
679 ;;; Visualization.
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
680
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
681 (define-derived-mode secrets-mode nil "Secrets"
108699
69ac0d220a1c * net/secrets.el: Autoload the widget functions.
Michael Albinus <michael.albinus@gmx.de>
parents: 108653
diff changeset
682 "Major mode for presenting password entries retrieved by Security Service.
108653
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
683 In this mode, widgets represent the search results.
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
684
108699
69ac0d220a1c * net/secrets.el: Autoload the widget functions.
Michael Albinus <michael.albinus@gmx.de>
parents: 108653
diff changeset
685 \\{secrets-mode-map}"
108653
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
686 ;; Keymap.
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
687 (setq secrets-mode-map (copy-keymap special-mode-map))
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
688 (set-keymap-parent secrets-mode-map widget-keymap)
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
689 (define-key secrets-mode-map "z" 'kill-this-buffer)
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
690
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
691 ;; When we toggle, we must set temporary widgets.
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
692 (set (make-local-variable 'tree-widget-after-toggle-functions)
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
693 '(secrets-tree-widget-after-toggle-function))
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
694
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
695 (when (not (called-interactively-p 'interactive))
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
696 ;; Initialize buffer.
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
697 (setq buffer-read-only t)
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
698 (let ((inhibit-read-only t))
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
699 (erase-buffer))))
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
700
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
701 ;; It doesn't make sense to call it interactively.
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
702 (put 'secrets-mode 'disabled t)
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
703
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
704 ;; The very first buffer created with `secrets-mode' does not have the
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
705 ;; keymap etc. So we create a dummy buffer. Stupid.
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
706 (with-temp-buffer (secrets-mode))
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
707
108699
69ac0d220a1c * net/secrets.el: Autoload the widget functions.
Michael Albinus <michael.albinus@gmx.de>
parents: 108653
diff changeset
708 ;; We autoload `secrets-show-secrets' only on systems with D-Bus support.
69ac0d220a1c * net/secrets.el: Autoload the widget functions.
Michael Albinus <michael.albinus@gmx.de>
parents: 108653
diff changeset
709 ;;;###autoload(when (featurep 'dbusbind)
69ac0d220a1c * net/secrets.el: Autoload the widget functions.
Michael Albinus <michael.albinus@gmx.de>
parents: 108653
diff changeset
710 ;;;###autoload (autoload 'secrets-show-secrets "secrets" nil t))
69ac0d220a1c * net/secrets.el: Autoload the widget functions.
Michael Albinus <michael.albinus@gmx.de>
parents: 108653
diff changeset
711
108653
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
712 (defun secrets-show-secrets ()
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
713 "Display a list of collections from the Secret Service API.
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
714 The collections are in tree view, that means they can be expanded
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
715 to the corresponding secret items, which could also be expanded
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
716 to their attributes."
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
717 (interactive)
108699
69ac0d220a1c * net/secrets.el: Autoload the widget functions.
Michael Albinus <michael.albinus@gmx.de>
parents: 108653
diff changeset
718
69ac0d220a1c * net/secrets.el: Autoload the widget functions.
Michael Albinus <michael.albinus@gmx.de>
parents: 108653
diff changeset
719 ;; Check, whether the Secret Service API is enabled.
69ac0d220a1c * net/secrets.el: Autoload the widget functions.
Michael Albinus <michael.albinus@gmx.de>
parents: 108653
diff changeset
720 (if (null secrets-enabled)
69ac0d220a1c * net/secrets.el: Autoload the widget functions.
Michael Albinus <michael.albinus@gmx.de>
parents: 108653
diff changeset
721 (message "Secret Service not available")
69ac0d220a1c * net/secrets.el: Autoload the widget functions.
Michael Albinus <michael.albinus@gmx.de>
parents: 108653
diff changeset
722
69ac0d220a1c * net/secrets.el: Autoload the widget functions.
Michael Albinus <michael.albinus@gmx.de>
parents: 108653
diff changeset
723 ;; Create the search buffer.
69ac0d220a1c * net/secrets.el: Autoload the widget functions.
Michael Albinus <michael.albinus@gmx.de>
parents: 108653
diff changeset
724 (with-current-buffer (get-buffer-create "*Secrets*")
69ac0d220a1c * net/secrets.el: Autoload the widget functions.
Michael Albinus <michael.albinus@gmx.de>
parents: 108653
diff changeset
725 (switch-to-buffer-other-window (current-buffer))
69ac0d220a1c * net/secrets.el: Autoload the widget functions.
Michael Albinus <michael.albinus@gmx.de>
parents: 108653
diff changeset
726 ;; Inialize buffer with `secrets-mode'.
69ac0d220a1c * net/secrets.el: Autoload the widget functions.
Michael Albinus <michael.albinus@gmx.de>
parents: 108653
diff changeset
727 (secrets-mode)
69ac0d220a1c * net/secrets.el: Autoload the widget functions.
Michael Albinus <michael.albinus@gmx.de>
parents: 108653
diff changeset
728 (secrets-show-collections))))
108653
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
729
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
730 (defun secrets-show-collections ()
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
731 "Show all available collections."
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
732 (let ((inhibit-read-only t)
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
733 (alias (secrets-get-alias "default")))
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
734 (erase-buffer)
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
735 (tree-widget-set-theme "folder")
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
736 (dolist (coll (secrets-list-collections))
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
737 (widget-create
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
738 `(tree-widget
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
739 :tag ,coll
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
740 :collection ,coll
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
741 :open nil
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
742 :sample-face bold
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
743 :expander secrets-expand-collection)))))
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
744
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
745 (defun secrets-expand-collection (widget)
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
746 "Expand items of collection shown as WIDGET."
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
747 (let ((coll (widget-get widget :collection)))
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
748 (mapcar
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
749 (lambda (item)
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
750 `(tree-widget
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
751 :tag ,item
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
752 :collection ,coll
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
753 :item ,item
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
754 :open nil
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
755 :sample-face bold
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
756 :expander secrets-expand-item))
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
757 (secrets-list-items coll))))
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
758
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
759 (defun secrets-expand-item (widget)
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
760 "Expand password and attributes of item shown as WIDGET."
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
761 (let* ((coll (widget-get widget :collection))
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
762 (item (widget-get widget :item))
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
763 (attributes (secrets-get-attributes coll item))
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
764 ;; padding is needed to format attribute names.
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
765 (padding
108699
69ac0d220a1c * net/secrets.el: Autoload the widget functions.
Michael Albinus <michael.albinus@gmx.de>
parents: 108653
diff changeset
766 (apply
69ac0d220a1c * net/secrets.el: Autoload the widget functions.
Michael Albinus <michael.albinus@gmx.de>
parents: 108653
diff changeset
767 'max
69ac0d220a1c * net/secrets.el: Autoload the widget functions.
Michael Albinus <michael.albinus@gmx.de>
parents: 108653
diff changeset
768 (cons
69ac0d220a1c * net/secrets.el: Autoload the widget functions.
Michael Albinus <michael.albinus@gmx.de>
parents: 108653
diff changeset
769 (1+ (length "password"))
69ac0d220a1c * net/secrets.el: Autoload the widget functions.
Michael Albinus <michael.albinus@gmx.de>
parents: 108653
diff changeset
770 (mapcar
69ac0d220a1c * net/secrets.el: Autoload the widget functions.
Michael Albinus <michael.albinus@gmx.de>
parents: 108653
diff changeset
771 ;; Atribute names have a leading ":", which will be suppressed.
69ac0d220a1c * net/secrets.el: Autoload the widget functions.
Michael Albinus <michael.albinus@gmx.de>
parents: 108653
diff changeset
772 (lambda (attribute) (length (symbol-name (car attribute))))
69ac0d220a1c * net/secrets.el: Autoload the widget functions.
Michael Albinus <michael.albinus@gmx.de>
parents: 108653
diff changeset
773 attributes)))))
108653
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
774 (cons
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
775 ;; The password widget.
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
776 `(editable-field :tag "password"
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
777 :secret ?*
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
778 :value ,(secrets-get-secret coll item)
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
779 :sample-face widget-button-pressed
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
780 ;; We specify :size in order to limit the field.
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
781 :size 0
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
782 :format ,(concat
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
783 "%{%t%}:"
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
784 (make-string (- padding (length "password")) ? )
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
785 "%v\n"))
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
786 (mapcar
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
787 (lambda (attribute)
108699
69ac0d220a1c * net/secrets.el: Autoload the widget functions.
Michael Albinus <michael.albinus@gmx.de>
parents: 108653
diff changeset
788 (let ((name (substring (symbol-name (car attribute)) 1))
108653
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
789 (value (cdr attribute)))
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
790 ;; The attribute widget.
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
791 `(editable-field :tag ,name
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
792 :value ,value
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
793 :sample-face widget-documentation
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
794 ;; We specify :size in order to limit the field.
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
795 :size 0
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
796 :format ,(concat
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
797 "%{%t%}:"
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
798 (make-string (- padding (length name)) ? )
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
799 "%v\n"))))
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
800 attributes))))
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
801
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
802 (defun secrets-tree-widget-after-toggle-function (widget &rest ignore)
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
803 "Add a temporary widget to show the password."
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
804 (dolist (child (widget-get widget :children))
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
805 (when (widget-member child :secret)
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
806 (goto-char (widget-field-end child))
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
807 (widget-insert " ")
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
808 (widget-create-child-and-convert
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
809 child 'push-button
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
810 :notify 'secrets-tree-widget-show-password
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
811 "Show password")))
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
812 (widget-setup))
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
813
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
814 (defun secrets-tree-widget-show-password (widget &rest ignore)
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
815 "Show password, and remove temporary widget."
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
816 (let ((parent (widget-get widget :parent)))
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
817 (widget-put parent :secret nil)
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
818 (widget-default-value-set parent (widget-get parent :value))
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
819 (widget-setup)))
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
820
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
821 ;;; Initialization.
feaedf49cc07 Add visualization code for secrets.
Michael Albinus <albinus@detlef>
parents: 107447
diff changeset
822
107397
6c48d0b283da * net/secrets.el (secrets-enabled): New variable. Use it instead
Michael Albinus <albinus@detlef>
parents: 107396
diff changeset
823 (when (dbus-ping :session secrets-service 100)
107396
d5de7ba3f80f * net/secrets.el (top): Register the D-Bus signals only when the
Michael Albinus <albinus@detlef>
parents: 107389
diff changeset
824
107397
6c48d0b283da * net/secrets.el (secrets-enabled): New variable. Use it instead
Michael Albinus <albinus@detlef>
parents: 107396
diff changeset
825 ;; We must reset all variables, when there is a new instance of the
6c48d0b283da * net/secrets.el (secrets-enabled): New variable. Use it instead
Michael Albinus <albinus@detlef>
parents: 107396
diff changeset
826 ;; "org.freedesktop.secrets" service.
6c48d0b283da * net/secrets.el (secrets-enabled): New variable. Use it instead
Michael Albinus <albinus@detlef>
parents: 107396
diff changeset
827 (dbus-register-signal
6c48d0b283da * net/secrets.el (secrets-enabled): New variable. Use it instead
Michael Albinus <albinus@detlef>
parents: 107396
diff changeset
828 :session dbus-service-dbus dbus-path-dbus
6c48d0b283da * net/secrets.el (secrets-enabled): New variable. Use it instead
Michael Albinus <albinus@detlef>
parents: 107396
diff changeset
829 dbus-interface-dbus "NameOwnerChanged"
6c48d0b283da * net/secrets.el (secrets-enabled): New variable. Use it instead
Michael Albinus <albinus@detlef>
parents: 107396
diff changeset
830 (lambda (&rest args)
6c48d0b283da * net/secrets.el (secrets-enabled): New variable. Use it instead
Michael Albinus <albinus@detlef>
parents: 107396
diff changeset
831 (when secrets-debug (message "Secret Service has changed: %S" args))
6c48d0b283da * net/secrets.el (secrets-enabled): New variable. Use it instead
Michael Albinus <albinus@detlef>
parents: 107396
diff changeset
832 (setq secrets-session-path secrets-empty-path
6c48d0b283da * net/secrets.el (secrets-enabled): New variable. Use it instead
Michael Albinus <albinus@detlef>
parents: 107396
diff changeset
833 secrets-prompt-signal nil
6c48d0b283da * net/secrets.el (secrets-enabled): New variable. Use it instead
Michael Albinus <albinus@detlef>
parents: 107396
diff changeset
834 secrets-collection-paths nil))
6c48d0b283da * net/secrets.el (secrets-enabled): New variable. Use it instead
Michael Albinus <albinus@detlef>
parents: 107396
diff changeset
835 secrets-service)
107389
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
836
107397
6c48d0b283da * net/secrets.el (secrets-enabled): New variable. Use it instead
Michael Albinus <albinus@detlef>
parents: 107396
diff changeset
837 ;; We want to refresh our cache, when there is a change in
6c48d0b283da * net/secrets.el (secrets-enabled): New variable. Use it instead
Michael Albinus <albinus@detlef>
parents: 107396
diff changeset
838 ;; collections.
6c48d0b283da * net/secrets.el (secrets-enabled): New variable. Use it instead
Michael Albinus <albinus@detlef>
parents: 107396
diff changeset
839 (dbus-register-signal
6c48d0b283da * net/secrets.el (secrets-enabled): New variable. Use it instead
Michael Albinus <albinus@detlef>
parents: 107396
diff changeset
840 :session secrets-service secrets-path
6c48d0b283da * net/secrets.el (secrets-enabled): New variable. Use it instead
Michael Albinus <albinus@detlef>
parents: 107396
diff changeset
841 secrets-interface-service "CollectionCreated"
6c48d0b283da * net/secrets.el (secrets-enabled): New variable. Use it instead
Michael Albinus <albinus@detlef>
parents: 107396
diff changeset
842 'secrets-collection-handler)
107389
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
843
107397
6c48d0b283da * net/secrets.el (secrets-enabled): New variable. Use it instead
Michael Albinus <albinus@detlef>
parents: 107396
diff changeset
844 (dbus-register-signal
6c48d0b283da * net/secrets.el (secrets-enabled): New variable. Use it instead
Michael Albinus <albinus@detlef>
parents: 107396
diff changeset
845 :session secrets-service secrets-path
6c48d0b283da * net/secrets.el (secrets-enabled): New variable. Use it instead
Michael Albinus <albinus@detlef>
parents: 107396
diff changeset
846 secrets-interface-service "CollectionDeleted"
6c48d0b283da * net/secrets.el (secrets-enabled): New variable. Use it instead
Michael Albinus <albinus@detlef>
parents: 107396
diff changeset
847 'secrets-collection-handler)
107396
d5de7ba3f80f * net/secrets.el (top): Register the D-Bus signals only when the
Michael Albinus <albinus@detlef>
parents: 107389
diff changeset
848
107397
6c48d0b283da * net/secrets.el (secrets-enabled): New variable. Use it instead
Michael Albinus <albinus@detlef>
parents: 107396
diff changeset
849 ;; We shall inform, whether the secret service is enabled on this
6c48d0b283da * net/secrets.el (secrets-enabled): New variable. Use it instead
Michael Albinus <albinus@detlef>
parents: 107396
diff changeset
850 ;; machine.
107447
9d443ad80849 Fix unbalanced parenthesis in secrets.el.
Ted Zlatanov <tzz@lifelogs.com>
parents: 107397
diff changeset
851 (setq secrets-enabled t))
107396
d5de7ba3f80f * net/secrets.el (top): Register the D-Bus signals only when the
Michael Albinus <albinus@detlef>
parents: 107389
diff changeset
852
107397
6c48d0b283da * net/secrets.el (secrets-enabled): New variable. Use it instead
Michael Albinus <albinus@detlef>
parents: 107396
diff changeset
853 (provide 'secrets)
107389
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
854
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
855 ;;; TODO:
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
856
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
857 ;; * secrets-debug should be structured like auth-source-debug to
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
858 ;; prevent leaking sensitive information. Right now I don't see
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
859 ;; anything sensitive though.
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
860 ;; * Check, whether the dh-ietf1024-aes128-cbc-pkcs7 algorithm can be
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
861 ;; used for the transfer of the secrets. Currently, we use the
51ddd70d1fa1 * etc/NEWS: Add secrets.el.
Michael Albinus <albinus@detlef>
parents:
diff changeset
862 ;; plain algorithm.