mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-05-16 08:55:24 +00:00
Monotone-Parent: 8eb1c04a52c5c9e085d3376ba6f9142b007cf6b7
Monotone-Revision: 25ba41e4e6d01e0f051177fd9a19d230039e2f8d Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2008-02-22T21:21:59 Monotone-Branch: ca.inverse.sogo
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
2008-02-22 Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||
|
||||
* SoObjects/SOGo/SOGoDAVRendererTypes.h (SoWebDAVValue): added
|
||||
SOGoDAVDictionary webdav value class.
|
||||
|
||||
* SoObjects/SOGo/NSArray+Utilities.m ([NSArray -uniqueObjects]):
|
||||
new method that returns unique occurences of the objects.
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#import <NGObjWeb/SoWebDAVValue.h>
|
||||
|
||||
@class NSArray;
|
||||
@class NSDictionary;
|
||||
@class NSString;
|
||||
|
||||
@interface SOGoDAVSet : SoWebDAVValue
|
||||
@@ -42,4 +43,18 @@
|
||||
|
||||
@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 */
|
||||
|
||||
@@ -54,10 +54,8 @@
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
if (valueTag)
|
||||
[valueTag release];
|
||||
if (values)
|
||||
[values release];
|
||||
[valueTag release];
|
||||
[values release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
@@ -84,10 +82,9 @@
|
||||
resultString = [NSMutableString new];
|
||||
[resultString autorelease];
|
||||
|
||||
[resultString appendFormat: @"<%@>", setTag];
|
||||
// [resultString appendFormat: @"<%@>", setTag];
|
||||
valueEnum = [values objectEnumerator];
|
||||
currentValue = [valueEnum nextObject];
|
||||
while (currentValue)
|
||||
while ((currentValue = [valueEnum nextObject]))
|
||||
{
|
||||
if ([currentValue isKindOfClass: [SoWebDAVValue class]])
|
||||
valueString
|
||||
@@ -97,13 +94,13 @@
|
||||
inContext: context
|
||||
prefixes: prefixes];
|
||||
else
|
||||
valueString = currentValue;
|
||||
valueString = [[currentValue description] stringByEscapingXMLString];
|
||||
|
||||
[resultString appendFormat: @"<%@>%@</%@>",
|
||||
valueTag, valueString, valueTag];
|
||||
currentValue = [valueEnum nextObject];
|
||||
[resultString appendFormat: valueString];
|
||||
// [resultString appendFormat: @"<%@>%@</%@>",
|
||||
// valueTag, valueString, valueTag];
|
||||
}
|
||||
[resultString appendFormat: @"</%@>", setTag];
|
||||
// [resultString appendFormat: @"</%@>", setTag];
|
||||
|
||||
NSLog(@"dav rendering for key '%@' and tag '%@':\n", _key, setTag,
|
||||
resultString);
|
||||
@@ -111,4 +108,89 @@
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user