diff --git a/ChangeLog b/ChangeLog index 202df5592..413adbf37 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2009-10-06 Wolfgang Sourdeau + + * SoObjects/SOGo/SOGoGCSFolder.m + (-createChildComponentWithRecord:): made method public. + (-createChildComponentWithName:andContent:): made method public. + + * SoObjects/SOGo/NSArray+DAV.m (-asDAVPropstatWithStatus:): new + method that creates a "PROPSTAT" element with the specified + status. + 2009-10-06 Francis Lachapelle * SoObjects/SOGo/SOGoUser.m (_timeValue): improved parsing to diff --git a/SoObjects/Appointments/SOGoAppointmentFolder.m b/SoObjects/Appointments/SOGoAppointmentFolder.m index adb3e1d73..9cf120f8d 100644 --- a/SoObjects/Appointments/SOGoAppointmentFolder.m +++ b/SoObjects/Appointments/SOGoAppointmentFolder.m @@ -1239,7 +1239,7 @@ firstInstanceCalendarDateRange: (NGCalendarDateRange *) fir //c = [self objectClassForComponentName: [object objectForKey: @"c_component"]]; #warning TODO: determine why this commented invocation takes so long... - // sogoObject = [self _createChildComponentWithRecord: object]; + // sogoObject = [self createChildComponentWithRecord: object]; sogoObject = [SOGoCalendarComponent objectWithRecord: object inContainer: self]; diff --git a/SoObjects/SOGo/NSArray+DAV.h b/SoObjects/SOGo/NSArray+DAV.h index 2ff6863bc..47b9b5cc7 100644 --- a/SoObjects/SOGo/NSArray+DAV.h +++ b/SoObjects/SOGo/NSArray+DAV.h @@ -25,6 +25,7 @@ #import +@class NSDictionary; @class NSMutableDictionary; @class NSString; @@ -33,6 +34,8 @@ - (NSString *) asWebDavStringWithNamespaces: (NSMutableDictionary *) namespaces; +- (NSDictionary *) asDAVPropstatWithStatus: (NSString *) status; + @end #endif /* NSARRAY_DAV_H */ diff --git a/SoObjects/SOGo/NSArray+DAV.m b/SoObjects/SOGo/NSArray+DAV.m index 56cba073d..836c98036 100644 --- a/SoObjects/SOGo/NSArray+DAV.m +++ b/SoObjects/SOGo/NSArray+DAV.m @@ -20,9 +20,12 @@ * Boston, MA 02111-1307, USA. */ +#import #import #import +#import + #import "NSObject+DAV.h" #import "NSArray+DAV.h" @@ -48,4 +51,17 @@ return webdavString; } +- (NSDictionary *) asDAVPropstatWithStatus: (NSString *) status +{ + NSMutableArray *propstat; + + propstat = [NSMutableArray arrayWithCapacity: 2]; + [propstat addObject: davElementWithContent (@"prop", XMLNS_WEBDAV, + self)]; + [propstat addObject: davElementWithContent (@"status", XMLNS_WEBDAV, + status)]; + + return davElementWithContent (@"propstat", XMLNS_WEBDAV, propstat); +} + @end diff --git a/SoObjects/SOGo/SOGoGCSFolder.h b/SoObjects/SOGo/SOGoGCSFolder.h index 25e5d6e1a..b4fbe8abb 100644 --- a/SoObjects/SOGo/SOGoGCSFolder.h +++ b/SoObjects/SOGo/SOGoGCSFolder.h @@ -77,6 +77,10 @@ - (Class) objectClassForComponentName: (NSString *) componentName; - (Class) objectClassForContent: (NSString *) content; +- (id) createChildComponentWithRecord: (NSDictionary *) record; +- (id) createChildComponentWithName: (NSString *) newName + andContent: (NSString *) newContent; + - (NSArray *) fetchContentObjectNames; /* folder type */ diff --git a/SoObjects/SOGo/SOGoGCSFolder.m b/SoObjects/SOGo/SOGoGCSFolder.m index 8976e8b84..071b3a093 100644 --- a/SoObjects/SOGo/SOGoGCSFolder.m +++ b/SoObjects/SOGo/SOGoGCSFolder.m @@ -57,6 +57,7 @@ #import "NSDictionary+Utilities.h" #import "NSArray+Utilities.h" +#import "NSArray+DAV.h" #import "NSObject+DAV.h" #import "NSString+Utilities.h" #import "NSString+DAV.h" @@ -531,18 +532,18 @@ static NSArray *childRecordFields = nil; return Nil; } -- (id) _createChildComponentWithRecord: (NSDictionary *) record +- (id) createChildComponentWithRecord: (NSDictionary *) record { Class klazz; klazz = [self objectClassForComponentName: - [record objectForKey: @"c_component"]]; + [record objectForKey: @"c_component"]]; return [klazz objectWithRecord: record inContainer: self]; } -- (id) _createChildComponentWithName: (NSString *) newName - andContent: (NSString *) newContent +- (id) createChildComponentWithName: (NSString *) newName + andContent: (NSString *) newContent { Class klazz; NSDictionary *record; @@ -581,14 +582,14 @@ static NSArray *childRecordFields = nil; [childRecords setObject: record forKey: key]; } if (record) - obj = [self _createChildComponentWithRecord: record]; + obj = [self createChildComponentWithRecord: record]; else { request = [localContext request]; if ([[request method] isEqualToString: @"PUT"]) { - obj = [self _createChildComponentWithName: key - andContent: [request contentAsString]]; + obj = [self createChildComponentWithName: key + andContent: [request contentAsString]]; [obj setIsNew: YES]; } } @@ -928,8 +929,8 @@ static NSArray *childRecordFields = nil; syncTokenInt]; fields = [NSMutableArray arrayWithObjects: @"c_name", @"c_deleted", nil]; [mRecords addObjectsFromArray: [self _fetchFields: fields - withQualifier: qualifier - ignoreDeleted: NO]]; + withQualifier: qualifier + ignoreDeleted: NO]]; records = mRecords; } else @@ -946,22 +947,6 @@ static NSArray *childRecordFields = nil; return records; } -/* These methods are the optimal ones to generate propstats for DAV reports, - it should be used in other subclasses. */ -- (NSDictionary *) _davPropstat: (NSArray *) properties - withStatus: (NSString *) status -{ - NSMutableArray *propstat; - - propstat = [NSMutableArray arrayWithCapacity: 2]; - [propstat addObject: davElementWithContent (@"prop", XMLNS_WEBDAV, - properties)]; - [propstat addObject: davElementWithContent (@"status", XMLNS_WEBDAV, - status)]; - - return davElementWithContent (@"propstat", XMLNS_WEBDAV, propstat); -} - - (NSArray *) _davPropstatsWithProperties: (NSArray *) davProperties andMethodSelectors: (SEL *) selectors fromRecord: (NSDictionary *) record @@ -978,12 +963,12 @@ static NSArray *childRecordFields = nil; properties200 = [NSMutableArray arrayWithCapacity: max]; properties404 = [NSMutableArray arrayWithCapacity: max]; - sogoObject = [self _createChildComponentWithRecord: record]; + sogoObject = [self createChildComponentWithRecord: record]; for (count = 0; count < max; count++) { if (selectors[count] && [sogoObject respondsToSelector: selectors[count]]) - result = [sogoObject performSelector: selectors[count]]; + result = [sogoObject performSelector: selectors[count]]; else result = nil; @@ -996,17 +981,17 @@ static NSArray *childRecordFields = nil; else { propContent = [[davProperties objectAtIndex: count] - asWebDAVTuple]; + asWebDAVTuple]; [properties404 addObject: propContent]; } } if ([properties200 count]) - [propstats addObject: [self _davPropstat: properties200 - withStatus: @"HTTP/1.1 200 OK"]]; + [propstats addObject: [properties200 + asDAVPropstatWithStatus: @"HTTP/1.1 200 OK"]]; if ([properties404 count]) - [propstats addObject: [self _davPropstat: properties404 - withStatus: @"HTTP/1.1 404 Not Found"]]; + [propstats addObject: [properties404 + asDAVPropstatWithStatus: @"HTTP/1.1 404 Not Found"]]; return propstats; } @@ -1018,15 +1003,15 @@ static NSArray *childRecordFields = nil; andBaseURL: (NSString *) baseURL { static NSString *status[] = { @"HTTP/1.1 404 Not Found", - @"HTTP/1.1 201 Created", - @"HTTP/1.1 200 OK" }; + @"HTTP/1.1 201 Created", + @"HTTP/1.1 200 OK" }; NSMutableArray *children; NSString *href; unsigned int statusIndex; children = [NSMutableArray arrayWithCapacity: 3]; href = [NSString stringWithFormat: @"%@%@", - baseURL, [record objectForKey: @"c_name"]]; + baseURL, [record objectForKey: @"c_name"]]; [children addObject: davElementWithContent (@"href", XMLNS_WEBDAV, href)]; if (syncToken) @@ -1051,8 +1036,8 @@ static NSArray *childRecordFields = nil; if (statusIndex) [children addObjectsFromArray: [self _davPropstatsWithProperties: properties - andMethodSelectors: selectors - fromRecord: record]]; + andMethodSelectors: selectors + fromRecord: record]]; return davElementWithContent (@"sync-response", XMLNS_WEBDAV, children); }