From 87a7732361e9d0089f5761b11fc8d963ccded448 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Thu, 12 Jul 2012 15:03:38 +0000 Subject: [PATCH] applied changes from c6b25920d896b2d19d0ef40a4cadee46c87bba2d through fcec9822c0aaee8cefba77d0f50a8582b33fa3f0 Monotone-Parent: 975e40192e290b5aa4bc5c5b99a12b299d84fa5a Monotone-Revision: 4d39a71900cc87ae1185f268c1c35a5a4b086b1d Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2012-07-12T15:03:38 --- ChangeLog | 20 ++++ .../Appointments/SOGoAppointmentFolder.m | 110 +++++++++++++++--- SoObjects/SOGo/SOGoObject.h | 4 + SoObjects/SOGo/SOGoObject.m | 30 +++++ 4 files changed, 145 insertions(+), 19 deletions(-) diff --git a/ChangeLog b/ChangeLog index cb773ecb3..66c9d257e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -8,6 +8,26 @@ show the notification options if it's a web calendar or if the active user isn't the owner of the calendar. +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];