2005-03-25 Helge Hess <helge.hess@opengroupware.org>
+ * v0.9.79
+
+ * SOGoMailFolder.m: ensure that mailbox exists if a DAV depth:0 query
+ is run on the folder (by selecting the mailbox)
+
+ * SOGoMailManager.m: added method to retrieve mailbox select info
+
* SOGoMailAccount.m: added ability to create mailboxes at the root
(account) level (v0.9.78)
Product.m \
\
SOGoMailManager.m \
+ SOGoMailboxInfo.m \
SOGoMailConnectionEntry.m \
\
SOGoMailBaseObject.m \
*/
@class NSData, NSArray, NSException;
+@class SOGoMailboxInfo;
@interface SOGoMailFolder : SOGoMailBaseObject
{
NSArray *filenames;
NSString *folderType;
+ SOGoMailboxInfo *selectInfo;
}
/* messages */
#include "SOGoMailObject.h"
#include "SOGoMailAccount.h"
#include "SOGoMailManager.h"
+#include "SOGoMailboxInfo.h"
#include "common.h"
@implementation SOGoMailFolder
- (void)dealloc {
+ [self->selectInfo release];
[self->filenames release];
[self->folderType release];
[super dealloc];
return self->filenames;
}
+/* mailbox raw ops */
+
+- (NSException *)primaryFetchMailboxInfo {
+ /* returns nil if fetch was successful */
+ id info;
+
+ if (self->selectInfo != nil)
+ return nil; /* select info exists, => no error */
+
+ info = [[self mailManager] infoForMailboxAtURL:[self imap4URL]
+ password:[self imap4Password]];
+ if ([info isKindOfClass:[NSException class]])
+ return info;
+
+ self->selectInfo = [info retain];
+ return nil; /* no error */
+}
+
/* messages */
- (NSArray *)fetchUIDsMatchingQualifier:(id)_q sortOrdering:(id)_so {
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]];
+}
+
/* folder type */
- (NSString *)outlookFolderClass {
return self->folderType;
}
-/* operations */
-
-- (NSException *)delete {
- /* Note: overrides SOGoObject -delete */
- return [[self mailManager] deleteMailboxAtURL:[self imap4URL]
- password:[self imap4Password]];
-}
-
@end /* SOGoMailFolder */
/* managing folders */
+- (id)infoForMailboxAtURL:(NSURL *)_url password:(NSString *)_pwd;
+
- (NSException *)createMailbox:(NSString *)_mailbox atURL:(NSURL *)_url
password:(NSString *)_pwd;
- (NSException *)deleteMailboxAtURL:(NSURL *)_url password:(NSString *)_pwd;
#include "SOGoMailManager.h"
#include "SOGoMailConnectionEntry.h"
+#include "SOGoMailboxInfo.h"
#include "common.h"
/*
isEqualToString:@"Permission denied"];
}
+- (id)infoForMailboxAtURL:(NSURL *)_url password:(NSString *)_pwd {
+ SOGoMailConnectionEntry *entry;
+ SOGoMailboxInfo *info;
+ NSString *folderName;
+ id result;
+
+ if ((entry = [self entryForURL:_url password:_pwd]) == nil) {
+ // TODO: better to use an auth exception?
+ return [NSException exceptionWithHTTPStatus:404 /* Not Found */
+ reason:@"did not find IMAP4 folder (no entry)"];
+ }
+
+ folderName = [self imap4FolderNameForURL:_url];
+ result = [[entry client] select:folderName];
+ if (![[result valueForKey:@"result"] boolValue]) {
+ return [NSException exceptionWithHTTPStatus:404 /* Not Found */
+ reason:@"did not find IMAP4 folder (select failed)"];
+ }
+
+ info = [[SOGoMailboxInfo alloc] initWithURL:_url folderName:folderName
+ selectDictionary:result];
+ return [info autorelease];
+}
+
- (NSException *)createMailbox:(NSString *)_mailbox atURL:(NSURL *)_url
password:(NSString *)_pwd
{
/* check connection cache */
if ((entry = [self entryForURL:_url password:_pwd]) == nil) {
+ // TODO: better to use an auth exception?
return [NSException exceptionWithHTTPStatus:404 /* Not Found */
- reason:@"did not find IMAP4 folder"];
+ reason:@"did not find IMAP4 folder (no entry)"];
}
/* construct path */
/* check connection cache */
if ((entry = [self entryForURL:_url password:_pwd]) == nil) {
+ // TODO: better to use an auth exception?
return [NSException exceptionWithHTTPStatus:404 /* Not Found */
- reason:@"did not find IMAP4 folder"];
+ reason:@"did not find IMAP4 folder (no entry)"];
}
/* delete */
--- /dev/null
+/*
+ Copyright (C) 2005 SKYRIX Software AG
+
+ This file is part of OpenGroupware.org.
+
+ OGo is free software; you can redistribute it and/or modify it under
+ the terms of the GNU Lesser General Public License as published by the
+ Free Software Foundation; either version 2, or (at your option) any
+ later version.
+
+ OGo is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with OGo; see the file COPYING. If not, write to the
+ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA.
+*/
+
+#ifndef __Mailer_SOGoMailboxInfo_H__
+#define __Mailer_SOGoMailboxInfo_H__
+
+#import <Foundation/NSObject.h>
+
+/*
+ SOGoMailboxInfo
+
+ Represents the info returned by an IMAP4 select. Use SOGoMailManager to
+ retrieve the data.
+*/
+
+@class NSString, NSDate, NSArray, NSURL, NSDictionary;
+
+@interface SOGoMailboxInfo : NSObject
+{
+ NSDate *timestamp;
+ NSURL *url;
+ NSString *name;
+ NSArray *allowedFlags;
+ NSString *access;
+ unsigned int recent;
+}
+
+- (id)initWithURL:(NSURL *)_url folderName:(NSString *)_name
+ selectDictionary:(NSDictionary *)_dict;
+
+/* accessors */
+
+- (NSDate *)timestamp;
+- (NSURL *)url;
+- (NSString *)name;
+- (NSArray *)allowedFlags;
+- (NSString *)access;
+- (unsigned int)recent;
+
+@end
+
+#endif /* __Mailer_SOGoMailboxInfo_H__ */
--- /dev/null
+/*
+ Copyright (C) 2005 SKYRIX Software AG
+
+ This file is part of OpenGroupware.org.
+
+ OGo is free software; you can redistribute it and/or modify it under
+ the terms of the GNU Lesser General Public License as published by the
+ Free Software Foundation; either version 2, or (at your option) any
+ later version.
+
+ OGo is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with OGo; see the file COPYING. If not, write to the
+ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA.
+*/
+
+#include "SOGoMailboxInfo.h"
+#include "common.h"
+
+@implementation SOGoMailboxInfo
+
+- (id)initWithURL:(NSURL *)_url folderName:(NSString *)_name
+ selectDictionary:(NSDictionary *)_dict
+{
+ if (_dict == nil || (_url == nil && _name == nil)) {
+ [self release];
+ return nil;
+ }
+
+ if ((self = [super init])) {
+ self->timestamp = [[NSDate alloc] init];
+ self->url = [_url copy];
+ self->name = [_name copy];
+ self->allowedFlags = [[_dict objectForKey:@"flags"] copy];
+ self->access = [[_dict objectForKey:@"access"] copy];
+ self->recent = [[_dict objectForKey:@"recent"] unsignedIntValue];
+ }
+ return self;
+}
+- (id)init {
+ return [self initWithURL:nil folderName: nil selectDictionary:nil];
+}
+
+- (void)dealloc {
+ [self->timestamp release];
+ [self->url release];
+ [self->name release];
+ [self->allowedFlags release];
+ [self->access release];
+ [super dealloc];
+}
+
+/* accessors */
+
+- (NSDate *)timestamp {
+ return self->timestamp;
+}
+- (NSURL *)url {
+ return self->url;
+}
+- (NSString *)name {
+ return self->name;
+}
+- (NSArray *)allowedFlags {
+ return self->allowedFlags;
+}
+- (NSString *)access {
+ return self->access;
+}
+- (unsigned int)recent {
+ return self->recent;
+}
+
+/* description */
+
+- (void)appendAttributesToDescription:(NSMutableString *)_ms {
+ if (self->name) [_ms appendFormat:@" name=%@", self->name];
+ if (self->access) [_ms appendFormat:@" access=%@", self->access];
+
+ if (self->recent != 0) [_ms appendFormat:@" recent=%d", self->recent];
+
+ [_ms appendFormat:@" flags=%@",
+ [[self allowedFlags] componentsJoinedByString:@","]];
+}
+
+- (NSString *)description {
+ NSMutableString *ms;
+
+ ms = [NSMutableString stringWithCapacity:64];
+ [ms appendFormat:@"<0x%08X[%@]:", self, NSStringFromClass([self class])];
+ [self appendAttributesToDescription:ms];
+ [ms appendString:@">"];
+ return ms;
+}
+
+@end /* SOGoMailboxInfo */
# Version file
-SUBMINOR_VERSION:=78
+SUBMINOR_VERSION:=79
# v0.9.69 requires libNGMime v4.5.210
# v0.9.55 requires libNGExtensions v4.5.136
#include <NGObjWeb/NGObjWeb.h>
#include <NGObjWeb/SoObjects.h>
+#include <NGObjWeb/SoObject+SoDAV.h>
+
#include <NGImap4/NGImap4Client.h>