Mercurial > emacs
comparison lisp/net/dbus.el @ 112112:318b7249ccd0
* net/dbus.el (dbus-register-property): Added optional parameter
dont-register-service. Updated docstring accordingly.
author | Michael Albinus <michael.albinus@gmx.de> |
---|---|
date | Tue, 04 Jan 2011 11:57:24 +0100 |
parents | de02b794c330 |
children | af71852e09a2 |
comparison
equal
deleted
inserted
replaced
112111:4e3dc3aca537 | 112112:318b7249ccd0 |
---|---|
1 ;;; dbus.el --- Elisp bindings for D-Bus. | 1 ;;; dbus.el --- Elisp bindings for D-Bus. |
2 | 2 |
3 ;; Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc. | 3 ;; Copyright (C) 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. |
4 | 4 |
5 ;; Author: Michael Albinus <michael.albinus@gmx.de> | 5 ;; Author: Michael Albinus <michael.albinus@gmx.de> |
6 ;; Keywords: comm, hardware | 6 ;; Keywords: comm, hardware |
7 | 7 |
8 ;; This file is part of GNU Emacs. | 8 ;; This file is part of GNU Emacs. |
866 "GetAll" :timeout 500 interface) | 866 "GetAll" :timeout 500 interface) |
867 result) | 867 result) |
868 (add-to-list 'result (cons (car dict) (caadr dict)) 'append))))) | 868 (add-to-list 'result (cons (car dict) (caadr dict)) 'append))))) |
869 | 869 |
870 (defun dbus-register-property | 870 (defun dbus-register-property |
871 (bus service path interface property access value &optional emits-signal) | 871 (bus service path interface property access value |
872 &optional emits-signal dont-register-service) | |
872 "Register property PROPERTY on the D-Bus BUS. | 873 "Register property PROPERTY on the D-Bus BUS. |
873 | 874 |
874 BUS is either a Lisp symbol, `:system' or `:session', or a string | 875 BUS is either a Lisp symbol, `:system' or `:session', or a string |
875 denoting the bus address. | 876 denoting the bus address. |
876 | 877 |
877 SERVICE is the D-Bus service name of the D-Bus. It must be a | 878 SERVICE is the D-Bus service name of the D-Bus. It must be a |
878 known name. | 879 known name (See discussion of DONT-REGISTER-SERVICE below). |
879 | 880 |
880 PATH is the D-Bus object path SERVICE is registered. INTERFACE | 881 PATH is the D-Bus object path SERVICE is registered (See |
881 is the name of the interface used at PATH, PROPERTY is the name | 882 discussion of DONT-REGISTER-SERVICE below). INTERFACE is the |
882 of the property of INTERFACE. ACCESS indicates, whether the | 883 name of the interface used at PATH, PROPERTY is the name of the |
883 property can be changed by other services via D-Bus. It must be | 884 property of INTERFACE. ACCESS indicates, whether the property |
884 either the symbol `:read' or `:readwrite'. VALUE is the initial | 885 can be changed by other services via D-Bus. It must be either |
885 value of the property, it can be of any valid type (see | 886 the symbol `:read' or `:readwrite'. VALUE is the initial value |
887 of the property, it can be of any valid type (see | |
886 `dbus-call-method' for details). | 888 `dbus-call-method' for details). |
887 | 889 |
888 If PROPERTY already exists on PATH, it will be overwritten. For | 890 If PROPERTY already exists on PATH, it will be overwritten. For |
889 properties with access type `:read' this is the only way to | 891 properties with access type `:read' this is the only way to |
890 change their values. Properties with access type `:readwrite' | 892 change their values. Properties with access type `:readwrite' |
892 | 894 |
893 The interface \"org.freedesktop.DBus.Properties\" is added to | 895 The interface \"org.freedesktop.DBus.Properties\" is added to |
894 PATH, including a default handler for the \"Get\", \"GetAll\" and | 896 PATH, including a default handler for the \"Get\", \"GetAll\" and |
895 \"Set\" methods of this interface. When EMITS-SIGNAL is non-nil, | 897 \"Set\" methods of this interface. When EMITS-SIGNAL is non-nil, |
896 the signal \"PropertiesChanged\" is sent when the property is | 898 the signal \"PropertiesChanged\" is sent when the property is |
897 changed by `dbus-set-property'." | 899 changed by `dbus-set-property'. |
900 | |
901 When DONT-REGISTER-SERVICE is non-nil, the known name SERVICE is | |
902 not registered. This means that other D-Bus clients have no way | |
903 of noticing the newly registered property. When interfaces are | |
904 constructed incrementally by adding single methods or properties | |
905 at a time, DONT-REGISTER-SERVICE can be used to prevent other | |
906 clients from discovering the still incomplete interface." | |
898 (unless (member access '(:read :readwrite)) | 907 (unless (member access '(:read :readwrite)) |
899 (signal 'dbus-error (list "Access type invalid" access))) | 908 (signal 'dbus-error (list "Access type invalid" access))) |
900 | 909 |
901 ;; Register SERVICE. | 910 ;; Register SERVICE. |
902 (unless (member service (dbus-list-names bus)) | 911 (unless (or dont-register-service |
912 (member service (dbus-list-names bus))) | |
903 (dbus-call-method | 913 (dbus-call-method |
904 bus dbus-service-dbus dbus-path-dbus dbus-interface-dbus | 914 bus dbus-service-dbus dbus-path-dbus dbus-interface-dbus |
905 "RequestName" service 0)) | 915 "RequestName" service 0)) |
906 | 916 |
907 ;; Add the handler. We use `dbus-service-emacs' as service name, in | 917 ;; Add the handler. We use `dbus-service-emacs' as service name, in |
908 ;; order to let unregister SERVICE despite of this default handler. | 918 ;; order to let unregister SERVICE despite of this default handler. |
909 (dbus-register-method | 919 (dbus-register-method |
910 bus service path dbus-interface-properties "Get" 'dbus-property-handler) | 920 bus service path dbus-interface-properties "Get" 'dbus-property-handler |
921 dont-register-service) | |
911 (dbus-register-method | 922 (dbus-register-method |
912 bus service path dbus-interface-properties "GetAll" 'dbus-property-handler) | 923 bus service path dbus-interface-properties "GetAll" 'dbus-property-handler |
924 dont-register-service) | |
913 (dbus-register-method | 925 (dbus-register-method |
914 bus service path dbus-interface-properties "Set" 'dbus-property-handler) | 926 bus service path dbus-interface-properties "Set" 'dbus-property-handler |
927 dont-register-service) | |
915 | 928 |
916 ;; Send the PropertiesChanged signal. | 929 ;; Send the PropertiesChanged signal. |
917 (when emits-signal | 930 (when emits-signal |
918 (dbus-send-signal | 931 (dbus-send-signal |
919 bus service path dbus-interface-properties "PropertiesChanged" | 932 bus service path dbus-interface-properties "PropertiesChanged" |