Monotone-Parent: f4d36201867e3633e57d99b75ebd377af0a7a8bb
Monotone-Revision: 20ad0039d697a608e811617e3f9802be732ccf03 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2010-04-23T19:26:05 Monotone-Branch: ca.inverse.sogo
This commit is contained in:
parent
392b300a02
commit
5b59219812
|
@ -1,5 +1,10 @@
|
||||||
2010-04-23 Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
2010-04-23 Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||||
|
|
||||||
|
* Main/SOGo+DAV.m (-davPrincipalPropertySearch:): restored method.
|
||||||
|
|
||||||
|
* SoObjects/SOGo/SOGoUserFolder.m (-collectionDavKey:matches:):
|
||||||
|
moved this tester method for REPORT queries from SOGo+DAV.m.
|
||||||
|
|
||||||
* Tools/SOGoSockDOperation.m (-_performSearch): we now support an
|
* Tools/SOGoSockDOperation.m (-_performSearch): we now support an
|
||||||
additional identifier in the object DN, for specifying specific
|
additional identifier in the object DN, for specifying specific
|
||||||
objects.
|
objects.
|
||||||
|
|
440
Main/SOGo+DAV.m
440
Main/SOGo+DAV.m
|
@ -238,165 +238,158 @@
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
// - (void) _fillMatches: (NSMutableDictionary *) matches
|
- (void) _fillMatches: (NSMutableDictionary *) matches
|
||||||
// fromElement: (NSObject <DOMElement> *) searchElement
|
fromElement: (NSObject <DOMElement> *) searchElement
|
||||||
// {
|
{
|
||||||
// NSObject <DOMNodeList> *list;
|
NSObject <DOMNodeList> *list;
|
||||||
// NSObject <DOMNode> *valueNode;
|
NSObject <DOMNode> *valueNode;
|
||||||
// NSArray *elements;
|
NSArray *elements;
|
||||||
// NSString *property, *match;
|
NSString *property, *match;
|
||||||
|
|
||||||
// list = [searchElement getElementsByTagName: @"prop"];
|
list = [searchElement getElementsByTagName: @"prop"];
|
||||||
// if ([list length])
|
if ([list length])
|
||||||
// {
|
{
|
||||||
// elements = [self domNode: [list objectAtIndex: 0]
|
elements = [self domNode: [list objectAtIndex: 0]
|
||||||
// getChildNodesByType: DOM_ELEMENT_NODE];
|
getChildNodesByType: DOM_ELEMENT_NODE];
|
||||||
// if ([elements count])
|
if ([elements count])
|
||||||
// {
|
{
|
||||||
// valueNode = [elements objectAtIndex: 0];
|
valueNode = [elements objectAtIndex: 0];
|
||||||
// property = [NSString stringWithFormat: @"{%@}%@",
|
property = [NSString stringWithFormat: @"{%@}%@",
|
||||||
// [valueNode namespaceURI],
|
[valueNode namespaceURI],
|
||||||
// [valueNode nodeName]];
|
[valueNode nodeName]];
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// list = [searchElement getElementsByTagName: @"match"];
|
list = [searchElement getElementsByTagName: @"match"];
|
||||||
// if ([list length])
|
if ([list length])
|
||||||
// {
|
{
|
||||||
// valueNode = [[list objectAtIndex: 0] firstChild];
|
valueNode = [[list objectAtIndex: 0] firstChild];
|
||||||
// match = [valueNode nodeValue];
|
match = [valueNode nodeValue];
|
||||||
// }
|
}
|
||||||
|
|
||||||
// [matches setObject: match forKey: property];
|
[matches setObject: match forKey: property];
|
||||||
// }
|
}
|
||||||
|
|
||||||
// - (void) _fillProperties: (NSMutableArray *) properties
|
- (void) _fillProperties: (NSMutableArray *) properties
|
||||||
// fromElement: (NSObject <DOMElement> *) propElement
|
fromElement: (NSObject <DOMElement> *) propElement
|
||||||
// {
|
{
|
||||||
// NSEnumerator *elements;
|
NSEnumerator *elements;
|
||||||
// NSObject <DOMElement> *propNode;
|
NSObject <DOMElement> *propNode;
|
||||||
// NSString *property;
|
NSString *property;
|
||||||
|
|
||||||
// elements = [[self domNode: propElement
|
elements = [[self domNode: propElement
|
||||||
// getChildNodesByType: DOM_ELEMENT_NODE]
|
getChildNodesByType: DOM_ELEMENT_NODE]
|
||||||
// objectEnumerator];
|
objectEnumerator];
|
||||||
// while ((propNode = [elements nextObject]))
|
while ((propNode = [elements nextObject]))
|
||||||
// {
|
{
|
||||||
// property = [NSString stringWithFormat: @"{%@}%@",
|
property = [NSString stringWithFormat: @"{%@}%@",
|
||||||
// [propNode namespaceURI],
|
[propNode namespaceURI],
|
||||||
// [propNode nodeName]];
|
[propNode nodeName]];
|
||||||
// [properties addObject: property];
|
[properties addObject: property];
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
// - (void) _fillPrincipalMatches: (NSMutableDictionary *) matches
|
- (void) _fillPrincipalMatches: (NSMutableDictionary *) matches
|
||||||
// andProperties: (NSMutableArray *) properties
|
andProperties: (NSMutableArray *) properties
|
||||||
// fromElement: (NSObject <DOMElement> *) documentElement
|
fromElement: (NSObject <DOMElement> *) documentElement
|
||||||
// {
|
{
|
||||||
// NSEnumerator *children;
|
NSEnumerator *children;
|
||||||
// NSObject <DOMElement> *currentElement;
|
NSObject <DOMElement> *currentElement;
|
||||||
// NSString *tag;
|
NSString *tag;
|
||||||
|
|
||||||
// children = [[self domNode: documentElement
|
children = [[self domNode: documentElement
|
||||||
// getChildNodesByType: DOM_ELEMENT_NODE]
|
getChildNodesByType: DOM_ELEMENT_NODE]
|
||||||
// objectEnumerator];
|
objectEnumerator];
|
||||||
// while ((currentElement = [children nextObject]))
|
while ((currentElement = [children nextObject]))
|
||||||
// {
|
{
|
||||||
// tag = [currentElement tagName];
|
tag = [currentElement tagName];
|
||||||
// if ([tag isEqualToString: @"property-search"])
|
if ([tag isEqualToString: @"property-search"])
|
||||||
// [self _fillMatches: matches fromElement: currentElement];
|
[self _fillMatches: matches fromElement: currentElement];
|
||||||
// else if ([tag isEqualToString: @"prop"])
|
else if ([tag isEqualToString: @"prop"])
|
||||||
// [self _fillProperties: properties fromElement: currentElement];
|
[self _fillProperties: properties fromElement: currentElement];
|
||||||
// else
|
else
|
||||||
// [self errorWithFormat: @"principal-property-search: unknown tag '%@'",
|
[self errorWithFormat: @"principal-property-search: unknown tag '%@'",
|
||||||
// tag];
|
tag];
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
#warning this is a bit ugly, as usual
|
#warning this is a bit ugly, as usual
|
||||||
// - (void) _fillCollections: (NSMutableArray *) collections
|
- (void) _fillCollections: (NSMutableArray *) collections
|
||||||
// withCalendarHomeSetMatching: (NSString *) value
|
withCalendarHomeSetMatching: (NSString *) value
|
||||||
// inContext: (WOContext *) localContext
|
inContext: (WOContext *) localContext
|
||||||
// {
|
{
|
||||||
// SOGoUserFolder *collection;
|
SOGoUserFolder *collection;
|
||||||
// NSRange substringRange;
|
NSRange substringRange;
|
||||||
|
|
||||||
// substringRange = [value rangeOfString: @"/SOGo/dav/"];
|
substringRange = [value rangeOfString: @"/SOGo/dav/"];
|
||||||
// value = [value substringFromIndex: NSMaxRange (substringRange)];
|
value = [value substringFromIndex: NSMaxRange (substringRange)];
|
||||||
// substringRange = [value rangeOfString: @"/Calendar"];
|
substringRange = [value rangeOfString: @"/Calendar"];
|
||||||
// value = [value substringToIndex: substringRange.location];
|
value = [value substringToIndex: substringRange.location];
|
||||||
// collection = [[SOGoUser userWithLogin: value]
|
collection = [[SOGoUser userWithLogin: value]
|
||||||
// homeFolderInContext: localContext];
|
homeFolderInContext: localContext];
|
||||||
// if (collection)
|
if (collection)
|
||||||
// [collections addObject: collection];
|
[collections addObject: collection];
|
||||||
// }
|
}
|
||||||
|
|
||||||
// - (NSMutableArray *) _firstPrincipalCollectionsWhere: (NSString *) key
|
- (NSMutableArray *) _firstPrincipalCollectionsWhere: (NSString *) key
|
||||||
// matches: (NSString *) value
|
matches: (NSString *) value
|
||||||
// inContext: (WOContext *) localContext
|
inContext: (WOContext *) localContext
|
||||||
// {
|
{
|
||||||
// NSMutableArray *collections;
|
NSMutableArray *collections;
|
||||||
|
|
||||||
// collections = [NSMutableArray array];
|
collections = [NSMutableArray array];
|
||||||
// if ([key
|
if ([key
|
||||||
// isEqualToString: @"{urn:ietf:params:xml:ns:caldav}calendar-home-set"])
|
isEqualToString: @"{urn:ietf:params:xml:ns:caldav}calendar-home-set"])
|
||||||
// [self _fillCollections: collections withCalendarHomeSetMatching: value
|
[self _fillCollections: collections withCalendarHomeSetMatching: value
|
||||||
// inContext: localContext];
|
inContext: localContext];
|
||||||
// else
|
else
|
||||||
// [self errorWithFormat: @"principal-property-search: unhandled key '%@'",
|
[self errorWithFormat: @"principal-property-search: unhandled key '%@'",
|
||||||
// key];
|
key];
|
||||||
|
|
||||||
// return collections;
|
return collections;
|
||||||
// }
|
}
|
||||||
|
|
||||||
// #warning unused stub
|
- (void) _principalCollections: (NSMutableArray **) baseCollections
|
||||||
// - (BOOL) collectionDavKey: (NSString *) key
|
where: (NSString *) key
|
||||||
// matches: (NSString *) value
|
matches: (NSString *) value
|
||||||
// {
|
inContext: (WOContext *) localContext
|
||||||
// return YES;
|
{
|
||||||
// }
|
SOGoUserFolder *currentCollection;
|
||||||
|
unsigned int count, max;
|
||||||
|
|
||||||
// - (void) _principalCollections: (NSMutableArray **) baseCollections
|
if (!*baseCollections)
|
||||||
// where: (NSString *) key
|
*baseCollections = [self _firstPrincipalCollectionsWhere: key
|
||||||
// matches: (NSString *) value
|
matches: value
|
||||||
// inContext: (WOContext *) localContext
|
inContext: localContext];
|
||||||
// {
|
else
|
||||||
// SOGoUserFolder *currentCollection;
|
{
|
||||||
// unsigned int count, max;
|
max = [*baseCollections count];
|
||||||
|
for (count = max; count > 0; count--)
|
||||||
|
{
|
||||||
|
currentCollection = [*baseCollections objectAtIndex: count - 1];
|
||||||
|
if (![currentCollection collectionDavKey: key matches: value])
|
||||||
|
[*baseCollections removeObjectAtIndex: count - 1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// if (!*baseCollections)
|
- (NSArray *) _principalCollectionsMatching: (NSDictionary *) matches
|
||||||
// *baseCollections = [self _firstPrincipalCollectionsWhere: key
|
inContext: (WOContext *) localContext
|
||||||
// matches: value
|
{
|
||||||
// inContext: localContext];
|
NSMutableArray *collections;
|
||||||
// else
|
NSEnumerator *allKeys;
|
||||||
// {
|
NSString *currentKey;
|
||||||
// max = [*baseCollections count];
|
|
||||||
// for (count = max; count > 0; count--)
|
|
||||||
// {
|
|
||||||
// currentCollection = [*baseCollections objectAtIndex: count - 1];
|
|
||||||
// if (![currentCollection collectionDavKey: key matches: value])
|
|
||||||
// [*baseCollections removeObjectAtIndex: count - 1];
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// - (NSArray *) _principalCollectionsMatching: (NSDictionary *) matches
|
collections = nil;
|
||||||
// inContext: (WOContext *) localContext
|
|
||||||
// {
|
|
||||||
// NSMutableArray *collections;
|
|
||||||
// NSEnumerator *allKeys;
|
|
||||||
// NSString *currentKey;
|
|
||||||
|
|
||||||
// collections = nil;
|
allKeys = [[matches allKeys] objectEnumerator];
|
||||||
|
while ((currentKey = [allKeys nextObject]))
|
||||||
|
[self _principalCollections: &collections
|
||||||
|
where: currentKey
|
||||||
|
matches: [matches objectForKey: currentKey]
|
||||||
|
inContext: localContext];
|
||||||
|
|
||||||
// allKeys = [[matches allKeys] objectEnumerator];
|
return collections;
|
||||||
// while ((currentKey = [allKeys nextObject]))
|
}
|
||||||
// [self _principalCollections: &collections
|
|
||||||
// where: currentKey
|
|
||||||
// matches: [matches objectForKey: currentKey]
|
|
||||||
// inContext: localContext];
|
|
||||||
|
|
||||||
// return collections;
|
|
||||||
// }
|
|
||||||
|
|
||||||
/* <D:principal-property-search xmlns:D="DAV:">
|
/* <D:principal-property-search xmlns:D="DAV:">
|
||||||
<D:property-search>
|
<D:property-search>
|
||||||
|
@ -420,96 +413,95 @@
|
||||||
</D:prop>
|
</D:prop>
|
||||||
</D:principal-property-search> */
|
</D:principal-property-search> */
|
||||||
|
|
||||||
// - (void) _appendProperties: (NSArray *) properties
|
- (void) _appendProperties: (NSArray *) properties
|
||||||
// ofCollection: (SOGoUserFolder *) collection
|
ofCollection: (SOGoUserFolder *) collection
|
||||||
// toResponses: (NSMutableArray *) responses
|
toResponses: (NSMutableArray *) responses
|
||||||
// {
|
{
|
||||||
// unsigned int count, max;
|
unsigned int count, max;
|
||||||
// SEL methodSel;
|
SEL methodSel;
|
||||||
// NSString *currentProperty;
|
NSString *currentProperty;
|
||||||
// id currentValue;
|
id currentValue;
|
||||||
// NSMutableArray *response, *props;
|
NSMutableArray *response, *props;
|
||||||
// NSDictionary *keyTuple;
|
NSDictionary *keyTuple;
|
||||||
|
|
||||||
// response = [NSMutableArray array];
|
response = [NSMutableArray array];
|
||||||
// [response addObject: davElementWithContent (@"href", XMLNS_WEBDAV,
|
[response addObject: davElementWithContent (@"href", XMLNS_WEBDAV,
|
||||||
// [collection davURLAsString])];
|
[collection davURLAsString])];
|
||||||
// props = [NSMutableArray array];
|
props = [NSMutableArray array];
|
||||||
// max = [properties count];
|
max = [properties count];
|
||||||
// for (count = 0; count < max; count++)
|
for (count = 0; count < max; count++)
|
||||||
// {
|
{
|
||||||
// currentProperty = [properties objectAtIndex: count];
|
currentProperty = [properties objectAtIndex: count];
|
||||||
// methodSel = SOGoSelectorForPropertyGetter (currentProperty);
|
methodSel = SOGoSelectorForPropertyGetter (currentProperty);
|
||||||
// if (methodSel && [collection respondsToSelector: methodSel])
|
if (methodSel && [collection respondsToSelector: methodSel])
|
||||||
// {
|
{
|
||||||
// currentValue = [collection performSelector: methodSel];
|
currentValue = [collection performSelector: methodSel];
|
||||||
// #warning evil eVIL EVIl!
|
#warning evil eVIL EVIl!
|
||||||
// if ([currentValue isKindOfClass: [NSArray class]])
|
if ([currentValue isKindOfClass: [NSArray class]])
|
||||||
// {
|
{
|
||||||
// currentValue = [currentValue objectAtIndex: 0];
|
currentValue = [currentValue objectAtIndex: 0];
|
||||||
// currentValue
|
currentValue
|
||||||
// = davElementWithContent ([currentValue objectAtIndex: 0],
|
= davElementWithContent ([currentValue objectAtIndex: 0],
|
||||||
// [currentValue objectAtIndex: 1],
|
[currentValue objectAtIndex: 1],
|
||||||
// [currentValue objectAtIndex: 3]);
|
[currentValue objectAtIndex: 3]);
|
||||||
// }
|
}
|
||||||
// keyTuple = [currentProperty asWebDAVTuple];
|
keyTuple = [currentProperty asWebDAVTuple];
|
||||||
// [props addObject: davElementWithContent ([keyTuple objectForKey: @"method"],
|
[props addObject: davElementWithContent ([keyTuple objectForKey: @"method"],
|
||||||
// [keyTuple objectForKey: @"ns"],
|
[keyTuple objectForKey: @"ns"],
|
||||||
// currentValue)];
|
currentValue)];
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// [response addObject: davElementWithContent (@"propstat", XMLNS_WEBDAV,
|
[response addObject: davElementWithContent (@"propstat", XMLNS_WEBDAV,
|
||||||
// davElementWithContent
|
davElementWithContent
|
||||||
// (@"prop", XMLNS_WEBDAV,
|
(@"prop", XMLNS_WEBDAV,
|
||||||
// props))];
|
props))];
|
||||||
// [responses addObject: davElementWithContent (@"response", XMLNS_WEBDAV,
|
[responses addObject: davElementWithContent (@"response", XMLNS_WEBDAV,
|
||||||
// response)];
|
response)];
|
||||||
// }
|
}
|
||||||
|
|
||||||
// - (void) _appendProperties: (NSArray *) properties
|
- (void) _appendProperties: (NSArray *) properties
|
||||||
// ofCollections: (NSArray *) collections
|
ofCollections: (NSArray *) collections
|
||||||
// toResponse: (WOResponse *) response
|
toResponse: (WOResponse *) response
|
||||||
// {
|
{
|
||||||
// NSDictionary *mStatus;
|
NSDictionary *mStatus;
|
||||||
// NSMutableArray *responses;
|
NSMutableArray *responses;
|
||||||
// unsigned int count, max;
|
unsigned int count, max;
|
||||||
|
|
||||||
// max = [collections count];
|
max = [collections count];
|
||||||
// responses = [NSMutableArray arrayWithCapacity: max];
|
responses = [NSMutableArray arrayWithCapacity: max];
|
||||||
// for (count = 0; count < max; count++)
|
for (count = 0; count < max; count++)
|
||||||
// [self _appendProperties: properties
|
[self _appendProperties: properties
|
||||||
// ofCollection: [collections objectAtIndex: count]
|
ofCollection: [collections objectAtIndex: count]
|
||||||
// toResponses: responses];
|
toResponses: responses];
|
||||||
// mStatus = davElementWithContent (@"multistatus", XMLNS_WEBDAV, responses);
|
mStatus = davElementWithContent (@"multistatus", XMLNS_WEBDAV, responses);
|
||||||
// [response appendContentString: [mStatus asWebDavStringWithNamespaces: nil]];
|
[response appendContentString: [mStatus asWebDavStringWithNamespaces: nil]];
|
||||||
// }
|
}
|
||||||
|
|
||||||
/* rfc3744, should be moved into SOGoUserFolder */
|
/* rfc3744, should be moved into SOGoUserFolder */
|
||||||
|
- (WOResponse *) davPrincipalPropertySearch: (WOContext *) localContext
|
||||||
|
{
|
||||||
|
NSObject <DOMDocument> *document;
|
||||||
|
NSObject <DOMElement> *documentElement;
|
||||||
|
NSArray *collections;
|
||||||
|
NSMutableDictionary *matches;
|
||||||
|
NSMutableArray *properties;
|
||||||
|
WOResponse *r;
|
||||||
|
|
||||||
// - (WOResponse *) davPrincipalPropertySearch: (WOContext *) localContext
|
document = [[localContext request] contentAsDOMDocument];
|
||||||
// {
|
documentElement = [document documentElement];
|
||||||
// NSObject <DOMDocument> *document;
|
|
||||||
// NSObject <DOMElement> *documentElement;
|
|
||||||
// NSArray *collections;
|
|
||||||
// NSMutableDictionary *matches;
|
|
||||||
// NSMutableArray *properties;
|
|
||||||
// WOResponse *r;
|
|
||||||
|
|
||||||
// document = [[localContext request] contentAsDOMDocument];
|
matches = [NSMutableDictionary dictionary];
|
||||||
// documentElement = [document documentElement];
|
properties = [NSMutableArray array];
|
||||||
|
[self _fillPrincipalMatches: matches andProperties: properties
|
||||||
|
fromElement: documentElement];
|
||||||
|
collections = [self _principalCollectionsMatching: matches
|
||||||
|
inContext: localContext];
|
||||||
|
r = [localContext response];
|
||||||
|
[r prepareDAVResponse];
|
||||||
|
[self _appendProperties: properties ofCollections: collections
|
||||||
|
toResponse: r];
|
||||||
|
|
||||||
// matches = [NSMutableDictionary dictionary];
|
return r;
|
||||||
// properties = [NSMutableArray array];
|
}
|
||||||
// [self _fillPrincipalMatches: matches andProperties: properties
|
|
||||||
// fromElement: documentElement];
|
|
||||||
// collections = [self _principalCollectionsMatching: matches
|
|
||||||
// inContext: localContext];
|
|
||||||
// r = [localContext response];
|
|
||||||
// [r prepareDAVResponse];
|
|
||||||
// [self _appendProperties: properties ofCollections: collections
|
|
||||||
// toResponse: r];
|
|
||||||
|
|
||||||
// return r;
|
|
||||||
// }
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -58,6 +58,9 @@
|
||||||
|
|
||||||
- (NSArray *) davPrincipalURL;
|
- (NSArray *) davPrincipalURL;
|
||||||
|
|
||||||
|
- (BOOL) collectionDavKey: (NSString *) key
|
||||||
|
matches: (NSString *) value;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
#endif /* __SOGo_SOGoUserFolder_H__ */
|
#endif /* __SOGo_SOGoUserFolder_H__ */
|
||||||
|
|
|
@ -634,4 +634,12 @@
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#warning unused stub
|
||||||
|
- (BOOL) collectionDavKey: (NSString *) key
|
||||||
|
matches: (NSString *) value
|
||||||
|
{
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@end /* SOGoUserFolder */
|
@end /* SOGoUserFolder */
|
||||||
|
|
Loading…
Reference in a new issue