From: helge Date: Sun, 3 Oct 2004 20:36:21 +0000 (+0000) Subject: started body part support X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fb585cc13e24a8faeca1d4ee7117ab7f71bdf149;p=scalable-opengroupware.org started body part support git-svn-id: http://svn.opengroupware.org/SOGo/trunk@349 d1b88da0-ebda-0310-925b-ed51d893ca5b --- diff --git a/SOGo/SoObjects/Mailer/ChangeLog b/SOGo/SoObjects/Mailer/ChangeLog index 922d85a9..9be6b5f4 100644 --- a/SOGo/SoObjects/Mailer/ChangeLog +++ b/SOGo/SoObjects/Mailer/ChangeLog @@ -1,9 +1,17 @@ 2004-10-03 Helge Hess + * v0.9.21 + + * SOGoMailObject.m: lookup 'number' names as part child objects + + * added SOGoMailBodyPart as a child object of SOGoMailObject + + * SOGoMailAccounts.m: changed link generation for active folder + * v0.9.20 - + * SOGoMailObject.m: added method to fetch parts - + * SOGoMailManager.m: properly select folder prior fetch, added method to fetch parts of a single (message) URL diff --git a/SOGo/SoObjects/Mailer/GNUmakefile b/SOGo/SoObjects/Mailer/GNUmakefile index f033de56..a372e001 100644 --- a/SOGo/SoObjects/Mailer/GNUmakefile +++ b/SOGo/SoObjects/Mailer/GNUmakefile @@ -16,6 +16,7 @@ Mailer_OBJC_FILES += \ SOGoMailAccount.m \ SOGoMailFolder.m \ SOGoMailObject.m \ + SOGoMailBodyPart.m \ Mailer_RESOURCE_FILES += \ Version \ diff --git a/SOGo/SoObjects/Mailer/SOGoMailAccounts.m b/SOGo/SoObjects/Mailer/SOGoMailAccounts.m index aca3fc7f..cf6e2b49 100644 --- a/SOGo/SoObjects/Mailer/SOGoMailAccounts.m +++ b/SOGo/SoObjects/Mailer/SOGoMailAccounts.m @@ -125,7 +125,8 @@ [md setObject:[NSNumber numberWithBool:YES] forKey:@"isPathNode"]; [md setObject:[self davDisplayName] forKey:@"title"]; [md setObject:[self nameInContainer] forKey:@"name"]; - [md setObject:@"." forKey:@"link"]; + [md setObject:[@"../" stringByAppendingString:[self nameInContainer]] + forKey:@"link"]; if ([blocks count] > 0) [md setObject:blocks forKey:@"children"]; return md; diff --git a/SOGo/SoObjects/Mailer/SOGoMailBodyPart.h b/SOGo/SoObjects/Mailer/SOGoMailBodyPart.h new file mode 100644 index 00000000..cd2eb996 --- /dev/null +++ b/SOGo/SoObjects/Mailer/SOGoMailBodyPart.h @@ -0,0 +1,42 @@ +/* + Copyright (C) 2004 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_SOGoMailBodyPart_H__ +#define __Mailer_SOGoMailBodyPart_H__ + +#include + +/* + SOGoMailBodyPart + Parent object: SOGoMailObject or SOGoMailBodyPart + Child objects: SOGoMailBodyPart's + + Represents a MIME part of a mail as retrieved using IMAP4 body structure + commands in NGImap4. +*/ + +@interface SOGoMailBodyPart : SOGoMailBaseObject +{ +} + +@end + +#endif /* __Mailer_SOGoMailBodyPart_H__ */ diff --git a/SOGo/SoObjects/Mailer/SOGoMailBodyPart.m b/SOGo/SoObjects/Mailer/SOGoMailBodyPart.m new file mode 100644 index 00000000..8a66834a --- /dev/null +++ b/SOGo/SoObjects/Mailer/SOGoMailBodyPart.m @@ -0,0 +1,62 @@ +/* + Copyright (C) 2004 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 "SOGoMailBodyPart.h" +#include "SOGoMailObject.h" +#include "common.h" + +@implementation SOGoMailBodyPart + +- (void)dealloc { + [super dealloc]; +} + +/* hierarchy */ + +- (SOGoMailObject *)mailObject { + return [[self container] mailObject]; +} + +/* name lookup */ + +- (id)lookupImap4BodyPartKey:(NSString *)_key inContext:(id)_ctx { + // TODO: we might want to check for existence prior controller creation + return [[[SOGoMailBodyPart alloc] initWithName:_key + inContainer:self] autorelease]; +} + +- (id)lookupName:(NSString *)_key inContext:(id)_ctx acquire:(BOOL)_flag { + id obj; + + /* first check attributes directly bound to the application */ + if ((obj = [super lookupName:_key inContext:_ctx acquire:NO]) != nil) + return obj; + + /* lookup body part */ + + if ((obj = [self lookupImap4BodyPartKey:_key inContext:_ctx]) != nil) + return obj; + + /* return 404 to stop acquisition */ + return [NSException exceptionWithHTTPStatus:404 /* Not Found */]; +} + +@end /* SOGoMailBodyPart */ diff --git a/SOGo/SoObjects/Mailer/SOGoMailObject.h b/SOGo/SoObjects/Mailer/SOGoMailObject.h index 9cb4ab1a..ae45d58f 100644 --- a/SOGo/SoObjects/Mailer/SOGoMailObject.h +++ b/SOGo/SoObjects/Mailer/SOGoMailObject.h @@ -28,9 +28,14 @@ /* SOGoMailObject Parent object: the SOGoMailFolder - Child objects: none (maybe SOGoMailAttachments?) + Child objects: SOGoMailBodyPart's - Represents a single mail as retrieved using NGImap4. + Represents a single mail as retrieved using NGImap4. Since IMAP4 can parse + MIME structures on the server side, which we map into child objects of the + message. + The child objects are accessed using integer IDs, eg: + /INBOX/12345/1/2/3 + would address the MIME part 1.2.3 of the mail 12345 in the folder INBOX. */ @interface SOGoMailObject : SOGoMailBaseObject @@ -39,7 +44,7 @@ /* message */ -- (id)fetchParts:(NSArray *)_parts; +- (id)fetchParts:(NSArray *)_parts; /* Note: 'parts' are fetch keys here */ @end diff --git a/SOGo/SoObjects/Mailer/SOGoMailObject.m b/SOGo/SoObjects/Mailer/SOGoMailObject.m index 603ea64a..072fdb62 100644 --- a/SOGo/SoObjects/Mailer/SOGoMailObject.m +++ b/SOGo/SoObjects/Mailer/SOGoMailObject.m @@ -22,6 +22,7 @@ #include "SOGoMailObject.h" #include "SOGoMailManager.h" +#include "SOGoMailBodyPart.h" #include "common.h" @implementation SOGoMailObject @@ -32,6 +33,12 @@ return [self nameInContainer]; } +/* hierarchy */ + +- (SOGoMailObject *)mailObject { + return self; +} + /* message */ - (id)fetchParts:(NSArray *)_parts { @@ -39,4 +46,43 @@ password:[self imap4Password]]; } +/* name lookup */ + +- (BOOL)isBodyPartKey:(NSString *)_key inContext:(id)_ctx { + /* + Every key starting with a digit is consider an IMAP4 mime part key. + */ + if ([_key length] == 0) + return NO; + + if (isdigit([_key characterAtIndex:0])) + return YES; + + return NO; +} + +- (id)lookupImap4BodyPartKey:(NSString *)_key inContext:(id)_ctx { + // TODO: we might want to check for existence prior controller creation + return [[[SOGoMailBodyPart alloc] initWithName:_key + inContainer:self] autorelease]; +} + +- (id)lookupName:(NSString *)_key inContext:(id)_ctx acquire:(BOOL)_flag { + id obj; + + /* first check attributes directly bound to the application */ + if ((obj = [super lookupName:_key inContext:_ctx acquire:NO]) != nil) + return obj; + + /* lookup body part */ + + if ([self isBodyPartKey:_key inContext:_ctx]) { + if ((obj = [self lookupImap4BodyPartKey:_key inContext:_ctx]) != nil) + return obj; + } + + /* return 404 to stop acquisition */ + return [NSException exceptionWithHTTPStatus:404 /* Not Found */]; +} + @end /* SOGoMailObject */ diff --git a/SOGo/SoObjects/Mailer/Version b/SOGo/SoObjects/Mailer/Version index 7cb001ac..49f242e5 100644 --- a/SOGo/SoObjects/Mailer/Version +++ b/SOGo/SoObjects/Mailer/Version @@ -1,3 +1,3 @@ # $Id$ -SUBMINOR_VERSION:=20 +SUBMINOR_VERSION:=21 diff --git a/SOGo/SoObjects/Mailer/product.plist b/SOGo/SoObjects/Mailer/product.plist index 539c0e8c..2060eae8 100644 --- a/SOGo/SoObjects/Mailer/product.plist +++ b/SOGo/SoObjects/Mailer/product.plist @@ -27,5 +27,9 @@ SOGoMailObject = { superclass = "SOGoMailBaseObject"; }; + + SOGoMailBodyPart = { + superclass = "SOGoMailBaseObject"; + }; }; }