Mercurial > emacs
comparison lisp/net/dbus.el @ 107255:6ea11661a516
* net/dbus.el (dbus-introspect, dbus-get-property)
(dbus-set-property, dbus-get-all-properties): Use
`dbus-call-method' when noninteractive. (Bug#5645)
author | Michael Albinus <albinus@detlef> |
---|---|
date | Sun, 28 Feb 2010 11:27:39 +0100 |
parents | 1d1d5d9bd884 |
children | 319b48a599cf |
comparison
equal
deleted
inserted
replaced
107254:f5443a6af811 | 107255:6ea11661a516 |
---|---|
571 the introspection data, is a string in XML format." | 571 the introspection data, is a string in XML format." |
572 ;; We don't want to raise errors. `dbus-call-method-non-blocking' | 572 ;; We don't want to raise errors. `dbus-call-method-non-blocking' |
573 ;; is used, because the handler can be registered in our Emacs | 573 ;; is used, because the handler can be registered in our Emacs |
574 ;; instance; caller an callee would block each other. | 574 ;; instance; caller an callee would block each other. |
575 (dbus-ignore-errors | 575 (dbus-ignore-errors |
576 (dbus-call-method-non-blocking | 576 (funcall |
577 (if noninteractive 'dbus-call-method 'dbus-call-method-non-blocking) | |
577 bus service path dbus-interface-introspectable "Introspect"))) | 578 bus service path dbus-interface-introspectable "Introspect"))) |
578 | 579 |
579 (defun dbus-introspect-xml (bus service path) | 580 (defun dbus-introspect-xml (bus service path) |
580 "Return the introspection data of SERVICE in D-Bus BUS at object path PATH. | 581 "Return the introspection data of SERVICE in D-Bus BUS at object path PATH. |
581 The data are a parsed list. The root object is a \"node\", | 582 The data are a parsed list. The root object is a \"node\", |
829 It will be checked at BUS, SERVICE, PATH. The result can be any | 830 It will be checked at BUS, SERVICE, PATH. The result can be any |
830 valid D-Bus value, or `nil' if there is no PROPERTY." | 831 valid D-Bus value, or `nil' if there is no PROPERTY." |
831 (dbus-ignore-errors | 832 (dbus-ignore-errors |
832 ;; "Get" returns a variant, so we must use the `car'. | 833 ;; "Get" returns a variant, so we must use the `car'. |
833 (car | 834 (car |
834 (dbus-call-method-non-blocking | 835 (funcall |
836 (if noninteractive 'dbus-call-method 'dbus-call-method-non-blocking) | |
835 bus service path dbus-interface-properties | 837 bus service path dbus-interface-properties |
836 "Get" :timeout 500 interface property)))) | 838 "Get" :timeout 500 interface property)))) |
837 | 839 |
838 (defun dbus-set-property (bus service path interface property value) | 840 (defun dbus-set-property (bus service path interface property value) |
839 "Set value of PROPERTY of INTERFACE to VALUE. | 841 "Set value of PROPERTY of INTERFACE to VALUE. |
840 It will be checked at BUS, SERVICE, PATH. When the value has | 842 It will be checked at BUS, SERVICE, PATH. When the value has |
841 been set successful, the result is VALUE. Otherwise, `nil' is | 843 been set successful, the result is VALUE. Otherwise, `nil' is |
842 returned." | 844 returned." |
843 (dbus-ignore-errors | 845 (dbus-ignore-errors |
844 ;; "Set" requires a variant. | 846 ;; "Set" requires a variant. |
845 (dbus-call-method-non-blocking | 847 (funcall |
848 (if noninteractive 'dbus-call-method 'dbus-call-method-non-blocking) | |
846 bus service path dbus-interface-properties | 849 bus service path dbus-interface-properties |
847 "Set" :timeout 500 interface property (list :variant value)) | 850 "Set" :timeout 500 interface property (list :variant value)) |
848 ;; Return VALUE. | 851 ;; Return VALUE. |
849 (dbus-get-property bus service path interface property))) | 852 (dbus-get-property bus service path interface property))) |
850 | 853 |
855 `nil' is returned." | 858 `nil' is returned." |
856 (dbus-ignore-errors | 859 (dbus-ignore-errors |
857 ;; "GetAll" returns "a{sv}". | 860 ;; "GetAll" returns "a{sv}". |
858 (let (result) | 861 (let (result) |
859 (dolist (dict | 862 (dolist (dict |
860 (dbus-call-method-non-blocking | 863 (funcall |
864 (if noninteractive | |
865 'dbus-call-method | |
866 'dbus-call-method-non-blocking) | |
861 bus service path dbus-interface-properties | 867 bus service path dbus-interface-properties |
862 "GetAll" :timeout 500 interface) | 868 "GetAll" :timeout 500 interface) |
863 result) | 869 result) |
864 (add-to-list 'result (cons (car dict) (caadr dict)) 'append))))) | 870 (add-to-list 'result (cons (car dict) (caadr dict)) 'append))))) |
865 | 871 |