Function: tramp-get-media-devices
tramp-get-media-devices is a byte-compiled function defined in
tramp-gvfs.el.gz.
Signature
(tramp-get-media-devices VEC)
Documentation
Retrieve media devices, and cache them.
The hash key is a tramp-media-device structure.
VEC is used only for traces.
Source Code
;; Defined in /usr/src/emacs/lisp/net/tramp-gvfs.el.gz
(defun tramp-get-media-devices (vec)
"Retrieve media devices, and cache them.
The hash key is a `tramp-media-device' structure.
VEC is used only for traces."
(let (devices)
(dolist (method tramp-media-methods)
(dolist (volume (cadr (with-tramp-dbus-call-method vec t
:session (tramp-gvfs-service-volumemonitor method)
tramp-gvfs-path-remotevolumemonitor
tramp-gvfs-interface-remotevolumemonitor "List")))
(let* ((uri (url-generic-parse-url (nth 5 volume)))
(vec (make-tramp-file-name
:method "mtp"
;; A host name cannot contain spaces.
:host (tramp-compat-string-replace " " "_" (nth 1 volume))))
(media (make-tramp-media-device
:method method
:host (tramp-gvfs-url-host (nth 5 volume))
:port (and (url-portspec uri)
(number-to-string (url-portspec uri))))))
(push (tramp-file-name-host vec) devices)
(tramp-set-connection-property vec "activation-uri" (nth 5 volume))
(tramp-set-connection-property vec "media-device" media)
(tramp-set-connection-property media "vector" vec))))
;; Adapt default host name, supporting /mtp:: when possible.
(setq tramp-default-host-alist
(append
`(("mtp" nil ,(if (= (length devices) 1) (car devices) "")))
(delete
(assoc "mtp" tramp-default-host-alist)
tramp-default-host-alist)))))