[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/bluetooth 5219f05 31/57: fixes a compile error and adds
From: |
Stefan Monnier |
Subject: |
[elpa] externals/bluetooth 5219f05 31/57: fixes a compile error and adds customization |
Date: |
Thu, 7 Nov 2019 23:28:54 -0500 (EST) |
branch: externals/bluetooth
commit 5219f05ce155a537ff6a1d16e7eccfc0230ff899
Author: Raffael Stocker <address@hidden>
Commit: Raffael Stocker <address@hidden>
fixes a compile error and adds customization
Fixes error due to undefined `bluetooth--base-uuid' at compile time.
Adds customization group and item for Bluez bus (:system or :session).
---
bluetooth.el | 40 +++++++++++++++++++++++++++-------------
1 file changed, 27 insertions(+), 13 deletions(-)
diff --git a/bluetooth.el b/bluetooth.el
index 0e38ef6..3123389 100644
--- a/bluetooth.el
+++ b/bluetooth.el
@@ -46,6 +46,16 @@
(require 'dash)
(require 'rx)
+(defgroup bluetooth nil
+ "Bluetooth device management."
+ :group 'comm)
+
+(defcustom bluetooth-bluez-bus :system
+ "D-Bus bus that Bluez is registered on.
+This is usually `:system' if bluetoothd runs as a system service, or
+`:session' if it runs as a user service."
+ :type '(symbol))
+
(defconst bluetooth-buffer-name "*Bluetooth*"
"Name of the buffer in which to list bluetooth devices.")
@@ -87,6 +97,10 @@
(defvar bluetooth--method-objects '() "D-Bus method objects.")
+(eval-and-compile
+ (defconst bluetooth--base-uuid "0000-1000-8000-00805f9b34fb"
+ "Bluetooth base UUID."))
+
;;; API description:
;;;
;;; This is a plist of plists, providing API information for the
@@ -223,9 +237,10 @@ devices, as well as setting properties."
"Return a list of bluetooth adapters and devices connected to them."
(mapcar (lambda (a)
(list a (dbus-introspect-get-node-names
- :system bluetooth--service (concat bluetooth--root "/"
a))))
+ bluetooth-bluez-bus bluetooth--service
+ (concat bluetooth--root "/" a))))
(dbus-introspect-get-node-names
- :system bluetooth--service bluetooth--root)))
+ bluetooth-bluez-bus bluetooth--service bluetooth--root)))
;;; Given a device list as obtained from `bluetooth--get-devices'
;;; this function gathers all the properties of each device.
@@ -251,7 +266,8 @@ devices, as well as setting properties."
(list bluetooth--root (car devlist) dev)
"/")
collect (cons dev (list (dbus-get-all-properties
- :system bluetooth--service path
+ bluetooth-bluez-bus
+ bluetooth--service path
"org.bluez.Device1")))))
devices))
@@ -290,7 +306,7 @@ devices, as well as setting properties."
(plist-get (plist-get bluetooth--api-info api) :path)
"/"))
(interface (plist-get (plist-get bluetooth--api-info api) :interface)))
- (apply function :system bluetooth--service path interface
+ (apply function bluetooth-bluez-bus bluetooth--service path interface
(mapcar (lambda (x) (if (eq x :path-devid) (concat path "/" dev-id)
x))
args))))
@@ -353,8 +369,8 @@ devices, as well as setting properties."
"Get the current adapter state and display it.
This function only uses the first adapter reported by Bluez."
(let* ((adapters (dbus-introspect-get-node-names
- :system bluetooth--service bluetooth--root))
- (resp (dbus-get-all-properties :system bluetooth--service
+ bluetooth-bluez-bus bluetooth--service bluetooth--root))
+ (resp (dbus-get-all-properties bluetooth-bluez-bus bluetooth--service
(concat bluetooth--root "/"
(car adapters))
"org.bluez.Adapter1"))
@@ -383,7 +399,7 @@ This function only uses the first adapter reported by
Bluez."
"Display a list of Bluetooth devices that are available."
(interactive)
;; make sure D-Bus is (made) available
- (dbus-ping :system bluetooth--service bluetooth--timeout)
+ (dbus-ping bluetooth-bluez-bus bluetooth--service bluetooth--timeout)
(let ((buffer-exists (get-buffer bluetooth-buffer-name)))
(with-current-buffer (switch-to-buffer bluetooth-buffer-name)
(unless buffer-exists
@@ -508,28 +524,26 @@ This function only uses the first adapter reported by
Bluez."
"[A-Z][a-z]+"
(lambda (x) (concat "-" (downcase x)))
method t))
- collect (dbus-register-method :system dbus-service-emacs
+ collect (dbus-register-method bluetooth-bluez-bus
+ dbus-service-emacs
bluetooth--own-path
bluetooth--agent-intf
method (intern fname) t))))
(dbus-register-service :session dbus-service-emacs)
- (dbus-call-method :system bluetooth--service bluetooth--root
+ (dbus-call-method bluetooth-bluez-bus bluetooth--service bluetooth--root
bluetooth--agent-mngr-intf "RegisterAgent"
:object-path bluetooth--own-path "KeyboardDisplay"))
(defun bluetooth--unregister-agent ()
"Unregister the pairing agent."
(ignore-errors
- (dbus-call-method :system bluetooth--service bluetooth--root
+ (dbus-call-method bluetooth-bluez-bus bluetooth--service bluetooth--root
bluetooth--agent-mngr-intf "UnregisterAgent"
:object-path bluetooth--own-path)
(mapc #'dbus-unregister-object bluetooth--method-objects)))
;;; Application layer
-(defconst bluetooth--base-uuid "0000-1000-8000-00805f9b34fb"
- "Bluetooth base UUID.")
-
(defun bluetooth--parse-service-class-uuid (uuid)
"Parse UUID and return short and long service class names."
(let ((uuid-re (rx (seq bos (submatch (= 8 xdigit))
- [elpa] externals/bluetooth ee4e582 30/57: fixes compiler warnings about unused parameters, (continued)
- [elpa] externals/bluetooth ee4e582 30/57: fixes compiler warnings about unused parameters, Stefan Monnier, 2019/11/07
- [elpa] externals/bluetooth 3365413 33/57: corrects the major mode check in `list-bluetooth-devices', Stefan Monnier, 2019/11/07
- [elpa] externals/bluetooth b47bddc 36/57: switches device-info buffer to special mode, Stefan Monnier, 2019/11/07
- [elpa] externals/bluetooth 42a9487 35/57: moves `hl-line-mode' to end of init so hl is shown at startup, Stefan Monnier, 2019/11/07
- [elpa] externals/bluetooth 325febd 16/57: adds Imenu integration to Readme feature list, Stefan Monnier, 2019/11/07
- [elpa] externals/bluetooth f0e5047 18/57: removes unnecessary quotes before lambdas and corrects indentation, Stefan Monnier, 2019/11/07
- [elpa] externals/bluetooth 738347b 19/57: adds TAGS to .gitignore, Stefan Monnier, 2019/11/07
- [elpa] externals/bluetooth 28e9eb2 21/57: wraps @body in progn in bluetooth--maybe-cancel-reject, Stefan Monnier, 2019/11/07
- [elpa] externals/bluetooth 4133a10 13/57: makes mode idempotent, Stefan Monnier, 2019/11/07
- [elpa] externals/bluetooth 3c25a8c 23/57: adds basic service class UUID parsing, Stefan Monnier, 2019/11/07
- [elpa] externals/bluetooth 5219f05 31/57: fixes a compile error and adds customization,
Stefan Monnier <=
- [elpa] externals/bluetooth 0108cbd 32/57: uses `read-from-minibuffer' instead of `read-passwd', Stefan Monnier, 2019/11/07
- [elpa] externals/bluetooth 1ec2997 22/57: uses the correct bus (:system) for the callback methods, Stefan Monnier, 2019/11/07
- [elpa] externals/bluetooth 83344c8 20/57: cleans up display code, Stefan Monnier, 2019/11/07
- [elpa] externals/bluetooth fe926e9 28/57: puts functions before the long uuid defconsts for readability, Stefan Monnier, 2019/11/07
- [elpa] externals/bluetooth c473128 40/57: adds repository URL to mode (entry) command docstring, Stefan Monnier, 2019/11/07
- [elpa] externals/bluetooth eb1d4ea 25/57: adds UUID and service/device class parsing and display, Stefan Monnier, 2019/11/07
- [elpa] externals/bluetooth f9bfd26 39/57: fixes a grammatical mistake in Readme.org, Stefan Monnier, 2019/11/07
- [elpa] externals/bluetooth 565cfec 38/57: adds more elaborate usage information, Stefan Monnier, 2019/11/07
- [elpa] externals/bluetooth 7714f6b 45/57: updates Readme, Stefan Monnier, 2019/11/07
- [elpa] externals/bluetooth 1f3b244 47/57: makes checkdoc and package-lint happy, Stefan Monnier, 2019/11/07