26 var resourceType = [properties objectForKey:@"resourcetype"];
30 [aURL setResourceValue:YES forKey:CPURLIsDirectoryKey];
31 [aURL setResourceValue:NO forKey:CPURLIsRegularFileKey];
35 [aURL setResourceValue:NO forKey:CPURLIsDirectoryKey];
36 [aURL setResourceValue:YES forKey:CPURLIsRegularFileKey];
39 var displayName = [properties objectForKey:@"displayname"];
41 if (displayName !== nil)
43 [aURL setResourceValue:displayName forKey:CPURLNameKey];
44 [aURL setResourceValue:displayName forKey:CPURLLocalizedNameKey];
61 _blocksForConnections = @{};
66 - (CPArray)contentsOfDirectoryAtURL:(
CPURL)aURL includingPropertiesForKeys:(CPArray)keys options:(CPDirectoryEnumerationOptions)aMask block:(Function)aBlock
74 var makeContents =
function(aURL, response)
78 URLStrings = [response keyEnumerator];
80 while ((URLString = [URLStrings nextObject]) !== nil)
83 properties = [response objectForKey:URLString];
86 if (![[URL absoluteString]
isEqual:[aURL absoluteString]])
98 return makeContents(aURL, [
self PROPFIND:aURL properties:properties depth:1 block:nil]);
102 aBlock(aURL, makeContents(aURL, response));
110 [request setHTTPMethod:@"PROPFIND"];
111 [request setValue:aDepth forHTTPHeaderField:@"Depth"];
113 var HTTPBody = ["<?xml version=\"1.0\"?><a:propfind xmlns:a=\"DAV:\">"],
115 count = properties.length;
117 for (; index < count; ++index)
118 HTTPBody.push(
"<a:prop><a:", properties[index],
"/></a:prop>");
120 HTTPBody.push(
"</a:propfind>");
122 [request setHTTPBody:HTTPBody.join("")];
131 [_blocksForConnections setObject:aBlock forKey:[connection UID]];
137 var block = [_blocksForConnections objectForKey:[aURLConnection
UID]];
175 if (typeof window[
"ActiveXObject"] !==
"undefined")
177 var XMLDocument =
new ActiveXObject(
"Microsoft.XMLDOM");
179 XMLDocument.async =
false;
180 XMLDocument.loadXML(anXMLString);
185 return new DOMParser().parseFromString(anXMLString,
"text/xml");
191 responses = XMLDocument.getElementsByTagNameNS(
"*",
"response"),
193 responseCount = responses.length,
194 propertiesForURLs = @{};
196 for (; responseIndex < responseCount; ++responseIndex)
198 var response = responses[responseIndex],
199 elements = response.getElementsByTagNameNS(
"*",
"prop").item(0).childNodes,
201 count = elements.length,
204 for (; index < count; ++index)
206 var element = elements[index];
208 if (element.nodeType === 8 || element.nodeType === 3)
211 var nodeName = element.nodeName,
212 colonIndex = nodeName.lastIndexOf(
':');
215 nodeName = nodeName.substr(colonIndex + 1);
217 if (nodeName ===
@"resourcetype")
218 [properties setObject:element.firstChild ? CPWebDAVManagerCollectionResourceType : CPWebDAVManagerNonCollectionResourceType forKey:nodeName];
223 var href = response.getElementsByTagNameNS(
"*",
"href").item(0);
225 [propertiesForURLs setObject:properties forKey:href.firstChild.nodeValue];
228 return propertiesForURLs;
var WebDAVPropertiesForURLKeys
CPDictionary PROPFIND:properties:depth:block:(CPURL aURL, [properties] CPDictionary properties, [depth] CPString aDepth, [block] Function aBlock)
Provides loading of a URL request.
var setURLResourceValuesForKeysFromProperties
A mutable key-value pair collection.
id requestWithURL:(CPURL aURL)
An immutable string (collection of characters).
CPWebDAVManagerNonCollectionResourceType
CPURLConnection connectionWithRequest:delegate:(CPURLRequest aRequest, [delegate] id aDelegate)
var XMLDocumentFromString
Contains data obtained during a request made with CPURLConnection.
id URLWithString:(CPString URLString)
var parsePROPFINDResponse
void setObject:forKey:(id anObject, [forKey] id aKey)
CPWebDAVManagerCollectionResourceType