From b451ecf1bfe5cf4f0e261ab48ac7aa9e0d8c56db Mon Sep 17 00:00:00 2001 From: helge Date: Fri, 8 Oct 2004 14:40:26 +0000 Subject: [PATCH] minor enh for default file extensions git-svn-id: http://svn.opengroupware.org/SOGo/trunk@373 d1b88da0-ebda-0310-925b-ed51d893ca5b --- SOGo/SoObjects/SOGo/ChangeLog | 2 ++ SOGo/SoObjects/SOGo/SOGoFolder.m | 37 +++++++++++++++++++++++++++++++- SOGo/SoObjects/SOGo/Version | 2 +- 3 files changed, 39 insertions(+), 2 deletions(-) diff --git a/SOGo/SoObjects/SOGo/ChangeLog b/SOGo/SoObjects/SOGo/ChangeLog index eb38acfd..d8905758 100644 --- a/SOGo/SoObjects/SOGo/ChangeLog +++ b/SOGo/SoObjects/SOGo/ChangeLog @@ -1,5 +1,7 @@ 2004-10-08 Helge Hess + * SOGoFolder.m: added facility to define default extensions (v0.9.24) + * SOGoObject.m: fixed not implemented return status (501, not 502) (v0.9.23) diff --git a/SOGo/SoObjects/SOGo/SOGoFolder.m b/SOGo/SoObjects/SOGo/SOGoFolder.m index ff770364..4eee453b 100644 --- a/SOGo/SoObjects/SOGo/SOGoFolder.m +++ b/SOGo/SoObjects/SOGo/SOGoFolder.m @@ -82,9 +82,44 @@ /* reflection */ +- (NSString *)defaultFilenameExtension { + /* + Override to add an extension to a filename + + Note: be careful with that, needs to be consistent with object lookup! + */ + return nil; +} + - (NSArray *)toOneRelationshipKeys { /* toOneRelationshipKeys are the 'files' contained in a folder */ - return [self fetchContentObjectNames]; + NSMutableArray *ma; + NSArray *names; + NSString *ext; + unsigned i, count; + + if ((names = [self fetchContentObjectNames]) == nil) + return names; + + if ((count = [names count]) == 0) + return names; + + if ((ext = [self defaultFilenameExtension]) == nil) + return names; + + ma = [NSMutableArray arrayWithCapacity:count]; + for (i = 0; i < count; i++) { + NSRange r; + NSString *name; + + name = [names objectAtIndex:i]; + r = [name rangeOfString:@"."]; + if (r.length == 0) + name = [[name stringByAppendingString:@"."] stringByAppendingString:ext]; + + [ma addObject:name]; + } + return ma; } /* WebDAV */ diff --git a/SOGo/SoObjects/SOGo/Version b/SOGo/SoObjects/SOGo/Version index 134290ff..b110bb31 100644 --- a/SOGo/SoObjects/SOGo/Version +++ b/SOGo/SoObjects/SOGo/Version @@ -1,3 +1,3 @@ # $Id: Version 170 2004-08-11 10:45:40Z helge $ -SUBMINOR_VERSION:=23 +SUBMINOR_VERSION:=24 -- 2.39.5