]> git.eshelyaron.com Git - emacs.git/commitdiff
Add "afp" method to Tramp
authorMichael Albinus <michael.albinus@gmx.de>
Thu, 29 Oct 2015 13:05:55 +0000 (14:05 +0100)
committerMichael Albinus <michael.albinus@gmx.de>
Thu, 29 Oct 2015 13:05:55 +0000 (14:05 +0100)
* doc/misc/tramp.texi (GVFS based methods): Describe `afp' method.

* lisp/net/tramp-gvfs.el (tramp-gvfs-methods): Add "afp" method.
(tramp-gvfs-handle-expand-file-name)
(tramp-gvfs-handler-mounted-unmounted)
(tramp-gvfs-connection-mounted-p, tramp-gvfs-mount-spec)
(tramp-gvfs-maybe-open-connection): Support also "afp".
(tramp-gvfs-handle-file-attributes): Handle the case of empty
"owner::user" and "owner::group" entries.

doc/misc/tramp.texi
etc/NEWS
lisp/net/tramp-gvfs.el

index 8673b00b23d5fa235fdc55b2ea43d6efb13cdef1..07d34bd4d2fef8fc425e7e60e6ebfe682ea08ca6 100644 (file)
@@ -1062,6 +1062,16 @@ Therefore, your @value{emacsname} must have D-Bus integration,
 @pxref{Top, , D-Bus, dbus}.
 
 @table @asis
+@item @option{afp}
+@cindex method afp
+@cindex afp method
+
+Access to Mac OS X volumes via the Apple Filing Protocol is offered by
+this method.  The access must always be performed with a leading
+volume (share) name, like @file{@trampfn{afp, user, host, /volume}}.
+
+
+
 @item @option{dav}
 @cindex method dav
 @cindex method davs
@@ -1107,9 +1117,10 @@ FUSE, it also needs the SYNCE-GVFS plugin.
 @vindex tramp-gvfs-methods
 @defopt tramp-gvfs-methods
 This custom option, a list, defines the external methods which shall
-be used with GVFS@.  Per default, these are @option{dav},
-@option{davs}, @option{obex}, @option{sftp} and @option{synce}.  Other
-possible values are @option{ftp} and @option{smb}.
+be used with GVFS@.  Per default, these are @option{afp},
+@option{dav}, @option{davs}, @option{obex}, @option{sftp} and
+@option{synce}.  Other possible values are @option{ftp} and
+@option{smb}.
 @end defopt
 @end ifset
 
index 512b491b5f8f89bc9ddca9fbdc179aa2525fecd0..0dbfd3f40229c35996c0485916a17f94ea11fc64 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -670,6 +670,10 @@ plist will contain a :peer element that has the output of
 
 ** Tramp
 
++++
+*** New connection method "afp", which allows to access Mac OS X
+volumes via the Apple Filing Protocol.
+
 +++
 *** New connection method "nc", which allows to access dumb busyboxes.
 
index 177ccfc37120d53fac1d81ad240c0636e969215d..c68b5e4c55c6fcaae57ee53c2c1712e4f002d2ef 100644 (file)
   (require 'custom))
 
 ;;;###tramp-autoload
-(defcustom tramp-gvfs-methods '("dav" "davs" "obex" "sftp" "synce")
+(defcustom tramp-gvfs-methods '("afp" "dav" "davs" "obex" "sftp" "synce")
   "List of methods for remote files, accessed with GVFS."
   :group 'tramp
-  :version "23.2"
-  :type '(repeat (choice (const "dav")
+  :version "25.1"
+  :type '(repeat (choice (const "afp")
+                        (const "dav")
                         (const "davs")
                         (const "ftp")
                         (const "obex")
@@ -231,7 +232,8 @@ It has been changed in GVFS 1.14.")
 ;;     ARRAY BYTE          mount_prefix
 ;;     ARRAY
 ;;       STRUCT                    mount_spec_item
-;;         STRING            key (server, share, type, user, host, port)
+;;         STRING            key (type, user, domain, host, server,
+;;                                 share, volume, port, ssl)
 ;;         ARRAY BYTE        value
 ;;   ARRAY BYTE           default_location     Since GVFS 1.5 only !!!
 
@@ -770,7 +772,7 @@ file names."
       (unless (tramp-run-real-handler 'file-name-absolute-p (list localname))
        (setq localname (concat "/" localname)))
       ;; We do not pass "/..".
-      (if (string-equal "smb" method)
+      (if (string-match "^\\(afp\\|smb\\)$" method)
          (when (string-match "^/[^/]+\\(/\\.\\./?\\)" localname)
            (setq localname (replace-match "/" t t localname 1)))
        (when (string-match "^/\\.\\./?" localname)
@@ -825,8 +827,9 @@ file names."
                            (if (re-search-forward
                                 "unix::uid:\\s-+\\([0-9]+\\)" nil t)
                                (string-to-number (match-string 1)))
-                         (if (re-search-forward
-                              "owner::user:\\s-+\\(\\S-+\\)" nil t)
+                         (if (and
+                              (re-search-forward "owner::user:\\s-+" nil t)
+                              (re-search-forward "(\\S-+\\)" (point-at-eol) t))
                              (match-string 1)))
                        (tramp-get-local-uid id-format)))
              (setq res-gid
@@ -834,8 +837,9 @@ file names."
                            (if (re-search-forward
                                 "unix::gid:\\s-+\\([0-9]+\\)" nil t)
                                (string-to-number (match-string 1)))
-                         (if (re-search-forward
-                              "owner::group:\\s-+\\(\\S-+\\)" nil t)
+                         (if (and
+                              (re-search-forward "owner::group:\\s-+" nil t)
+                              (re-search-forward "(\\S-+\\)" (point-at-eol) t))
                              (match-string 1)))
                        (tramp-get-local-gid id-format)))
              ;; ... last access, modification and change time
@@ -1346,12 +1350,14 @@ ADDRESS can have the form \"xx:xx:xx:xx:xx:xx\" or \"[xx:xx:xx:xx:xx:xx]\"."
                    (cadr (assoc "port" (cadr mount-spec)))))
             (ssl (tramp-gvfs-dbus-byte-array-to-string
                   (cadr (assoc "ssl" (cadr mount-spec)))))
-            (prefix (concat (tramp-gvfs-dbus-byte-array-to-string
-                             (car mount-spec))
-                            (tramp-gvfs-dbus-byte-array-to-string
-                             (cadr (assoc "share" (cadr mount-spec)))))))
-       (when (string-match "^smb" method)
-         (setq method "smb"))
+            (prefix (concat
+                     (tramp-gvfs-dbus-byte-array-to-string
+                      (car mount-spec))
+                     (tramp-gvfs-dbus-byte-array-to-string
+                      (or (cadr (assoc "share" (cadr mount-spec)))
+                          (cadr (assoc "volume" (cadr mount-spec))))))))
+       (when (string-match "^\\(afp\\|smb\\)" method)
+         (setq method (match-string 1 method)))
        (when (string-equal "obex" method)
          (setq host (tramp-bluez-device host)))
        (when (and (string-equal "dav" method) (string-equal "true" ssl))
@@ -1428,12 +1434,15 @@ ADDRESS can have the form \"xx:xx:xx:xx:xx:xx\" or \"[xx:xx:xx:xx:xx:xx]\"."
                     (cadr (assoc "port" (cadr mount-spec)))))
              (ssl (tramp-gvfs-dbus-byte-array-to-string
                    (cadr (assoc "ssl" (cadr mount-spec)))))
-             (prefix (concat (tramp-gvfs-dbus-byte-array-to-string
-                              (car mount-spec))
-                             (tramp-gvfs-dbus-byte-array-to-string
-                              (cadr (assoc "share" (cadr mount-spec)))))))
-        (when (string-match "^smb" method)
-          (setq method "smb"))
+             (prefix (concat
+                      (tramp-gvfs-dbus-byte-array-to-string
+                       (car mount-spec))
+                      (tramp-gvfs-dbus-byte-array-to-string
+                       (or
+                        (cadr (assoc "share" (cadr mount-spec)))
+                        (cadr (assoc "volume" (cadr mount-spec))))))))
+        (when (string-match "^\\(afp\\|smb\\)" method)
+          (setq method (match-string 1 method)))
         (when (string-equal "obex" method)
           (setq host (tramp-bluez-device host)))
         (when (and (string-equal "dav" method) (string-equal "true" ssl))
@@ -1473,16 +1482,16 @@ It was \"a(say)\", but has changed to \"a{sv})\"."
         (host (tramp-file-name-real-host vec))
         (port (tramp-file-name-port vec))
         (localname (tramp-file-name-localname vec))
-        (ssl (if (string-match "^davs" method) "true" "false"))
+        (share (when (string-match "^/?\\([^/]+\\)" localname)
+                 (match-string 1 localname)))
+        (ssl (when (string-match "^davs" method) "true" "false"))
         (mount-spec
           `(:array
             ,@(cond
                ((string-equal "smb" method)
-                (string-match "^/?\\([^/]+\\)" localname)
                 (list (tramp-gvfs-mount-spec-entry "type" "smb-share")
                       (tramp-gvfs-mount-spec-entry "server" host)
-                      (tramp-gvfs-mount-spec-entry
-                      "share" (match-string 1 localname))))
+                      (tramp-gvfs-mount-spec-entry "share" share)))
                ((string-equal "obex" method)
                 (list (tramp-gvfs-mount-spec-entry "type" method)
                       (tramp-gvfs-mount-spec-entry
@@ -1491,6 +1500,10 @@ It was \"a(say)\", but has changed to \"a{sv})\"."
                 (list (tramp-gvfs-mount-spec-entry "type" "dav")
                       (tramp-gvfs-mount-spec-entry "host" host)
                       (tramp-gvfs-mount-spec-entry "ssl" ssl)))
+               ((string-equal "afp" method)
+                (list (tramp-gvfs-mount-spec-entry "type" "afp-volume")
+                      (tramp-gvfs-mount-spec-entry "host" host)
+                      (tramp-gvfs-mount-spec-entry "volume" share)))
                (t
                 (list (tramp-gvfs-mount-spec-entry "type" method)
                       (tramp-gvfs-mount-spec-entry "host" host))))
@@ -1546,6 +1559,10 @@ connection if a previous connection has died for some reason."
                 (string-equal localname "/"))
        (tramp-error vec 'file-error "Filename must contain a Windows share"))
 
+      (when (and (string-equal method "afp")
+                (string-equal localname "/"))
+       (tramp-error vec 'file-error "Filename must contain an AFP volume"))
+
       (with-tramp-progress-reporter
          vec 3
          (if (zerop (length user))
@@ -1795,7 +1812,7 @@ They are retrieved from the hal daemon."
 
 ;;; TODO:
 
-;; * Host name completion via smb-server or smb-network.
+;; * Host name completion via afp-server, smb-server or smb-network.
 ;; * Check how two shares of the same SMB server can be mounted in
 ;;   parallel.
 ;; * Apply SDP on bluetooth devices, in order to filter out obex