aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Albinus2010-05-19 14:47:37 +0200
committerMichael Albinus2010-05-19 14:47:37 +0200
commit8d9181c7998eb4c69add7d79d96f2f0713503b1a (patch)
tree5f4842ca9146a849b3b7e444fa22bc128c5fd8bc
parentb59ee24dfb243e087c09abe66638480491c0ba18 (diff)
downloademacs-8d9181c7998eb4c69add7d79d96f2f0713503b1a.tar.gz
emacs-8d9181c7998eb4c69add7d79d96f2f0713503b1a.zip
* net/secrets.el: Autoload the widget functions.
(secrets-search-items, secrets-create-item) (secrets-get-attributes, secrets-expand-item): Attributes will be stored on the password database without leading ":", as all other clients do as well. (secrets-mode): Fix docstring. (secrets-show-secrets): Provide it as autoloaded command only when D-Bus support is available. Check existence of Secret Service API.
-rw-r--r--lisp/ChangeLog11
-rw-r--r--lisp/net/secrets.el64
2 files changed, 46 insertions, 29 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index a945b6251df..3489073f051 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,14 @@
12010-05-19 Michael Albinus <michael.albinus@gmx.de>
2
3 * net/secrets.el: Autoload the widget functions.
4 (secrets-search-items, secrets-create-item)
5 (secrets-get-attributes, secrets-expand-item): Attributes will be
6 stored on the password database without leading ":", as all other
7 clients do as well.
8 (secrets-mode): Fix docstring.
9 (secrets-show-secrets): Provide it as autoloaded command only when
10 D-Bus support is available. Check existence of Secret Service API.
11
12010-05-19 Stefan Monnier <monnier@iro.umontreal.ca> 122010-05-19 Stefan Monnier <monnier@iro.umontreal.ca>
2 13
3 * indent.el (indent-region): Deactivate region (bug#6200). 14 * indent.el (indent-region): Deactivate region (bug#6200).
diff --git a/lisp/net/secrets.el b/lisp/net/secrets.el
index a7225d663e3..4487407971f 100644
--- a/lisp/net/secrets.el
+++ b/lisp/net/secrets.el
@@ -151,11 +151,11 @@
151 151
152(require 'dbus) 152(require 'dbus)
153 153
154(declare-function tree-widget-set-theme "tree-widget") 154(autoload 'tree-widget-set-theme "tree-widget")
155(declare-function widget-create-child-and-convert "wid-edit") 155(autoload 'widget-create-child-and-convert "wid-edit")
156(declare-function widget-default-value-set "wid-edit") 156(autoload 'widget-default-value-set "wid-edit")
157(declare-function widget-field-end "wid-edit") 157(autoload 'widget-field-end "wid-edit")
158(declare-function widget-member "wid-edit") 158(autoload 'widget-member "wid-edit")
159(defvar tree-widget-after-toggle-functions) 159(defvar tree-widget-after-toggle-functions)
160 160
161(defvar secrets-enabled nil 161(defvar secrets-enabled nil
@@ -563,7 +563,7 @@ The object paths of the found items are returned as list."
563 (setq props (add-to-list 563 (setq props (add-to-list
564 'props 564 'props
565 (list :dict-entry 565 (list :dict-entry
566 (symbol-name (car attributes)) 566 (substring (symbol-name (car attributes)) 1)
567 (cadr attributes)) 567 (cadr attributes))
568 'append) 568 'append)
569 attributes (cddr attributes))) 569 attributes (cddr attributes)))
@@ -601,7 +601,7 @@ The object path of the created item is returned."
601 (setq props (add-to-list 601 (setq props (add-to-list
602 'props 602 'props
603 (list :dict-entry 603 (list :dict-entry
604 (symbol-name (car attributes)) 604 (substring (symbol-name (car attributes)) 1)
605 (cadr attributes)) 605 (cadr attributes))
606 'append) 606 'append)
607 attributes (cddr attributes))) 607 attributes (cddr attributes)))
@@ -656,7 +656,8 @@ If there is no such item, or the item has no attributes, return nil."
656 (let ((item-path (secrets-item-path collection item))) 656 (let ((item-path (secrets-item-path collection item)))
657 (unless (secrets-empty-path item-path) 657 (unless (secrets-empty-path item-path)
658 (mapcar 658 (mapcar
659 (lambda (attribute) (cons (intern (car attribute)) (cadr attribute))) 659 (lambda (attribute)
660 (cons (intern (concat ":" (car attribute))) (cadr attribute)))
660 (dbus-get-property 661 (dbus-get-property
661 :session secrets-service item-path 662 :session secrets-service item-path
662 secrets-interface-item "Attributes"))))) 663 secrets-interface-item "Attributes")))))
@@ -678,13 +679,10 @@ If there is no such item, or the item doesn't own this attribute, return nil."
678;;; Visualization. 679;;; Visualization.
679 680
680(define-derived-mode secrets-mode nil "Secrets" 681(define-derived-mode secrets-mode nil "Secrets"
681 "Major mode for presenting search results of a Xesam search. 682 "Major mode for presenting password entries retrieved by Security Service.
682In this mode, widgets represent the search results. 683In this mode, widgets represent the search results.
683 684
684\\{secrets-mode-map} 685\\{secrets-mode-map}"
685Turning on Xesam mode runs the normal hook `xesam-mode-hook'. It
686can be used to set `xesam-notify-function', which must a search
687engine specific, widget :notify function to visualize xesam:url."
688 ;; Keymap. 686 ;; Keymap.
689 (setq secrets-mode-map (copy-keymap special-mode-map)) 687 (setq secrets-mode-map (copy-keymap special-mode-map))
690 (set-keymap-parent secrets-mode-map widget-keymap) 688 (set-keymap-parent secrets-mode-map widget-keymap)
@@ -707,19 +705,27 @@ engine specific, widget :notify function to visualize xesam:url."
707;; keymap etc. So we create a dummy buffer. Stupid. 705;; keymap etc. So we create a dummy buffer. Stupid.
708(with-temp-buffer (secrets-mode)) 706(with-temp-buffer (secrets-mode))
709 707
710;;;###autoload 708;; We autoload `secrets-show-secrets' only on systems with D-Bus support.
709;;;###autoload(when (featurep 'dbusbind)
710;;;###autoload (autoload 'secrets-show-secrets "secrets" nil t))
711
711(defun secrets-show-secrets () 712(defun secrets-show-secrets ()
712 "Display a list of collections from the Secret Service API. 713 "Display a list of collections from the Secret Service API.
713The collections are in tree view, that means they can be expanded 714The collections are in tree view, that means they can be expanded
714to the corresponding secret items, which could also be expanded 715to the corresponding secret items, which could also be expanded
715to their attributes." 716to their attributes."
716 (interactive) 717 (interactive)
717 ;; Create the search buffer. 718
718 (with-current-buffer (get-buffer-create "*Secrets*") 719 ;; Check, whether the Secret Service API is enabled.
719 (switch-to-buffer-other-window (current-buffer)) 720 (if (null secrets-enabled)
720 ;; Inialize buffer with `secrets-mode'. 721 (message "Secret Service not available")
721 (secrets-mode) 722
722 (secrets-show-collections))) 723 ;; Create the search buffer.
724 (with-current-buffer (get-buffer-create "*Secrets*")
725 (switch-to-buffer-other-window (current-buffer))
726 ;; Inialize buffer with `secrets-mode'.
727 (secrets-mode)
728 (secrets-show-collections))))
723 729
724(defun secrets-show-collections () 730(defun secrets-show-collections ()
725 "Show all available collections." 731 "Show all available collections."
@@ -757,14 +763,14 @@ to their attributes."
757 (attributes (secrets-get-attributes coll item)) 763 (attributes (secrets-get-attributes coll item))
758 ;; padding is needed to format attribute names. 764 ;; padding is needed to format attribute names.
759 (padding 765 (padding
760 (1+ 766 (apply
761 (apply 767 'max
762 'max 768 (cons
763 (cons 769 (1+ (length "password"))
764 (length "password") 770 (mapcar
765 (mapcar 771 ;; Atribute names have a leading ":", which will be suppressed.
766 (lambda (attribute) (length (symbol-name (car attribute)))) 772 (lambda (attribute) (length (symbol-name (car attribute))))
767 attributes)))))) 773 attributes)))))
768 (cons 774 (cons
769 ;; The password widget. 775 ;; The password widget.
770 `(editable-field :tag "password" 776 `(editable-field :tag "password"
@@ -779,7 +785,7 @@ to their attributes."
779 "%v\n")) 785 "%v\n"))
780 (mapcar 786 (mapcar
781 (lambda (attribute) 787 (lambda (attribute)
782 (let ((name (symbol-name (car attribute))) 788 (let ((name (substring (symbol-name (car attribute)) 1))
783 (value (cdr attribute))) 789 (value (cdr attribute)))
784 ;; The attribute widget. 790 ;; The attribute widget.
785 `(editable-field :tag ,name 791 `(editable-field :tag ,name