/*
- Copyright (C) 2002-2005 SKYRIX Software AG
+ Copyright (C) 2002-2006 SKYRIX Software AG
+ Copyright (C) 2006 Helge Hess
This file is part of SOPE.
[self warnWithFormat:@"'depth' locking not supported yet (depth=%@)!",
lockDepth];
}
- if (ifValue) {
+ if (ifValue != nil) {
[self warnWithFormat:@"'if' locking not supported yet, if: '%@'", ifValue];
}
- // need to parse lockinfo
+ /*
+ TODO: parse lockinfo:
+ <?xml version="1.0" encoding="UTF-8" ?>
+ <lockinfo xmlns="DAV:">
+ <locktype><write/></locktype>
+ <lockscope><exclusive/></lockscope>
+ <owner>helge</owner>
+ </lockinfo>
+
+ Currently we assume exclusive/write ... (also see SoWebDAVRenderer)
+ */
+
+ /* Sample timeout: Second-180 */
token = [lockManager lockURI:[rq uri]
timeout:[rq headerForKey:@"timeout"]
- scope:@"exclusive"
- type:@"write"
- owner:nil];
+ scope:@"exclusive" // TODO
+ type:@"write" // TODO
+ owner:nil]; // TODO
if (token == nil) {
/* already locked */
return [self httpException:423 /* locked */
}
- (BOOL)renderLockToken:(id)_object inContext:(WOContext *)_ctx {
- /* TODO: this is a fake ! */
+ // TODO: this is fake for most parts! The object needs to be some real
+ // object describing the lock, not just the token
WOResponse *r;
+ id tmp;
if (_object == nil) return NO;
[r appendContentString:@"<D:activelock>"];
if (formatOutput) [r appendContentCharacter:'\n'];
+ // TODO: we assume a write token and exclusive access, also check the
+ // SoObjectWebDAVDispatcher
+
+ [r appendContentString:@"<D:locktype><D:write/></D:locktype>"];
+ if (formatOutput) [r appendContentCharacter:'\n'];
+
+ [r appendContentString:@"<D:lockscope><D:exclusive/></D:lockscope>"];
+ if (formatOutput) [r appendContentCharacter:'\n'];
+
+ /* write the depth */
+ // TODO: we just give back the depth of the request ...
+
+ if ([(tmp = [[_ctx request] headerForKey:@"depth"]) isNotEmpty]) {
+ [r appendContentString:@"<D:depth>"];
+ [r appendContentString:[tmp stringValue]];
+ [r appendContentString:@"</D:depth>"];
+ if (formatOutput) [r appendContentCharacter:'\n'];
+ }
+
+ // TODO: owner, eg <D:owner><D:href>...</D:href></D:owner>
+
+ /* write the timeout */
+ // TODO: we just give back the timeout of the request ...
+
+ if ([(tmp = [[_ctx request] headerForKey:@"timeout"]) isNotEmpty]) {
+ /* eg <D:timeout>Second-604800</D:timeout> */
+ [r appendContentString:@"<D:timeout>"];
+ [r appendContentString:[tmp stringValue]];
+ [r appendContentString:@"</D:timeout>"];
+ if (formatOutput) [r appendContentCharacter:'\n'];
+ }
+
/* this is the href of the lock, not of the locked resource */
+
[r appendContentString:@"<D:locktoken><D:href>"];
[r appendContentString:[_object stringValue]];
[r appendContentString:@"</D:href></D:locktoken>"];
if (formatOutput) [r appendContentCharacter:'\n'];
- // TODO: locktype, eg <D:locktype><D:write/></D:locktype>
- // TODO: lockscope, eg <D:lockscope><D:exclusive/></D:lockscope>
- // TODO: depth, eg <D:depth>Infinitiy</D:depth>
- // TODO: owner, eg <D:owner><D:href>...</D:href></D:owner>
- // TODO: timeout, eg <D:timeout>Second-604800</D:timeout>
-
[r appendContentString:@"</D:activelock>"];
[r appendContentString:@"</D:lockdiscovery>"];
[r appendContentString:@"</D:prop>"];