From cc69371c4d33919423a0dcceef1058a0a85b828c Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Fri, 2 May 2008 22:46:49 +0000 Subject: [PATCH] Monotone-Parent: b8c85ddcde506f67f18bf96dcff79741af94661b Monotone-Revision: c3c38efee718461f598c3836c1cbe39986c23fd2 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2008-05-02T22:46:49 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 19 +++ SoObjects/SOGo/NSArray+DAV.h | 38 +++++ SoObjects/SOGo/NSArray+DAV.m | 45 ++++++ SoObjects/SOGo/NSDictionary+DAV.h | 37 +++++ SoObjects/SOGo/NSDictionary+DAV.m | 95 ++++++++++++ SoObjects/SOGo/NSObject+DAV.h | 48 +++++++ SoObjects/SOGo/NSObject+DAV.m | 44 ++++++ SoObjects/SOGo/NSString+DAV.h | 37 +++++ SoObjects/SOGo/NSString+DAV.m | 35 +++++ SoObjects/SOGo/NSURL+DAV.h | 37 +++++ SoObjects/SOGo/NSURL+DAV.m | 36 +++++ SoObjects/SOGo/SOGoDAVRendererTypes.h | 60 -------- SoObjects/SOGo/SOGoDAVRendererTypes.m | 198 -------------------------- 13 files changed, 471 insertions(+), 258 deletions(-) create mode 100644 SoObjects/SOGo/NSArray+DAV.h create mode 100644 SoObjects/SOGo/NSArray+DAV.m create mode 100644 SoObjects/SOGo/NSDictionary+DAV.h create mode 100644 SoObjects/SOGo/NSDictionary+DAV.m create mode 100644 SoObjects/SOGo/NSObject+DAV.h create mode 100644 SoObjects/SOGo/NSObject+DAV.m create mode 100644 SoObjects/SOGo/NSString+DAV.h create mode 100644 SoObjects/SOGo/NSString+DAV.m create mode 100644 SoObjects/SOGo/NSURL+DAV.h create mode 100644 SoObjects/SOGo/NSURL+DAV.m delete mode 100644 SoObjects/SOGo/SOGoDAVRendererTypes.h delete mode 100644 SoObjects/SOGo/SOGoDAVRendererTypes.m diff --git a/ChangeLog b/ChangeLog index b08648b68..ed9456cd7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,22 @@ +2008-05-02 Wolfgang Sourdeau + + * SoObjects/SOGo/SOGoDAVRendererTypes.[hm]: removed subclass + module, superseded by the new method mentionned below. + + * SoObjects/SOGo/SOGoWebDAVValue.m ([SOGoWebDAVValue + -stringForTag:_keyrawName:setTaginContext:contextprefixes:prefixes]): + a simple wrapper that returns an uninterpreted NSString to SOPE. + + * SoObjects/SOGo/NSArray+DAV.[hm], + * SoObjects/SOGo/NSDictionary+DAV.[hm], + * SoObjects/SOGo/NSObject+DAV.[hm], + * SoObjects/SOGo/NSString+DAV.[hm], + * SoObjects/SOGo/NSURL+DAV.[hm]: new class category modules that + handle the correct generation of DAV entries, with namespace + accounting. Those were implemented to enable the use of a simple + SoWebDAVValue as the root of the resulting string, thereby + avoiding the xml escaping done by SOPE when returning a real NSString. + 2008-04-25 Wolfgang Sourdeau * SoObjects/SOGo/LDAPSource.m ([LDAPSource -fetchContactsMatching:match]) diff --git a/SoObjects/SOGo/NSArray+DAV.h b/SoObjects/SOGo/NSArray+DAV.h new file mode 100644 index 000000000..6804a210f --- /dev/null +++ b/SoObjects/SOGo/NSArray+DAV.h @@ -0,0 +1,38 @@ +/* NSArray+DAV.h - this file is part of SOGo + * + * Copyright (C) 2008 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 NSARRAY_DAV_H +#define NSARRAY_DAV_H + +#import + +@class NSMutableDictionary; +@class NSString; + +@interface NSArray (SOGoWebDAVExtensions) + +- (NSString *) + asWebDavStringWithNamespaces: (NSMutableDictionary *) namespaces; + +@end + +#endif /* NSARRAY_DAV_H */ diff --git a/SoObjects/SOGo/NSArray+DAV.m b/SoObjects/SOGo/NSArray+DAV.m new file mode 100644 index 000000000..ae70ad7f5 --- /dev/null +++ b/SoObjects/SOGo/NSArray+DAV.m @@ -0,0 +1,45 @@ +/* NSArray+DAV.m - this file is part of SOGo + * + * Copyright (C) 2008 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 "NSObject+DAV.h" + +#import "NSArray+DAV.h" + +@implementation NSArray (SOGoWebDAVExtensions) + +- (NSString *) + asWebDavStringWithNamespaces: (NSMutableDictionary *) namespaces +{ + NSMutableString *webdavString; + NSEnumerator *children; + NSObject *child; + + webdavString = [NSMutableString string]; + children = [self objectEnumerator]; + while ((child = [children nextObject])) + [webdavString appendString: + [child asWebDavStringWithNamespaces: namespaces]]; + + return webdavString; +} + +@end diff --git a/SoObjects/SOGo/NSDictionary+DAV.h b/SoObjects/SOGo/NSDictionary+DAV.h new file mode 100644 index 000000000..a885b116a --- /dev/null +++ b/SoObjects/SOGo/NSDictionary+DAV.h @@ -0,0 +1,37 @@ +/* NSDictionary+DAV.h - this file is part of SOGo + * + * Copyright (C) 2008 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 NSDICTIONARY_DAV_H +#define NSDICTIONARY_DAV_H + +#import + +@class NSString; + +@interface NSDictionary (SOGoWebDAVExtensions) + +- (NSString *) + asWebDavStringWithNamespaces: (NSMutableDictionary *) namespaces; + +@end + +#endif /* NSDICTIONARY_DAV_H */ diff --git a/SoObjects/SOGo/NSDictionary+DAV.m b/SoObjects/SOGo/NSDictionary+DAV.m new file mode 100644 index 000000000..6ea330de4 --- /dev/null +++ b/SoObjects/SOGo/NSDictionary+DAV.m @@ -0,0 +1,95 @@ +/* NSDictionary+DAV.m - this file is part of SOGo + * + * Copyright (C) 2008 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 "NSDictionary+DAV.h" + +@implementation NSDictionary (SOGoWebDAVExtensions) + +- (NSString *) _namespaceDecl: (NSDictionary *) namespaces +{ + NSMutableString *decl; + NSEnumerator *keys; + NSString *key; + + decl = [NSMutableString string]; + keys = [[namespaces allKeys] objectEnumerator]; + while ((key = [keys nextObject])) + [decl appendFormat: @" xmlns:%@=\"%@\"", + [namespaces objectForKey: key], key]; + + return decl; +} + +- (NSString *) _newTagInNamespaces: (NSMutableDictionary *) namespaces + forNS: (NSString *) newNS +{ + NSString *newTag; + + newTag = [NSString stringWithFormat: @"n%d", [namespaces count]]; + [namespaces setObject: newTag forKey: newNS]; + + return newTag; +} + +- (NSString *) + asWebDavStringWithNamespaces: (NSMutableDictionary *) namespaces +{ + NSMutableString *webdavString; + NSString *nsTag, *ns, *subString, *element; + BOOL firstLevel; + + if (!namespaces) + { + firstLevel = YES; + namespaces = [NSMutableDictionary new]; + [namespaces setObject: @"D" forKey: @"DAV:"]; + } + else + firstLevel = NO; + + webdavString = [NSMutableString string]; + ns = [self objectForKey: @"ns"]; + nsTag = [namespaces objectForKey: ns]; + if (!nsTag) + nsTag = [self _newTagInNamespaces: namespaces forNS: ns]; + element = [NSString stringWithFormat: @"%@:%@", + nsTag, [self objectForKey: @"method"]]; + [webdavString appendFormat: @"<%@", element]; + subString = [[self objectForKey: @"content"] + asWebDavStringWithNamespaces: namespaces]; + if (firstLevel) + { + [webdavString appendString: [self _namespaceDecl: namespaces]]; + [namespaces release]; + } + if (subString) + [webdavString appendFormat: @">%@", subString, element]; + else + [webdavString appendString: @"/>"]; + + return webdavString; +} + +@end diff --git a/SoObjects/SOGo/NSObject+DAV.h b/SoObjects/SOGo/NSObject+DAV.h new file mode 100644 index 000000000..844ac0005 --- /dev/null +++ b/SoObjects/SOGo/NSObject+DAV.h @@ -0,0 +1,48 @@ +/* NSObject+DAV.h - this file is part of SOGo + * + * Copyright (C) 2008 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 NSOBJECT_DAV_H +#define NSOBJECT_DAV_H + +#import + +@class NSMutableDictionary; +@class NSString; +@class SOGoWebDAVValue; + +#define davElement(t,n) \ + [NSDictionary dictionaryWithObjectsAndKeys: t, @"method", n, @"ns", nil] + +#define davElementWithContent(t,n,c) \ + [NSDictionary dictionaryWithObjectsAndKeys: t, @"method", \ + n, @"ns", \ + c, @"content", nil] + +@interface NSObject (SOGoWebDAVExtensions) + +- (NSString *) + asWebDavStringWithNamespaces: (NSMutableDictionary *) namespaces; +- (SOGoWebDAVValue *) asWebDAVValue; + +@end + +#endif /* NSOBJECT_DAV_H */ diff --git a/SoObjects/SOGo/NSObject+DAV.m b/SoObjects/SOGo/NSObject+DAV.m new file mode 100644 index 000000000..5a95acf21 --- /dev/null +++ b/SoObjects/SOGo/NSObject+DAV.m @@ -0,0 +1,44 @@ +/* NSObject+DAV.m - this file is part of SOGo + * + * Copyright (C) 2008 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 "SOGoWebDAVValue.h" + +#import "NSObject+DAV.h" + +@implementation NSObject (SOGoWebDAVExtensions) + +- (NSString *) + asWebDavStringWithNamespaces: (NSMutableDictionary *) namespaces +{ + [self subclassResponsibility: _cmd]; + + return nil; +} + +- (SOGoWebDAVValue *) asWebDAVValue +{ + return [SOGoWebDAVValue + valueForObject: [self asWebDavStringWithNamespaces: nil] + attributes: nil]; +} + +@end diff --git a/SoObjects/SOGo/NSString+DAV.h b/SoObjects/SOGo/NSString+DAV.h new file mode 100644 index 000000000..068e8f8ba --- /dev/null +++ b/SoObjects/SOGo/NSString+DAV.h @@ -0,0 +1,37 @@ +/* NSString+DAV.h - this file is part of SOGo + * + * Copyright (C) 2008 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 NSSTRING_DAV_H +#define NSSTRING_DAV_H + +#import + +@class NSMutableDictionary; + +@interface NSString (SOGoWebDAVExtensions) + +- (NSString *) + asWebDavStringWithNamespaces: (NSMutableDictionary *) namespaces; + +@end + +#endif /* NSSTRING_DAV_H */ diff --git a/SoObjects/SOGo/NSString+DAV.m b/SoObjects/SOGo/NSString+DAV.m new file mode 100644 index 000000000..25d886618 --- /dev/null +++ b/SoObjects/SOGo/NSString+DAV.m @@ -0,0 +1,35 @@ +/* NSString+DAV.m - this file is part of SOGo + * + * Copyright (C) 2008 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 "NSString+DAV.h" + +@implementation NSString (SOGoWebDAVExtensions) + +- (NSString *) + asWebDavStringWithNamespaces: (NSMutableDictionary *) namespaces +{ + return [self stringByEscapingXMLString]; +} + +@end diff --git a/SoObjects/SOGo/NSURL+DAV.h b/SoObjects/SOGo/NSURL+DAV.h new file mode 100644 index 000000000..be39c2f1f --- /dev/null +++ b/SoObjects/SOGo/NSURL+DAV.h @@ -0,0 +1,37 @@ +/* NSURL+DAV.h - this file is part of SOGo + * + * Copyright (C) 2008 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 NSURL_DAV_H +#define NSURL_DAV_H + +#import + +@class NSMutableDictionary; + +@interface NSURL (SOGoWebDAVExtensions) + +- (NSString *) + asWebDavStringWithNamespaces: (NSMutableDictionary *) namespaces; + +@end + +#endif /* NSURL_DAV_H */ diff --git a/SoObjects/SOGo/NSURL+DAV.m b/SoObjects/SOGo/NSURL+DAV.m new file mode 100644 index 000000000..8068246d8 --- /dev/null +++ b/SoObjects/SOGo/NSURL+DAV.m @@ -0,0 +1,36 @@ +/* NSURL+DAV.m - this file is part of SOGo + * + * Copyright (C) 2008 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 "NSURL+DAV.h" + +@implementation NSURL (SOGoWebDAVExtensions) + +- (NSString *) + asWebDavStringWithNamespaces: (NSMutableDictionary *) namespaces +{ + return [[self absoluteString] stringByEscapingXMLString]; +} + +@end diff --git a/SoObjects/SOGo/SOGoDAVRendererTypes.h b/SoObjects/SOGo/SOGoDAVRendererTypes.h deleted file mode 100644 index 2fdfaa817..000000000 --- a/SoObjects/SOGo/SOGoDAVRendererTypes.h +++ /dev/null @@ -1,60 +0,0 @@ -/* 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 NSDictionary; -@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 - -@interface SOGoDAVDictionary : SoWebDAVValue -{ - NSString *valueTag; - NSDictionary *values; -} - -+ (id) davDictionary: (NSDictionary *) newValues - taggedAs: (NSString *) newValueTag; - -- (void) setValueTag: (NSString *) newValueTag; -- (void) setValues: (NSDictionary *) newValues; - -@end - -#endif /* SOGODAVRENDERERTYPES_H */ diff --git a/SoObjects/SOGo/SOGoDAVRendererTypes.m b/SoObjects/SOGo/SOGoDAVRendererTypes.m deleted file mode 100644 index 5d74a9c59..000000000 --- a/SoObjects/SOGo/SOGoDAVRendererTypes.m +++ /dev/null @@ -1,198 +0,0 @@ -/* SOGoDAVRendererTypes.m - this file is part of SOGo - * - * Copyright (C) 2006, 2008 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 - -#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 -{ - [valueTag release]; - [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]; - while ((currentValue = [valueEnum nextObject])) - { - if ([currentValue isKindOfClass: [SoWebDAVValue class]]) - valueString - = [currentValue stringForTag: - [NSString stringWithFormat: @"{DAV:}%@", valueTag] - rawName: [NSString stringWithFormat: @"D:%@", valueTag] - inContext: context - prefixes: prefixes]; - else - valueString = [[currentValue description] stringByEscapingXMLString]; - - [resultString appendFormat: valueString]; -// [resultString appendFormat: @"<%@>%@", -// valueTag, valueString, valueTag]; - } -// [resultString appendFormat: @"", setTag]; - - NSLog(@"dav rendering for key '%@' and tag '%@':\n", _key, setTag, - resultString); - - return resultString; -} - -- (NSString *) stringValue -{ - return [self stringForTag: valueTag rawName: valueTag - inContext: nil prefixes: nil]; -} - -@end - -@implementation SOGoDAVDictionary - -+ (id) davDictionary: (NSDictionary *) newValues - taggedAs: (NSString *) newValueTag; -{ - SOGoDAVDictionary *davDictionary; - - davDictionary = [self new]; - [davDictionary setValueTag: newValueTag]; - [davDictionary setValues: newValues]; - [davDictionary autorelease]; - - return davDictionary; -} - -- (id) init -{ - if ((self = [super init])) - { - valueTag = nil; - values = nil; - } - - return self; -} - -- (void) dealloc -{ - [valueTag release]; - [values release]; - [super dealloc]; -} - -- (void) setValueTag: (NSString *) newValueTag -{ - ASSIGN (valueTag, newValueTag); -} - -- (void) setValues: (NSDictionary *) newValues -{ - ASSIGN (values, newValues); -} - -- (NSString *) stringForTag: (NSString *) _key - rawName: (NSString *) setTag - inContext: (id) context - prefixes: (NSDictionary *) prefixes -{ - NSMutableString *resultString; - id currentValue; - NSEnumerator *objects; - NSString *currentKey, *valueString; - - resultString = [NSMutableString string]; - - [resultString appendFormat: @"<%@>", valueTag]; - objects = [[values allKeys] objectEnumerator]; - while ((currentKey = [objects nextObject])) - { - currentValue = [values objectForKey: currentKey]; - if ([currentValue isKindOfClass: [SoWebDAVValue class]]) - valueString - = [currentValue stringForTag: - [NSString stringWithFormat: @"{DAV:}%@", valueTag] - rawName: [NSString stringWithFormat: @"D:%@", valueTag] - inContext: context - prefixes: prefixes]; - else - valueString = [[currentValue description] stringByEscapingXMLString]; - - [resultString appendFormat: @"<%@>%@", currentKey, valueString, currentKey]; - } - [resultString appendFormat: @"", valueTag]; - - return resultString; -} - -@end