comparison lisp/url/url-dav.el @ 63290:01f269fcca4c

Remove most autoload cookies. Don't hook into the url-file-handler since it currently breaks all non-HTTP URLs.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Fri, 10 Jun 2005 22:02:23 +0000
parents e30c08177a3b
children a8fa7c632ee4 e58cb448e07c
comparison
equal deleted inserted replaced
63289:8ae350152375 63290:01f269fcca4c
455 ">\n" 455 ">\n"
456 body 456 body
457 "</" (symbol-name tag) ">\n")))) 457 "</" (symbol-name tag) ">\n"))))
458 (url-dav-process-response (url-retrieve-synchronously url) url))) 458 (url-dav-process-response (url-retrieve-synchronously url) url)))
459 459
460 ;;;###autoload
461 (defun url-dav-get-properties (url &optional attributes depth namespaces) 460 (defun url-dav-get-properties (url &optional attributes depth namespaces)
462 "Return properties for URL, up to DEPTH levels deep. 461 "Return properties for URL, up to DEPTH levels deep.
463 462
464 Returns an assoc list, where the key is the filename (possibly a full 463 Returns an assoc list, where the key is the filename (possibly a full
465 URI), and the value is a standard property list of DAV property 464 URI), and the value is a standard property list of DAV property
485 This will be used as the contents of the DAV:owner/DAV:href tag to 484 This will be used as the contents of the DAV:owner/DAV:href tag to
486 identify the owner of a LOCK when requesting it. This will be shown 485 identify the owner of a LOCK when requesting it. This will be shown
487 to other users when the DAV:lockdiscovery property is requested, so 486 to other users when the DAV:lockdiscovery property is requested, so
488 make sure you are comfortable with it leaking to the outside world.") 487 make sure you are comfortable with it leaking to the outside world.")
489 488
490 ;;;###autoload
491 (defun url-dav-lock-resource (url exclusive &optional depth) 489 (defun url-dav-lock-resource (url exclusive &optional depth)
492 "Request a lock on URL. If EXCLUSIVE is non-nil, get an exclusive lock. 490 "Request a lock on URL. If EXCLUSIVE is non-nil, get an exclusive lock.
493 Optional 3rd argument DEPTH says how deep the lock should go, default is 0 491 Optional 3rd argument DEPTH says how deep the lock should go, default is 0
494 \(lock only the resource and none of its children\). 492 \(lock only the resource and none of its children\).
495 493
526 (if (url-dav-http-success-p child-status) 524 (if (url-dav-http-success-p child-status)
527 (push (list url child-status "huh") successes) 525 (push (list url child-status "huh") successes)
528 (push (list url child-status) failures))) 526 (push (list url child-status) failures)))
529 (cons successes failures))) 527 (cons successes failures)))
530 528
531 ;;;###autoload
532 (defun url-dav-active-locks (url &optional depth) 529 (defun url-dav-active-locks (url &optional depth)
533 "Return an assoc list of all active locks on URL." 530 "Return an assoc list of all active locks on URL."
534 (let ((response (url-dav-get-properties url '(DAV:lockdiscovery) depth)) 531 (let ((response (url-dav-get-properties url '(DAV:lockdiscovery) depth))
535 (properties nil) 532 (properties nil)
536 (child nil) 533 (child nil)
561 (if child-results 558 (if child-results
562 (push (cons (url-expand-file-name child-url url) child-results) 559 (push (cons (url-expand-file-name child-url url) child-results)
563 results))) 560 results)))
564 results)) 561 results))
565 562
566 ;;;###autoload
567 (defun url-dav-unlock-resource (url lock-token) 563 (defun url-dav-unlock-resource (url lock-token)
568 "Release the lock on URL represented by LOCK-TOKEN. 564 "Release the lock on URL represented by LOCK-TOKEN.
569 Returns t iff the lock was successfully released." 565 Returns t iff the lock was successfully released."
570 (declare (special url-http-response-status)) 566 (declare (special url-http-response-status))
571 (let* ((url-request-extra-headers (list (cons "Lock-Token" 567 (let* ((url-request-extra-headers (list (cons "Lock-Token"
622 (url-debug 'dav "Unrecognized DAV:locktype (%S)" (car lock))))) 618 (url-debug 'dav "Unrecognized DAV:locktype (%S)" (car lock)))))
623 modes)) 619 modes))
624 620
625 (autoload 'url-http-head-file-attributes "url-http") 621 (autoload 'url-http-head-file-attributes "url-http")
626 622
627 ;;;###autoload
628 (defun url-dav-file-attributes (url &optional id-format) 623 (defun url-dav-file-attributes (url &optional id-format)
629 (let ((properties (cdar (url-dav-get-properties url))) 624 (let ((properties (cdar (url-dav-get-properties url)))
630 (attributes nil)) 625 (attributes nil))
631 (if (and properties 626 (if (and properties
632 (url-dav-http-success-p (plist-get properties 'DAV:status))) 627 (url-dav-http-success-p (plist-get properties 'DAV:status)))
678 nil)) 673 nil))
679 ;; Fall back to just the normal http way of doing things. 674 ;; Fall back to just the normal http way of doing things.
680 (setq attributes (url-http-head-file-attributes url id-format))) 675 (setq attributes (url-http-head-file-attributes url id-format)))
681 attributes)) 676 attributes))
682 677
683 ;;;###autoload
684 (defun url-dav-save-resource (url obj &optional content-type lock-token) 678 (defun url-dav-save-resource (url obj &optional content-type lock-token)
685 "Save OBJ as URL using WebDAV. 679 "Save OBJ as URL using WebDAV.
686 URL must be a fully qualified URL. 680 URL must be a fully qualified URL.
687 OBJ may be a buffer or a string." 681 OBJ may be a buffer or a string."
688 (declare (special url-http-response-status)) 682 (declare (special url-http-response-status))
734 (list 728 (list
735 (cons "If" 729 (cons "If"
736 (concat "(<" ,lock-token ">)")))))))) 730 (concat "(<" ,lock-token ">)"))))))))
737 731
738 732
739 ;;;###autoload
740 (defun url-dav-delete-directory (url &optional recursive lock-token) 733 (defun url-dav-delete-directory (url &optional recursive lock-token)
741 "Delete the WebDAV collection URL. 734 "Delete the WebDAV collection URL.
742 If optional second argument RECURSIVE is non-nil, then delete all 735 If optional second argument RECURSIVE is non-nil, then delete all
743 files in the collection as well." 736 files in the collection as well."
744 (let ((status nil) 737 (let ((status nil)
759 "Errror removing" 752 "Errror removing"
760 (car result) status)))) 753 (car result) status))))
761 props)) 754 props))
762 nil) 755 nil)
763 756
764 ;;;###autoload
765 (defun url-dav-delete-file (url &optional lock-token) 757 (defun url-dav-delete-file (url &optional lock-token)
766 "Delete file named URL." 758 "Delete file named URL."
767 (let ((props nil) 759 (let ((props nil)
768 (status nil)) 760 (status nil))
769 (setq props (url-dav-delete-something 761 (setq props (url-dav-delete-something
779 "Errror removing" 771 "Errror removing"
780 (car result) status)))) 772 (car result) status))))
781 props)) 773 props))
782 nil) 774 nil)
783 775
784 ;;;###autoload
785 (defun url-dav-directory-files (url &optional full match nosort files-only) 776 (defun url-dav-directory-files (url &optional full match nosort files-only)
786 "Return a list of names of files in DIRECTORY. 777 "Return a list of names of files in DIRECTORY.
787 There are three optional arguments: 778 There are three optional arguments:
788 If FULL is non-nil, return absolute file names. Otherwise return names 779 If FULL is non-nil, return absolute file names. Otherwise return names
789 that are relative to the specified directory. 780 that are relative to the specified directory.
826 817
827 (if nosort 818 (if nosort
828 files 819 files
829 (sort files 'string-lessp)))) 820 (sort files 'string-lessp))))
830 821
831 ;;;###autoload
832 (defun url-dav-file-directory-p (url) 822 (defun url-dav-file-directory-p (url)
833 "Return t if URL names an existing DAV collection." 823 "Return t if URL names an existing DAV collection."
834 (let ((properties (cdar (url-dav-get-properties url '(DAV:resourcetype))))) 824 (let ((properties (cdar (url-dav-get-properties url '(DAV:resourcetype)))))
835 (eq (plist-get properties 'DAV:resourcetype) 'DAV:collection))) 825 (eq (plist-get properties 'DAV:resourcetype) 'DAV:collection)))
836 826
837 ;;;###autoload
838 (defun url-dav-make-directory (url &optional parents) 827 (defun url-dav-make-directory (url &optional parents)
839 "Create the directory DIR and any nonexistent parent dirs." 828 "Create the directory DIR and any nonexistent parent dirs."
840 (declare (special url-http-response-status)) 829 (declare (special url-http-response-status))
841 (let* ((url-request-extra-headers nil) 830 (let* ((url-request-extra-headers nil)
842 (url-request-method "MKCOL") 831 (url-request-method "MKCOL")
862 (otherwise 851 (otherwise
863 nil))) 852 nil)))
864 (kill-buffer buffer))) 853 (kill-buffer buffer)))
865 result)) 854 result))
866 855
867 ;;;###autoload
868 (defun url-dav-rename-file (oldname newname &optional overwrite) 856 (defun url-dav-rename-file (oldname newname &optional overwrite)
869 (if (not (and (string-match url-handler-regexp oldname) 857 (if (not (and (string-match url-handler-regexp oldname)
870 (string-match url-handler-regexp newname))) 858 (string-match url-handler-regexp newname)))
871 (signal 'file-error 859 (signal 'file-error
872 (list "Cannot rename between different URL backends" 860 (list "Cannot rename between different URL backends"
903 (if (not (url-dav-http-success-p status)) 891 (if (not (url-dav-http-success-p status))
904 (signal 'file-error (list "Renaming" oldname newname status)))) 892 (signal 'file-error (list "Renaming" oldname newname status))))
905 props) 893 props)
906 t)) 894 t))
907 895
908 ;;;###autoload
909 (defun url-dav-file-name-all-completions (file url) 896 (defun url-dav-file-name-all-completions (file url)
910 "Return a list of all completions of file name FILE in directory DIRECTORY. 897 "Return a list of all completions of file name FILE in directory DIRECTORY.
911 These are all file names in directory DIRECTORY which begin with FILE." 898 These are all file names in directory DIRECTORY which begin with FILE."
912 (url-dav-directory-files url nil (concat "^" file ".*"))) 899 (url-dav-directory-files url nil (concat "^" file ".*")))
913 900
914 ;;;###autoload
915 (defun url-dav-file-name-completion (file url) 901 (defun url-dav-file-name-completion (file url)
916 "Complete file name FILE in directory DIRECTORY. 902 "Complete file name FILE in directory DIRECTORY.
917 Returns the longest string 903 Returns the longest string
918 common to all file names in DIRECTORY that start with FILE. 904 common to all file names in DIRECTORY that start with FILE.
919 If there is only one and FILE matches it exactly, returns t. 905 If there is only one and FILE matches it exactly, returns t.
949 935
950 (defun url-dav-register-handler (op) 936 (defun url-dav-register-handler (op)
951 (put op 'url-file-handlers (intern-soft (format "url-dav-%s" op)))) 937 (put op 'url-file-handlers (intern-soft (format "url-dav-%s" op))))
952 938
953 (mapcar 'url-dav-register-handler 939 (mapcar 'url-dav-register-handler
954 '(file-name-all-completions 940 ;; These handlers are disabled because they incorrectly presume that
955 file-name-completion 941 ;; the URL specifies an HTTP location and thus break FTP URLs.
956 rename-file 942 '(;; file-name-all-completions
957 make-directory 943 ;; file-name-completion
958 file-directory-p 944 ;; rename-file
959 directory-files 945 ;; make-directory
960 delete-file 946 ;; file-directory-p
961 delete-directory 947 ;; directory-files
962 file-attributes)) 948 ;; delete-file
949 ;; delete-directory
950 ;; file-attributes
951 ))
963 952
964 953
965 ;;; Version Control backend cruft 954 ;;; Version Control backend cruft
966 955
967 ;(put 'vc-registered 'url-file-handlers 'url-dav-vc-registered) 956 ;(put 'vc-registered 'url-file-handlers 'url-dav-vc-registered)