diff --git a/ChangeLog b/ChangeLog index f5169a820..5aa2b6522 100644 --- a/ChangeLog +++ b/ChangeLog @@ -11,6 +11,26 @@ * Added strings to translate and cleaned up the template to send HTML mails instead of text/plain. +2012-07-10 Wolfgang Sourdeau + + * SoObjects/Appointments/SOGoAppointmentFolder.m + (-davNotifyOnPersonalModifications) + (-setDavNotifyOnPersonalModifications:) + (-davNotifyOnExternalModifications) + (-setDavNotifyOnExternalModifications:) + (-davNotifyUserOnPersonalModifications) + (-setDavNotifyUserOnPersonalModifications:) + (-davNotifiedUserOnPersonalModifications) + (-setDavNotifiedUserOnPersonalModifications:): new dav accessors. + + + * SoObjects/SOGo/SOGoObject.m (-davBooleanForResult:): new method + that returns a valid DAV boolean from a BOOL. + (-isValidDAVBoolean:): new method that validates the value as a + DAV boolean. + (-resultForDAVBoolean:): new method that returns a BOOL from a DAV + boolean. + 2012-07-09 Ludovic Marcotte * Dropped old templates (SOGoAptMailDeletionReceipt.wox diff --git a/SoObjects/Appointments/SOGoAppointmentFolder.m b/SoObjects/Appointments/SOGoAppointmentFolder.m index 864d0ec26..29a64b77b 100644 --- a/SoObjects/Appointments/SOGoAppointmentFolder.m +++ b/SoObjects/Appointments/SOGoAppointmentFolder.m @@ -455,7 +455,7 @@ static NSNumber *sharedYes = nil; // We MUST keep the 'NO' value here, because we will always // fallback to the domain defaults otherwise. // -- (BOOL) _setNotificationValue: (BOOL) b +- (void) _setNotificationValue: (BOOL) b forKey: (NSString *) theKey { [self setFolderPropertyValue: [NSNumber numberWithBool: b] @@ -1005,7 +1005,9 @@ firstInstanceCalendarDateRange: (NGCalendarDateRange *) fir rules = [cycleinfo objectForKey: @"rules"]; exRules = [cycleinfo objectForKey: @"exRules"]; exDates = [cycleinfo objectForKey: @"exDates"]; - eventTimeZone = allDayTimeZone = tz = nil; + eventTimeZone = nil; + allDayTimeZone = nil; + tz = nil; row = [self fixupRecord: theRecord]; [row removeObjectForKey: @"c_cycleinfo"]; @@ -1062,7 +1064,9 @@ firstInstanceCalendarDateRange: (NGCalendarDateRange *) fir } } - tz = eventTimeZone? eventTimeZone : allDayTimeZone; +#warning this code is ugly: we should not mix objects with different types as\ + it reduces readability + tz = eventTimeZone ? eventTimeZone : allDayTimeZone; if (tz) { // Adjust the exception dates @@ -2250,28 +2254,18 @@ firstInstanceCalendarDateRange: (NGCalendarDateRange *) fir - (NSString *) davCalendarShowAlarms { - NSString *boolean; - - if ([self showCalendarAlarms]) - boolean = @"true"; - else - boolean = @"false"; - - return boolean; + return [self davBooleanForResult: [self showCalendarAlarms]]; } - (NSException *) setDavCalendarShowAlarms: (id) newBoolean { NSException *error; - error = nil; - - if ([newBoolean isEqualToString: @"true"] - || [newBoolean isEqualToString: @"1"]) - [self setShowCalendarAlarms: YES]; - else if ([newBoolean isEqualToString: @"false"] - || [newBoolean isEqualToString: @"0"]) - [self setShowCalendarAlarms: NO]; + if ([self isValidDAVBoolean: newBoolean]) + { + [self setShowCalendarAlarms: [self resultForDAVBoolean: newBoolean]]; + error = nil; + } else error = [NSException exceptionWithHTTPStatus: 400 reason: @"Bad boolean value."]; @@ -2279,6 +2273,84 @@ firstInstanceCalendarDateRange: (NGCalendarDateRange *) fir return error; } +- (NSString *) davNotifyOnPersonalModifications +{ + return [self davBooleanForResult: [self notifyOnPersonalModifications]]; +} + +- (NSException *) setDavNotifyOnPersonalModifications: (NSString *) newBoolean +{ + NSException *error; + + if ([self isValidDAVBoolean: newBoolean]) + { + [self setNotifyOnPersonalModifications: + [self resultForDAVBoolean: newBoolean]]; + error = nil; + } + else + error = [NSException exceptionWithHTTPStatus: 400 + reason: @"Bad boolean value."]; + + return error; +} + +- (NSString *) davNotifyOnExternalModifications +{ + return [self davBooleanForResult: [self notifyOnExternalModifications]]; +} + +- (NSException *) setDavNotifyOnExternalModifications: (NSString *) newBoolean +{ + NSException *error; + + if ([self isValidDAVBoolean: newBoolean]) + { + [self setNotifyOnExternalModifications: + [self resultForDAVBoolean: newBoolean]]; + error = nil; + } + else + error = [NSException exceptionWithHTTPStatus: 400 + reason: @"Bad boolean value."]; + + return error; +} + +- (NSString *) davNotifyUserOnPersonalModifications +{ + return [self davBooleanForResult: [self notifyUserOnPersonalModifications]]; +} + +- (NSException *) setDavNotifyUserOnPersonalModifications: (NSString *) newBoolean +{ + NSException *error; + + if ([self isValidDAVBoolean: newBoolean]) + { + [self setNotifyUserOnPersonalModifications: + [self resultForDAVBoolean: newBoolean]]; + error = nil; + } + else + error = [NSException exceptionWithHTTPStatus: 400 + reason: @"Bad boolean value."]; + + return error; +} + +- (NSString *) davNotifiedUserOnPersonalModifications +{ + return [self notifiedUserOnPersonalModifications]; +} + +- (NSException *) setDavNotifiedUserOnPersonalModifications: (NSString *) theUser +{ + [self setNotifiedUserOnPersonalModifications: theUser]; + + return nil; +} + /* vevent UID handling */ - (NSString *) resourceNameForEventUID: (NSString *) uid diff --git a/SoObjects/SOGo/SOGoObject.h b/SoObjects/SOGo/SOGoObject.h index dc26fd78e..172f45a60 100644 --- a/SoObjects/SOGo/SOGoObject.h +++ b/SoObjects/SOGo/SOGoObject.h @@ -166,6 +166,10 @@ parameters: (NSArray *) params; /* utilities */ +- (NSString *) davBooleanForResult: (BOOL) result; +- (BOOL) isValidDAVBoolean: (NSString *) davBoolean; +- (BOOL) resultForDAVBoolean: (NSString *) davBoolean; + - (NSString *) labelForKey: (NSString *) key; /* description */ diff --git a/SoObjects/SOGo/SOGoObject.m b/SoObjects/SOGo/SOGoObject.m index 8736cf050..44cc83647 100644 --- a/SoObjects/SOGo/SOGoObject.m +++ b/SoObjects/SOGo/SOGoObject.m @@ -27,6 +27,7 @@ #import #import #import +#import #import #import #import @@ -1582,6 +1583,35 @@ return exception; } +- (NSString *) davBooleanForResult: (BOOL) result +{ + return (result ? @"true" : @"false"); +} + +- (BOOL) isValidDAVBoolean: (NSString *) davBoolean +{ + static NSSet *validBooleans = nil; + + if (!validBooleans) + { + validBooleans = [NSSet setWithObjects: @"true", @"false", @"1", @"0", + nil]; + [validBooleans retain]; + } + + return [validBooleans containsObject: davBoolean]; +} + +- (BOOL) resultForDAVBoolean: (NSString *) davBoolean +{ + BOOL result; + + result = ([davBoolean isEqualToString: @"true"] + || [davBoolean isEqualToString: @"1"]); + + return result; +} + - (NSString *) labelForKey: (NSString *) key { return [self labelForKey: key inContext: context];