From 008fb7fbbc46b784ea1c61a02e94c831e7caddc1 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Thu, 14 Dec 2006 20:14:28 +0000 Subject: [PATCH] Monotone-Parent: 5e5737eca2d1e9eee20964323a842f391c2fa254 Monotone-Revision: cdc5b99b631d52baa52688922ca940cec737dae3 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2006-12-14T20:14:28 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 9 +- SoObjects/SOGo/SOGoDAVRendererTypes.h | 45 ++++++++++ SoObjects/SOGo/SOGoDAVRendererTypes.m | 114 ++++++++++++++++++++++++++ 3 files changed, 167 insertions(+), 1 deletion(-) create mode 100644 SoObjects/SOGo/SOGoDAVRendererTypes.h create mode 100644 SoObjects/SOGo/SOGoDAVRendererTypes.m diff --git a/ChangeLog b/ChangeLog index fae7dc4be..0a2f8bd0a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2006-12-14 Wolfgang Sourdeau + + * SoObjects/SOGo/SOGoDAVRendererTypes.m ([SOGoDAVSet + +davSetWithArray:newValuesofValuesTaggedAs:newValueTag]): a new + subclass module of SoWebDAVValue that supports collections of + properties of the same type. + 2006-11-21 Wolfgang Sourdeau * SoObjects/Mailer/SOGoMailAccount.m ([SOGoMailAccount @@ -10,7 +17,7 @@ * SoObjects/SOGo/SOGoObject.m ([SOGoObject -userTimeZone:username]): new method that returns the timezone for the specified user depending on his preferences and the server - defaults. + defaults * SoObjects/Mailer/SOGoMailObject.m ([SOGoMailObject -stringForData:partInfo:]): take the encoding into account and diff --git a/SoObjects/SOGo/SOGoDAVRendererTypes.h b/SoObjects/SOGo/SOGoDAVRendererTypes.h new file mode 100644 index 000000000..8a4b92743 --- /dev/null +++ b/SoObjects/SOGo/SOGoDAVRendererTypes.h @@ -0,0 +1,45 @@ +/* SOGoDAVRendererTypes.h - this file is part of SOGo + * + * Copyright (C) 2006 Inverse groupe conseil + * + * Author: Wolfgang Sourdeau + * + * This file is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This file 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef SOGODAVRENDERERTYPES_H +#define SOGODAVRENDERERTYPES_H + +#import + +@class NSArray; +@class NSString; + +@interface SOGoDAVSet : SoWebDAVValue +{ + NSString *valueTag; + NSArray *values; +} + ++ (id) davSetWithArray: (NSArray *) newValues + ofValuesTaggedAs: (NSString *) newValueTag; + +- (void) setValueTag: (NSString *) newValueTag; +- (void) setValues: (NSArray *) newValues; + +@end + +#endif /* SOGODAVRENDERERTYPES_H */ diff --git a/SoObjects/SOGo/SOGoDAVRendererTypes.m b/SoObjects/SOGo/SOGoDAVRendererTypes.m new file mode 100644 index 000000000..21a102c27 --- /dev/null +++ b/SoObjects/SOGo/SOGoDAVRendererTypes.m @@ -0,0 +1,114 @@ +/* SOGoDAVRendererTypes.m - this file is part of SOGo + * + * Copyright (C) 2006 Inverse groupe conseil + * + * Author: Wolfgang Sourdeau + * + * This file is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This file 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#import +#import +#import + +#import "SOGoDAVRendererTypes.h" + +@implementation SOGoDAVSet + ++ (id) davSetWithArray: (NSArray *) newValues + ofValuesTaggedAs: (NSString *) newValueTag +{ + id davSet; + + davSet = [self new]; + [davSet setValueTag: newValueTag]; + [davSet setValues: newValues]; + [davSet autorelease]; + + return davSet; +} + +- (id) init +{ + if ((self = [super init])) + { + valueTag = nil; + values = nil; + } + + return self; +} + +- (void) dealloc +{ + if (valueTag) + [valueTag release]; + if (values) + [values release]; + [super dealloc]; +} + +- (void) setValueTag: (NSString *) newValueTag +{ + ASSIGN (valueTag, newValueTag); +} + +- (void) setValues: (NSArray *) newValues +{ + ASSIGN (values, newValues); +} + +- (NSString *) stringForTag: (NSString *) _key + rawName: (NSString *) setTag + inContext: (id) context + prefixes: (NSDictionary *) prefixes +{ + NSMutableString *resultString; + id currentValue; + NSString *valueString; + NSEnumerator *valueEnum; + + resultString = [NSMutableString new]; + [resultString autorelease]; + + [resultString appendFormat: @"<%@>", setTag]; + valueEnum = [values objectEnumerator]; + currentValue = [valueEnum nextObject]; + while (currentValue) + { + if ([currentValue isKindOfClass: [SoWebDAVValue class]]) + valueString + = [currentValue stringForTag: + [NSString stringWithFormat: @"{DAV:}%@", valueTag] + rawName: [NSString stringWithFormat: @"D:%@", valueTag] + inContext: context + prefixes: prefixes]; + else + valueString = currentValue; + + [resultString appendFormat: @"<%@>%@", + valueTag, valueString, valueTag]; + currentValue = [valueEnum nextObject]; + } + [resultString appendFormat: @"", setTag]; + + NSLog(@"dav rendering for key '%@' and tag '%@':\n", _key, setTag, + resultString); + + return resultString; +} + +@end