54695
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1 ;;; url-dav.el --- WebDAV support
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
2
|
54828
|
3 ;; Copyright (C) 2001, 2004 Free Software Foundation, Inc.
|
54695
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
4
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
5 ;; Author: Bill Perry <wmperry@gnu.org>
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
6 ;; Maintainer: Bill Perry <wmperry@gnu.org>
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
7 ;; Keywords: url, vc
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
8
|
54828
|
9 ;; This file is part of GNU Emacs.
|
|
10
|
54695
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
12 ;; it under the terms of the GNU General Public License as published by
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
13 ;; the Free Software Foundation; either version 2, or (at your option)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
14 ;; any later version.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
15
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
16 ;; GNU Emacs is distributed in the hope that it will be useful,
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
19 ;; GNU General Public License for more details.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
20
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
21 ;; You should have received a copy of the GNU General Public License
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
24 ;; Boston, MA 02111-1307, USA.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
25
|
54795
|
26 ;; DAV is in RFC 2518.
|
|
27
|
54828
|
28 ;;; Commentary:
|
|
29
|
|
30 ;;; Code:
|
|
31
|
54695
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
32 (eval-when-compile
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
33 (require 'cl))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
34
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
35 (require 'xml)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
36 (require 'url-util)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
37 (require 'url-handlers)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
38
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
39 (defvar url-dav-supported-protocols '(1 2)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
40 "List of supported DAV versions.")
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
41
|
54795
|
42 (defun url-intersection (l1 l2)
|
|
43 "Return a list of the elements occuring in both of the lists L1 and L2."
|
|
44 (if (null l2)
|
|
45 l2
|
|
46 (let (result)
|
|
47 (while l1
|
|
48 (if (member (car l1) l2)
|
|
49 (setq result (cons (pop l1) result))
|
|
50 (pop l1)))
|
|
51 (nreverse result))))
|
|
52
|
54695
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
53 ;;;###autoload
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
54 (defun url-dav-supported-p (url)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
55 (and (featurep 'xml)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
56 (fboundp 'xml-expand-namespace)
|
54795
|
57 (url-intersection url-dav-supported-protocols
|
|
58 (plist-get (url-http-options url) 'dav))))
|
54695
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
59
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
60 (defun url-dav-node-text (node)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
61 "Return the text data from the XML node NODE."
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
62 (mapconcat (lambda (txt)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
63 (if (stringp txt)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
64 txt
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
65 "")) (xml-node-children node) " "))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
66
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
67
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
68 ;;; Parsing routines for the actual node contents.
|
54828
|
69 ;;
|
|
70 ;; I am not incredibly happy with how this code looks/works right
|
|
71 ;; now, but it DOES work, and if we get the API right, our callers
|
|
72 ;; won't have to worry about the internal representation.
|
54695
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
73
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
74 (defconst url-dav-datatype-attribute
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
75 'urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/dt)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
76
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
77 (defun url-dav-process-integer-property (node)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
78 (truncate (string-to-number (url-dav-node-text node))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
79
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
80 (defun url-dav-process-number-property (node)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
81 (string-to-number (url-dav-node-text node)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
82
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
83 (defconst url-dav-iso8601-regexp
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
84 (let* ((dash "-?")
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
85 (colon ":?")
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
86 (4digit "\\([0-9][0-9][0-9][0-9]\\)")
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
87 (2digit "\\([0-9][0-9]\\)")
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
88 (date-fullyear 4digit)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
89 (date-month 2digit)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
90 (date-mday 2digit)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
91 (time-hour 2digit)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
92 (time-minute 2digit)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
93 (time-second 2digit)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
94 (time-secfrac "\\(\\.[0-9]+\\)?")
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
95 (time-numoffset (concat "[-+]\\(" time-hour "\\):" time-minute))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
96 (time-offset (concat "Z" time-numoffset))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
97 (partial-time (concat time-hour colon time-minute colon time-second
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
98 time-secfrac))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
99 (full-date (concat date-fullyear dash date-month dash date-mday))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
100 (full-time (concat partial-time time-offset))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
101 (date-time (concat full-date "T" full-time)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
102 (list (concat "^" full-date)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
103 (concat "T" partial-time)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
104 (concat "Z" time-numoffset)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
105 "List of regular expressions matching iso8601 dates.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
106 1st regular expression matches the date.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
107 2nd regular expression matches the time.
|
54828
|
108 3rd regular expression matches the (optional) timezone specification.")
|
54695
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
109
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
110 (defun url-dav-process-date-property (node)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
111 (require 'parse-time)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
112 (let* ((date-re (nth 0 url-dav-iso8601-regexp))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
113 (time-re (nth 1 url-dav-iso8601-regexp))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
114 (tz-re (nth 2 url-dav-iso8601-regexp))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
115 (date-string (url-dav-node-text node))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
116 re-start
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
117 time seconds minute hour fractional-seconds
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
118 day month year day-of-week dst tz)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
119 ;; We need to populate 'time' with
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
120 ;; (SEC MIN HOUR DAY MON YEAR DOW DST TZ)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
121
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
122 ;; Nobody else handles iso8601 correctly, lets do it ourselves.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
123 (when (string-match date-re date-string re-start)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
124 (setq year (string-to-int (match-string 1 date-string))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
125 month (string-to-int (match-string 2 date-string))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
126 day (string-to-int (match-string 3 date-string))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
127 re-start (match-end 0))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
128 (when (string-match time-re date-string re-start)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
129 (setq hour (string-to-int (match-string 1 date-string))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
130 minute (string-to-int (match-string 2 date-string))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
131 seconds (string-to-int (match-string 3 date-string))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
132 fractional-seconds (string-to-int (or
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
133 (match-string 4 date-string)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
134 "0"))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
135 re-start (match-end 0))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
136 (when (string-match tz-re date-string re-start)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
137 (setq tz (match-string 1 date-string)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
138 (url-debug 'dav "Parsed iso8601%s date" (if tz "tz" ""))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
139 (setq time (list seconds minute hour day month year day-of-week dst tz))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
140
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
141 ;; Fall back to having Gnus do fancy things for us.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
142 (when (not time)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
143 (setq time (parse-time-string date-string)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
144
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
145 (if time
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
146 (setq time (apply 'encode-time time))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
147 (url-debug 'dav "Unable to decode date (%S) (%s)"
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
148 (xml-node-name node) date-string))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
149 time))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
150
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
151 (defun url-dav-process-boolean-property (node)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
152 (/= 0 (string-to-int (url-dav-node-text node))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
153
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
154 (defun url-dav-process-uri-property (node)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
155 ;; Returns a parsed representation of the URL...
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
156 (url-generic-parse-url (url-dav-node-text node)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
157
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
158 (defun url-dav-find-parser (node)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
159 "Find a function to parse the XML node NODE."
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
160 (or (get (xml-node-name node) 'dav-parser)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
161 (let ((fn (intern (format "url-dav-process-%s" (xml-node-name node)))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
162 (if (not (fboundp fn))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
163 (setq fn 'url-dav-node-text)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
164 (put (xml-node-name node) 'dav-parser fn))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
165 fn)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
166
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
167 (defmacro url-dav-dispatch-node (node)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
168 `(funcall (url-dav-find-parser ,node) ,node))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
169
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
170 (defun url-dav-process-DAV:prop (node)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
171 ;; A prop node has content model of ANY
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
172 ;;
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
173 ;; Some predefined nodes have special meanings though.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
174 ;;
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
175 ;; DAV:supportedlock - list of DAV:lockentry
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
176 ;; DAV:source
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
177 ;; DAV:iscollection - boolean
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
178 ;; DAV:getcontentlength - integer
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
179 ;; DAV:ishidden - boolean
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
180 ;; DAV:getcontenttype - string
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
181 ;; DAV:resourcetype - node who's name is the resource type
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
182 ;; DAV:getlastmodified - date
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
183 ;; DAV:creationdate - date
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
184 ;; DAV:displayname - string
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
185 ;; DAV:getetag - unknown
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
186 (let ((children (xml-node-children node))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
187 (node-type nil)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
188 (props nil)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
189 (value nil)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
190 (handler-func nil))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
191 (when (not children)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
192 (error "No child nodes in DAV:prop"))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
193
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
194 (while children
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
195 (setq node (car children)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
196 node-type (intern
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
197 (or
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
198 (cdr-safe (assq url-dav-datatype-attribute
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
199 (xml-node-attributes node)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
200 "unknown"))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
201 value nil)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
202
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
203 (case node-type
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
204 ((dateTime.iso8601tz
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
205 dateTime.iso8601
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
206 dateTime.tz
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
207 dateTime.rfc1123
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
208 dateTime
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
209 date) ; date is our 'special' one...
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
210 ;; Some type of date/time string.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
211 (setq value (url-dav-process-date-property node)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
212 (int
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
213 ;; Integer type...
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
214 (setq value (url-dav-process-integer-property node)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
215 ((number float)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
216 (setq value (url-dav-process-number-property node)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
217 (boolean
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
218 (setq value (url-dav-process-boolean-property node)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
219 (uri
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
220 (setq value (url-dav-process-uri-property node)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
221 (otherwise
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
222 (if (not (eq node-type 'unknown))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
223 (url-debug 'dav "Unknown data type in url-dav-process-prop: %s"
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
224 node-type))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
225 (setq value (url-dav-dispatch-node node))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
226
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
227 (setq props (plist-put props (xml-node-name node) value)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
228 children (cdr children)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
229 props))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
230
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
231 (defun url-dav-process-DAV:supportedlock (node)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
232 ;; DAV:supportedlock is a list of DAV:lockentry items.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
233 ;; DAV:lockentry in turn contains a DAV:lockscope and DAV:locktype.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
234 ;; The DAV:lockscope must have a single node beneath it, ditto for
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
235 ;; DAV:locktype.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
236 (let ((children (xml-node-children node))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
237 (results nil)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
238 scope type)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
239 (while children
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
240 (when (and (not (stringp (car children)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
241 (eq (xml-node-name (car children)) 'DAV:lockentry))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
242 (setq scope (assq 'DAV:lockscope (xml-node-children (car children)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
243 type (assq 'DAV:locktype (xml-node-children (car children))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
244 (when (and scope type)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
245 (setq scope (xml-node-name (car (xml-node-children scope)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
246 type (xml-node-name (car (xml-node-children type))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
247 (push (cons type scope) results)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
248 (setq children (cdr children)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
249 results))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
250
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
251 (defun url-dav-process-subnode-property (node)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
252 ;; Returns a list of child node names.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
253 (delq nil (mapcar 'car-safe (xml-node-children node))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
254
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
255 (defalias 'url-dav-process-DAV:depth 'url-dav-process-integer-property)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
256 (defalias 'url-dav-process-DAV:resourcetype 'url-dav-process-subnode-property)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
257 (defalias 'url-dav-process-DAV:locktype 'url-dav-process-subnode-property)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
258 (defalias 'url-dav-process-DAV:lockscope 'url-dav-process-subnode-property)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
259 (defalias 'url-dav-process-DAV:getcontentlength 'url-dav-process-integer-property)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
260 (defalias 'url-dav-process-DAV:getlastmodified 'url-dav-process-date-property)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
261 (defalias 'url-dav-process-DAV:creationdate 'url-dav-process-date-property)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
262 (defalias 'url-dav-process-DAV:iscollection 'url-dav-process-boolean-property)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
263 (defalias 'url-dav-process-DAV:ishidden 'url-dav-process-boolean-property)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
264
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
265 (defun url-dav-process-DAV:locktoken (node)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
266 ;; DAV:locktoken can have one or more DAV:href children.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
267 (delq nil (mapcar (lambda (n)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
268 (if (stringp n)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
269 n
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
270 (url-dav-dispatch-node n)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
271 (xml-node-children node))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
272
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
273 (defun url-dav-process-DAV:owner (node)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
274 ;; DAV:owner can contain anything.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
275 (delq nil (mapcar (lambda (n)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
276 (if (stringp n)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
277 n
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
278 (url-dav-dispatch-node n)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
279 (xml-node-children node))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
280
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
281 (defun url-dav-process-DAV:activelock (node)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
282 ;; DAV:activelock can contain:
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
283 ;; DAV:lockscope
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
284 ;; DAV:locktype
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
285 ;; DAV:depth
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
286 ;; DAV:owner (optional)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
287 ;; DAV:timeout (optional)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
288 ;; DAV:locktoken (optional)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
289 (let ((children (xml-node-children node))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
290 (results nil))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
291 (while children
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
292 (if (listp (car children))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
293 (push (cons (xml-node-name (car children))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
294 (url-dav-dispatch-node (car children)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
295 results))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
296 (setq children (cdr children)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
297 results))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
298
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
299 (defun url-dav-process-DAV:lockdiscovery (node)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
300 ;; Can only contain a list of DAV:activelock objects.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
301 (let ((children (xml-node-children node))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
302 (results nil))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
303 (while children
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
304 (cond
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
305 ((stringp (car children))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
306 ;; text node? why?
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
307 nil)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
308 ((eq (xml-node-name (car children)) 'DAV:activelock)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
309 (push (url-dav-dispatch-node (car children)) results))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
310 (t
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
311 ;; Ignore unknown nodes...
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
312 nil))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
313 (setq children (cdr children)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
314 results))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
315
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
316 (defun url-dav-process-DAV:status (node)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
317 ;; The node contains a standard HTTP/1.1 response line... we really
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
318 ;; only care about the numeric status code.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
319 (let ((status (url-dav-node-text node)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
320 (if (string-match "\\`[ \r\t\n]*HTTP/[0-9.]+ \\([0-9]+\\)" status)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
321 (string-to-int (match-string 1 status))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
322 500)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
323
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
324 (defun url-dav-process-DAV:propstat (node)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
325 ;; A propstate node can have the following children...
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
326 ;;
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
327 ;; DAV:prop - a list of properties and values
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
328 ;; DAV:status - An HTTP/1.1 status line
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
329 (let ((children (xml-node-children node))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
330 (props nil)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
331 (status nil))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
332 (when (not children)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
333 (error "No child nodes in DAV:propstat"))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
334
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
335 (setq props (url-dav-dispatch-node (assq 'DAV:prop children))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
336 status (url-dav-dispatch-node (assq 'DAV:status children)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
337
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
338 ;; Need to parse out the HTTP status
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
339 (setq props (plist-put props 'DAV:status status))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
340 props))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
341
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
342 (defun url-dav-process-DAV:response (node)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
343 (let ((children (xml-node-children node))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
344 (propstat nil)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
345 (href))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
346 (when (not children)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
347 (error "No child nodes in DAV:response"))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
348
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
349 ;; A response node can have the following children...
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
350 ;;
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
351 ;; DAV:href - URL the response is for.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
352 ;; DAV:propstat - see url-dav-process-propstat
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
353 ;; DAV:responsedescription - text description of the response
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
354 (setq propstat (assq 'DAV:propstat children)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
355 href (assq 'DAV:href children))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
356
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
357 (when (not href)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
358 (error "No href in DAV:response"))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
359
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
360 (when (not propstat)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
361 (error "No propstat in DAV:response"))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
362
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
363 (setq propstat (url-dav-dispatch-node propstat)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
364 href (url-dav-dispatch-node href))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
365 (cons href propstat)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
366
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
367 (defun url-dav-process-DAV:multistatus (node)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
368 (let ((children (xml-node-children node))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
369 (results nil))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
370 (while children
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
371 (push (url-dav-dispatch-node (car children)) results)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
372 (setq children (cdr children)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
373 results))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
374
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
375
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
376 ;;; DAV request/response generation/processing
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
377 (defun url-dav-process-response (buffer url)
|
54828
|
378 "Parse a WebDAV response from BUFFER, interpreting it relative to URL.
|
54695
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
379
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
380 The buffer must have been retrieved by HTTP or HTTPS and contain an
|
54828
|
381 XML document."
|
54695
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
382 (declare (special url-http-content-type
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
383 url-http-response-status
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
384 url-http-end-of-headers))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
385 (let ((tree nil)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
386 (overall-status nil))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
387 (when buffer
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
388 (unwind-protect
|
54929
|
389 (with-current-buffer buffer
|
54695
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
390 (goto-char url-http-end-of-headers)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
391 (setq overall-status url-http-response-status)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
392
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
393 ;; XML documents can be transferred as either text/xml or
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
394 ;; application/xml, and we are required to accept both of
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
395 ;; them.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
396 (if (and
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
397 url-http-content-type
|
54929
|
398 (string-match "\\`\\(text\\|application\\)/xml"
|
|
399 url-http-content-type))
|
54695
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
400 (setq tree (xml-parse-region (point) (point-max)))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
401 ;; Clean up after ourselves.
|
54929
|
402 (kill-buffer buffer)))
|
54695
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
403
|
54929
|
404 ;; We should now be
|
54695
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
405 (if (eq (xml-node-name (car tree)) 'DAV:multistatus)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
406 (url-dav-dispatch-node (car tree))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
407 (url-debug 'dav "Got back singleton response for URL(%S)" url)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
408 (let ((properties (url-dav-dispatch-node (car tree))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
409 ;; We need to make sure we have a DAV:status node in there for
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
410 ;; higher-level code;
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
411 (setq properties (plist-put properties 'DAV:status overall-status))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
412 ;; Make this look like a DAV:multistatus parse tree so that
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
413 ;; nobody but us needs to know the difference.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
414 (list (cons url properties))))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
415
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
416 (defun url-dav-request (url method tag body
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
417 &optional depth headers namespaces)
|
54828
|
418 "Perform WebDAV operation METHOD on URL. Return the parsed responses.
|
54695
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
419 Automatically creates an XML request body if TAG is non-nil.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
420 BODY is the XML document fragment to be enclosed by <TAG></TAG>.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
421
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
422 DEPTH is how deep the request should propogate. Default is 0, meaning
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
423 it should apply only to URL. A negative number means to use
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
424 `Infinity' for the depth. Not all WebDAV servers support this depth
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
425 though.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
426
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
427 HEADERS is an assoc list of extra headers to send in the request.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
428
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
429 NAMESPACES is an assoc list of (NAMESPACE . EXPANSION), and these are
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
430 added to the <TAG> element. The DAV=DAV: namespace is automatically
|
54828
|
431 added to this list, so most requests can just pass in nil."
|
54695
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
432 ;; Take care of the default value for depth...
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
433 (setq depth (or depth 0))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
434
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
435 ;; Now lets translate it into something webdav can understand.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
436 (if (< depth 0)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
437 (setq depth "Infinity")
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
438 (setq depth (int-to-string depth)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
439 (if (not (assoc "DAV" namespaces))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
440 (setq namespaces (cons '("DAV" . "DAV:") namespaces)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
441
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
442 (let* ((url-request-extra-headers `(("Depth" . ,depth)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
443 ("Content-type" . "text/xml")
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
444 ,@headers))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
445 (url-request-method method)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
446 (url-request-data
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
447 (if tag
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
448 (concat
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
449 "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n"
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
450 "<" (symbol-name tag) " "
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
451 ;; add in the appropriate namespaces...
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
452 (mapconcat (lambda (ns)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
453 (concat "xmlns:" (car ns) "='" (cdr ns) "'"))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
454 namespaces "\n ")
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
455 ">\n"
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
456 body
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
457 "</" (symbol-name tag) ">\n"))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
458 (url-dav-process-response (url-retrieve-synchronously url) url)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
459
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
460 ;;;###autoload
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
461 (defun url-dav-get-properties (url &optional attributes depth namespaces)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
462 "Return properties for URL, up to DEPTH levels deep.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
463
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
464 Returns an assoc list, where the key is the filename (possibly a full
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
465 URI), and the value is a standard property list of DAV property
|
54828
|
466 names (ie: DAV:resourcetype)."
|
54695
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
467 (url-dav-request url "PROPFIND" 'DAV:propfind
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
468 (if attributes
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
469 (mapconcat (lambda (attr)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
470 (concat "<DAV:prop><"
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
471 (symbol-name attr)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
472 "/></DAV:prop>"))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
473 attributes "\n ")
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
474 " <DAV:allprop/>")
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
475 depth nil namespaces))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
476
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
477 (defmacro url-dav-http-success-p (status)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
478 "Return whether PROPERTIES was the result of a successful DAV request."
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
479 `(= (/ (or ,status 500) 100) 2))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
480
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
481
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
482 ;;; Locking support
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
483 (defvar url-dav-lock-identifier (concat "mailto:" user-mail-address)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
484 "*URL used as contact information when creating locks in DAV.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
485 This will be used as the contents of the DAV:owner/DAV:href tag to
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
486 identify the owner of a LOCK when requesting it. This will be shown
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
487 to other users when the DAV:lockdiscovery property is requested, so
|
54828
|
488 make sure you are comfortable with it leaking to the outside world.")
|
54695
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
489
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
490 ;;;###autoload
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
491 (defun url-dav-lock-resource (url exclusive &optional depth)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
492 "Request a lock on URL. If EXCLUSIVE is non-nil, get an exclusive lock.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
493 Optional 3rd argument DEPTH says how deep the lock should go, default is 0
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
494 \(lock only the resource and none of its children\).
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
495
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
496 Returns a cons-cell of (SUCCESSFUL-RESULTS . FAILURE-RESULTS).
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
497 SUCCESSFUL-RESULTS is a list of (URL STATUS locktoken).
|
54828
|
498 FAILURE-RESULTS is a list of (URL STATUS)."
|
54695
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
499 (setq exclusive (if exclusive "<DAV:exclusive/>" "<DAV:shared/>"))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
500 (let* ((body
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
501 (concat
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
502 " <DAV:lockscope>" exclusive "</DAV:lockscope>\n"
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
503 " <DAV:locktype> <DAV:write/> </DAV:locktype>\n"
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
504 " <DAV:owner>\n"
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
505 " <DAV:href>" url-dav-lock-identifier "</DAV:href>\n"
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
506 " </DAV:owner>\n"))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
507 (response nil) ; Responses to the LOCK request
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
508 (result nil) ; For walking thru the response list
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
509 (child-url nil)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
510 (child-status nil)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
511 (failures nil) ; List of failure cases (URL . STATUS)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
512 (successes nil)) ; List of success cases (URL . STATUS)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
513 (setq response (url-dav-request url "LOCK" 'DAV:lockinfo body
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
514 depth '(("Timeout" . "Infinite"))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
515
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
516 ;; Get the parent URL ready for expand-file-name
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
517 (if (not (vectorp url))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
518 (setq url (url-generic-parse-url url)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
519
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
520 ;; Walk thru the response list, fully expand the URL, and grab the
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
521 ;; status code.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
522 (while response
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
523 (setq result (pop response)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
524 child-url (url-expand-file-name (pop result) url)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
525 child-status (or (plist-get result 'DAV:status) 500))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
526 (if (url-dav-http-success-p child-status)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
527 (push (list url child-status "huh") successes)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
528 (push (list url child-status) failures)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
529 (cons successes failures)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
530
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
531 ;;;###autoload
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
532 (defun url-dav-active-locks (url &optional depth)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
533 "Return an assoc list of all active locks on URL."
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
534 (let ((response (url-dav-get-properties url '(DAV:lockdiscovery) depth))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
535 (properties nil)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
536 (child nil)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
537 (child-url nil)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
538 (child-results nil)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
539 (results nil))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
540 (if (not (vectorp url))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
541 (setq url (url-generic-parse-url url)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
542
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
543 (while response
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
544 (setq child (pop response)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
545 child-url (pop child)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
546 child-results nil)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
547 (when (and (url-dav-http-success-p (plist-get child 'DAV:status))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
548 (setq child (plist-get child 'DAV:lockdiscovery)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
549 ;; After our parser has had its way with it, The
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
550 ;; DAV:lockdiscovery property is a list of DAV:activelock
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
551 ;; objects, which are comprised of DAV:activelocks, which
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
552 ;; assoc lists of properties and values.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
553 (while child
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
554 (if (assq 'DAV:locktoken (car child))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
555 (let ((tokens (cdr (assq 'DAV:locktoken (car child))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
556 (owners (cdr (assq 'DAV:owner (car child)))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
557 (dolist (token tokens)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
558 (dolist (owner owners)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
559 (push (cons token owner) child-results)))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
560 (pop child)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
561 (if child-results
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
562 (push (cons (url-expand-file-name child-url url) child-results)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
563 results)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
564 results))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
565
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
566 ;;;###autoload
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
567 (defun url-dav-unlock-resource (url lock-token)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
568 "Release the lock on URL represented by LOCK-TOKEN.
|
54828
|
569 Returns t iff the lock was successfully released."
|
54695
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
570 (declare (special url-http-response-status))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
571 (let* ((url-request-extra-headers (list (cons "Lock-Token"
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
572 (concat "<" lock-token ">"))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
573 (url-request-method "UNLOCK")
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
574 (url-request-data nil)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
575 (buffer (url-retrieve-synchronously url))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
576 (result nil))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
577 (when buffer
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
578 (unwind-protect
|
54929
|
579 (with-current-buffer buffer
|
54695
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
580 (setq result (url-dav-http-success-p url-http-response-status)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
581 (kill-buffer buffer)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
582 result))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
583
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
584
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
585 ;;; file-name-handler stuff
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
586 (defun url-dav-file-attributes-mode-string (properties)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
587 (let ((modes (make-string 10 ?-))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
588 (supported-locks (plist-get properties 'DAV:supportedlock))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
589 (executable-p (equal (plist-get properties 'http://apache.org/dav/props/executable)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
590 "T"))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
591 (directory-p (memq 'DAV:collection (plist-get properties 'DAV:resourcetype)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
592 (readable t)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
593 (lock nil))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
594 ;; Assume we can read this, otherwise the PROPFIND would have
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
595 ;; failed.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
596 (when readable
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
597 (aset modes 1 ?r)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
598 (aset modes 4 ?r)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
599 (aset modes 7 ?r))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
600
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
601 (when directory-p
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
602 (aset modes 0 ?d))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
603
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
604 (when executable-p
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
605 (aset modes 3 ?x)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
606 (aset modes 6 ?x)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
607 (aset modes 9 ?x))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
608
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
609 (while supported-locks
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
610 (setq lock (car supported-locks)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
611 supported-locks (cdr supported-locks))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
612 (case (car lock)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
613 (DAV:write
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
614 (case (cdr lock)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
615 (DAV:shared ; group permissions (possibly world)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
616 (aset modes 5 ?w))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
617 (DAV:exclusive
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
618 (aset modes 2 ?w)) ; owner permissions?
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
619 (otherwise
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
620 (url-debug 'dav "Unrecognized DAV:lockscope (%S)" (cdr lock)))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
621 (otherwise
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
622 (url-debug 'dav "Unrecognized DAV:locktype (%S)" (car lock)))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
623 modes))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
624
|
54795
|
625 (autoload 'url-http-head-file-attributes "url-http")
|
|
626
|
54695
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
627 ;;;###autoload
|
54929
|
628 (defun url-dav-file-attributes (url &optional id-format)
|
54695
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
629 (let ((properties (cdar (url-dav-get-properties url)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
630 (attributes nil))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
631 (if (and properties
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
632 (url-dav-http-success-p (plist-get properties 'DAV:status)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
633 ;; We got a good DAV response back..
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
634 (setq attributes
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
635 (list
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
636 ;; t for directory, string for symbolic link, or nil
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
637 ;; Need to support DAV Bindings to figure out the
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
638 ;; symbolic link issues.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
639 (if (memq 'DAV:collection (plist-get properties 'DAV:resourcetype)) t nil)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
640
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
641 ;; Number of links to file... Needs DAV Bindings.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
642 1
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
643
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
644 ;; File uid - no way to figure out?
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
645 0
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
646
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
647 ;; File gid - no way to figure out?
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
648 0
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
649
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
650 ;; Last access time - ???
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
651 nil
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
652
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
653 ;; Last modification time
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
654 (plist-get properties 'DAV:getlastmodified)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
655
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
656 ;; Last status change time... just reuse last-modified
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
657 ;; for now.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
658 (plist-get properties 'DAV:getlastmodified)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
659
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
660 ;; size in bytes
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
661 (or (plist-get properties 'DAV:getcontentlength) 0)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
662
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
663 ;; file modes as a string like `ls -l'
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
664 ;;
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
665 ;; Should be able to build this up from the
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
666 ;; DAV:supportedlock attribute pretty easily. Getting
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
667 ;; the group info could be impossible though.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
668 (url-dav-file-attributes-mode-string properties)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
669
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
670 ;; t iff file's gid would change if it were deleted &
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
671 ;; recreated. No way for us to know that thru DAV.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
672 nil
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
673
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
674 ;; inode number - meaningless
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
675 nil
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
676
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
677 ;; device number - meaningless
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
678 nil))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
679 ;; Fall back to just the normal http way of doing things.
|
54929
|
680 (setq attributes (url-http-head-file-attributes url id-format)))
|
54695
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
681 attributes))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
682
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
683 ;;;###autoload
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
684 (defun url-dav-save-resource (url obj &optional content-type lock-token)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
685 "Save OBJ as URL using WebDAV.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
686 URL must be a fully qualified URL.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
687 OBJ may be a buffer or a string."
|
54795
|
688 (declare (special url-http-response-status))
|
54695
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
689 (let ((buffer nil)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
690 (result nil)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
691 (url-request-extra-headers nil)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
692 (url-request-method "PUT")
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
693 (url-request-data
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
694 (cond
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
695 ((bufferp obj)
|
54929
|
696 (with-current-buffer obj
|
54695
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
697 (buffer-string)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
698 ((stringp obj)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
699 obj)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
700 (t
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
701 (error "Invalid object to url-dav-save-resource")))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
702
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
703 (if lock-token
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
704 (push
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
705 (cons "If" (concat "(<" lock-token ">)"))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
706 url-request-extra-headers))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
707
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
708 ;; Everything must always have a content-type when we submit it.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
709 (push
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
710 (cons "Content-type" (or content-type "application/octet-stream"))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
711 url-request-extra-headers)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
712
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
713 ;; Do the save...
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
714 (setq buffer (url-retrieve-synchronously url))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
715
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
716 ;; Sanity checking
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
717 (when buffer
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
718 (unwind-protect
|
54929
|
719 (with-current-buffer buffer
|
54695
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
720 (setq result (url-dav-http-success-p url-http-response-status)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
721 (kill-buffer buffer)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
722 result))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
723
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
724 (eval-when-compile
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
725 (defmacro url-dav-delete-something (url lock-token &rest error-checking)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
726 "Delete URL completely, with no sanity checking whatsoever. DO NOT USE.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
727 This is defined as a macro that will not be visible from compiled files.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
728 Use with care, and even then think three times.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
729 "
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
730 `(progn
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
731 ,@error-checking
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
732 (url-dav-request ,url "DELETE" nil nil -1
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
733 (if ,lock-token
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
734 (list
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
735 (cons "If"
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
736 (concat "(<" ,lock-token ">)"))))))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
737
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
738
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
739 ;;;###autoload
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
740 (defun url-dav-delete-directory (url &optional recursive lock-token)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
741 "Delete the WebDAV collection URL.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
742 If optional second argument RECURSIVE is non-nil, then delete all
|
54828
|
743 files in the collection as well."
|
54695
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
744 (let ((status nil)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
745 (props nil)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
746 (props nil))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
747 (setq props (url-dav-delete-something
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
748 url lock-token
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
749 (setq props (url-dav-get-properties url '(DAV:getcontenttype) 1))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
750 (if (and (not recursive)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
751 (/= (length props) 1))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
752 (signal 'file-error (list "Removing directory"
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
753 "directory not empty" url)))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
754
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
755 (mapc (lambda (result)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
756 (setq status (plist-get (cdr result) 'DAV:status))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
757 (if (not (url-dav-http-success-p status))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
758 (signal 'file-error (list "Removing directory"
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
759 "Errror removing"
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
760 (car result) status))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
761 props))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
762 nil)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
763
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
764 ;;;###autoload
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
765 (defun url-dav-delete-file (url &optional lock-token)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
766 "Delete file named URL."
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
767 (let ((props nil)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
768 (status nil))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
769 (setq props (url-dav-delete-something
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
770 url lock-token
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
771 (setq props (url-dav-get-properties url))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
772 (if (eq (plist-get (cdar props) 'DAV:resourcetype) 'DAV:collection)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
773 (signal 'file-error (list "Removing old name" "is a collection" url)))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
774
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
775 (mapc (lambda (result)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
776 (setq status (plist-get (cdr result) 'DAV:status))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
777 (if (not (url-dav-http-success-p status))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
778 (signal 'file-error (list "Removing old name"
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
779 "Errror removing"
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
780 (car result) status))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
781 props))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
782 nil)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
783
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
784 ;;;###autoload
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
785 (defun url-dav-directory-files (url &optional full match nosort files-only)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
786 "Return a list of names of files in DIRECTORY.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
787 There are three optional arguments:
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
788 If FULL is non-nil, return absolute file names. Otherwise return names
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
789 that are relative to the specified directory.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
790 If MATCH is non-nil, mention only file names that match the regexp MATCH.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
791 If NOSORT is non-nil, the list is not sorted--its order is unpredictable.
|
54828
|
792 NOSORT is useful if you plan to sort the result yourself."
|
54695
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
793 (let ((properties (url-dav-get-properties url '(DAV:resourcetype) 1))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
794 (child-url nil)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
795 (child-props nil)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
796 (files nil)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
797 (parsed-url (url-generic-parse-url url)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
798
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
799 (if (= (length properties) 1)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
800 (signal 'file-error (list "Opening directory" "not a directory" url)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
801
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
802 (while properties
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
803 (setq child-props (pop properties)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
804 child-url (pop child-props))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
805 (if (and (eq (plist-get child-props 'DAV:resourcetype) 'DAV:collection)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
806 files-only)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
807 ;; It is a directory, and we were told to return just files.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
808 nil
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
809
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
810 ;; Fully expand the URL and then rip off the beginning if we
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
811 ;; are not supposed to return fully-qualified names.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
812 (setq child-url (url-expand-file-name child-url parsed-url))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
813 (if (not full)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
814 (setq child-url (substring child-url (length url))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
815
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
816 ;; We don't want '/' as the last character in filenames...
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
817 (if (string-match "/$" child-url)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
818 (setq child-url (substring child-url 0 -1)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
819
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
820 ;; If we have a match criteria, then apply it.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
821 (if (or (and match (not (string-match match child-url)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
822 (string= child-url "")
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
823 (string= child-url url))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
824 nil
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
825 (push child-url files))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
826
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
827 (if nosort
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
828 files
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
829 (sort files 'string-lessp))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
830
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
831 ;;;###autoload
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
832 (defun url-dav-file-directory-p (url)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
833 "Return t if URL names an existing DAV collection."
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
834 (let ((properties (cdar (url-dav-get-properties url '(DAV:resourcetype)))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
835 (eq (plist-get properties 'DAV:resourcetype) 'DAV:collection)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
836
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
837 ;;;###autoload
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
838 (defun url-dav-make-directory (url &optional parents)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
839 "Create the directory DIR and any nonexistent parent dirs."
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
840 (declare (special url-http-response-status))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
841 (let* ((url-request-extra-headers nil)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
842 (url-request-method "MKCOL")
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
843 (url-request-data nil)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
844 (buffer (url-retrieve-synchronously url))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
845 (result nil))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
846 (when buffer
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
847 (unwind-protect
|
54929
|
848 (with-current-buffer buffer
|
54695
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
849 (case url-http-response-status
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
850 (201 ; Collection created in its entirety
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
851 (setq result t))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
852 (403 ; Forbidden
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
853 nil)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
854 (405 ; Method not allowed
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
855 nil)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
856 (409 ; Conflict
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
857 nil)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
858 (415 ; Unsupported media type (WTF?)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
859 nil)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
860 (507 ; Insufficient storage
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
861 nil)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
862 (otherwise
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
863 nil)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
864 (kill-buffer buffer)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
865 result))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
866
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
867 ;;;###autoload
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
868 (defun url-dav-rename-file (oldname newname &optional overwrite)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
869 (if (not (and (string-match url-handler-regexp oldname)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
870 (string-match url-handler-regexp newname)))
|
54795
|
871 (signal 'file-error
|
|
872 (list "Cannot rename between different URL backends"
|
|
873 oldname newname)))
|
54695
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
874
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
875 (let* ((headers nil)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
876 (props nil)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
877 (status nil)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
878 (directory-p (url-dav-file-directory-p oldname))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
879 (exists-p (url-http-file-exists-p newname)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
880
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
881 (if (and exists-p
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
882 (or
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
883 (null overwrite)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
884 (and (numberp overwrite)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
885 (not (yes-or-no-p
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
886 (format "File %s already exists; rename to it anyway? "
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
887 newname))))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
888 (signal 'file-already-exists (list "File already exists" newname)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
889
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
890 ;; Honor the overwrite flag...
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
891 (if overwrite (push '("Overwrite" . "T") headers))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
892
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
893 ;; Have to tell them where to copy it to!
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
894 (push (cons "Destination" newname) headers)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
895
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
896 ;; Always send a depth of -1 in case we are moving a collection.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
897 (setq props (url-dav-request oldname "MOVE" nil nil (if directory-p -1 0)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
898 headers))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
899
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
900 (mapc (lambda (result)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
901 (setq status (plist-get (cdr result) 'DAV:status))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
902
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
903 (if (not (url-dav-http-success-p status))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
904 (signal 'file-error (list "Renaming" oldname newname status))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
905 props)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
906 t))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
907
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
908 ;;;###autoload
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
909 (defun url-dav-file-name-all-completions (file url)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
910 "Return a list of all completions of file name FILE in directory DIRECTORY.
|
54828
|
911 These are all file names in directory DIRECTORY which begin with FILE."
|
54695
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
912 (url-dav-directory-files url nil (concat "^" file ".*")))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
913
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
914 ;;;###autoload
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
915 (defun url-dav-file-name-completion (file url)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
916 "Complete file name FILE in directory DIRECTORY.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
917 Returns the longest string
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
918 common to all file names in DIRECTORY that start with FILE.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
919 If there is only one and FILE matches it exactly, returns t.
|
54828
|
920 Returns nil if DIR contains no name starting with FILE."
|
54695
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
921 (let ((matches (url-dav-file-name-all-completions file url))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
922 (result nil))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
923 (cond
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
924 ((null matches)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
925 ;; No matches
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
926 nil)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
927 ((and (= (length matches) 1)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
928 (string= file (car matches)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
929 ;; Only one file and FILE matches it exactly...
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
930 t)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
931 (t
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
932 ;; Need to figure out the longest string that they have in commmon
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
933 (setq matches (sort matches (lambda (a b) (> (length a) (length b)))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
934 (let ((n (length file))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
935 (searching t)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
936 (regexp nil)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
937 (failed nil))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
938 (while (and searching
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
939 (< n (length (car matches))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
940 (setq regexp (concat "^" (substring (car matches) 0 (1+ n)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
941 failed nil)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
942 (dolist (potential matches)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
943 (if (not (string-match regexp potential))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
944 (setq failed t)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
945 (if failed
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
946 (setq searching nil)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
947 (incf n)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
948 (substring (car matches) 0 n))))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
949
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
950 (defun url-dav-register-handler (op)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
951 (put op 'url-file-handlers (intern-soft (format "url-dav-%s" op))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
952
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
953 (mapcar 'url-dav-register-handler
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
954 '(file-name-all-completions
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
955 file-name-completion
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
956 rename-file
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
957 make-directory
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
958 file-directory-p
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
959 directory-files
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
960 delete-file
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
961 delete-directory
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
962 file-attributes))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
963
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
964
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
965 ;;; Version Control backend cruft
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
966
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
967 ;(put 'vc-registered 'url-file-handlers 'url-dav-vc-registered)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
968
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
969 ;;;###autoload
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
970 (defun url-dav-vc-registered (url)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
971 (if (and (string-match "\\`https?" url)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
972 (plist-get (url-http-options url) 'dav))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
973 (progn
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
974 (vc-file-setprop url 'vc-backend 'dav)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
975 t)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
976
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
977
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
978 ;;; Miscellaneous stuff.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
979
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
980 (provide 'url-dav)
|
54699
|
981
|
54828
|
982 ;; arch-tag: 2b14b7b3-888a-49b8-a490-17276a40e78e
|
|
983 ;;; url-dav.el ends here
|