- (id)lookupImap4Folder:(NSString *)_key inContext:(id)_ctx {
// TODO: we might want to check for existence prior controller creation
+ NSURL *sf;
+
+ /* check whether URL exists */
+
+ sf = [self imap4URL];
+ sf = [NSURL URLWithString:[[sf path] stringByAppendingPathComponent:_key]
+ relativeToURL:sf];
+
+ if (![[self mailManager] doesMailboxExistAtURL:sf
+ password:[self imap4Password]]) {
+ /*
+ We may not return 404, confuses path traversal - but we still do in the
+ calling method. Probably the traversal process should be fixed to
+ support 404 exceptions (as stop traversal _and_ acquisition).
+ */
+ return nil;
+ }
+
+ /* create object */
+
return [[[SOGoMailFolder alloc] initWithName:_key
inContainer:self] autorelease];
}
inContainer:self] autorelease];
}
-- (id)lookupName:(NSString *)_key inContext:(id)_ctx acquire:(BOOL)_flag {
+- (id)lookupName:(NSString *)_key inContext:(id)_ctx acquire:(BOOL)_acquire {
id obj;
if ([self isMessageKey:_key inContext:_ctx])
return obj;
/* return 404 to stop acquisition */
- return [NSException exceptionWithHTTPStatus:404 /* Not Found */];
+ return _acquire
+ ? [NSException exceptionWithHTTPStatus:404 /* Not Found */]
+ : nil; /* hack to work with WebDAV move */
}
/* WebDAV */
password:[self imap4Password]];
}
-- (id)davQueryOnSelf:(EOFetchSpecification *)_fs inContext:(id)_ctx {
- NSException *error;
-
- /* ensure that the mailbox exists */
- if ((error = [self primaryFetchMailboxInfo]) != nil)
- return error;
-
- return [super davQueryOnSelf:_fs inContext:_ctx];
-}
-
- (NSException *)delete {
/* Note: overrides SOGoObject -delete */
return [[self mailManager] deleteMailboxAtURL:[self imap4URL]
password:[self imap4Password]];
}
+- (NSException *)davMoveToTargetObject:(id)_target newName:(NSString *)_name
+ inContext:(id)_ctx
+{
+ [self logWithFormat:@"TODO: should move collection as '%@' to: %@",
+ _name, _target];
+ return [NSException exceptionWithHTTPStatus:501 /* Not Implemented */
+ reason:@"not implemented"];
+}
+- (NSException *)davCopyToTargetObject:(id)_target newName:(NSString *)_name
+ inContext:(id)_ctx
+{
+ [self logWithFormat:@"TODO: should copy collection as '%@' to: %@",
+ _name, _target];
+ return [NSException exceptionWithHTTPStatus:501 /* Not Implemented */
+ reason:@"not implemented"];
+}
+
/* folder type */
- (NSString *)outlookFolderClass {
isEqualToString:@"Permission denied"];
}
+- (BOOL)doesMailboxExistAtURL:(NSURL *)_url password:(NSString *)_pwd {
+ SOGoMailConnectionEntry *entry;
+ NSString *folderName;
+ id result;
+
+ if ((entry = [self entryForURL:_url password:_pwd]) == nil)
+ return NO;
+
+ /* check in hierarchy cache */
+
+ if ((result = [entry cachedHierarchyResults]) != nil) {
+ result = [result objectForKey:@"list"];
+ return ([result objectForKey:[_url path]] != nil) ? YES : NO;
+ }
+
+ /* check using IMAP4 select */
+ // TODO: we should probably just fetch the whole hierarchy?
+
+ folderName = [self imap4FolderNameForURL:_url];
+ result = [[entry client] select:folderName];
+ if (![[result valueForKey:@"result"] boolValue])
+ return NO;
+
+ return YES;
+}
+
- (id)infoForMailboxAtURL:(NSURL *)_url password:(NSString *)_pwd {
SOGoMailConnectionEntry *entry;
SOGoMailboxInfo *info;
return [self davCreationDate];
}
+- (NSException *)davMoveToTargetObject:(id)_target newName:(NSString *)_name
+ inContext:(id)_ctx
+{
+ [self logWithFormat:@"TODO: should move mail as '%@' to: %@",
+ _name, _target];
+ return [NSException exceptionWithHTTPStatus:501 /* Not Implemented */
+ reason:@"not implemented"];
+}
+- (NSException *)davCopyToTargetObject:(id)_target newName:(NSString *)_name
+ inContext:(id)_ctx
+{
+ [self logWithFormat:@"TODO: should copy mail as '%@' to: %@",
+ _name, _target];
+ return [NSException exceptionWithHTTPStatus:501 /* Not Implemented */
+ reason:@"not implemented"];
+}
+
/* actions */
- (id)GETAction:(WOContext *)_ctx {