From dbfa5926b63e692b45072217b98b22c0348d41ff Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Wed, 7 Mar 2007 21:33:13 +0000 Subject: [PATCH] Monotone-Parent: c8a00b4000a967d747332ed76e3501e958d17cfb Monotone-Revision: 54dc6ee0dac49ddab76097b4e22cd6d4d5d91a3d Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2007-03-07T21:33:13 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 13 ++++ .../Appointments/SOGoCalendarComponent.h | 1 + .../Appointments/SOGoCalendarComponent.m | 66 +++++++++++++++++++ 3 files changed, 80 insertions(+) diff --git a/ChangeLog b/ChangeLog index ddc738ec8..42bc66729 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,18 @@ 2007-03-07 Wolfgang Sourdeau + * SoObjects/Appointments/SOGoCalendarComponent.m + ([SOGoCalendarComponent -contentAsString]): overriden method that + takes the privacy into account and discard the relevant fields if + needed by generating a new content string and caching it. + ([SOGoCalendarComponent + -saveContentString:contentStringbaseVersion:baseVersion]): if the + new method above has cached a content string, release it and set + it to nil so that it will have to be regenerated in the case it is + requested further. + ([SOGoCalendarComponent -_filterPrivateComponent:component]): + discard the fields that have to be hidden when the card is + private. + * SoObjects/Appointments/SOGoAppointmentFolder.m ([SOGoAppointmentFolder -appendObject:objectwithBaseURL:baseURLtoREPORTResponse:r]): make diff --git a/SoObjects/Appointments/SOGoCalendarComponent.h b/SoObjects/Appointments/SOGoCalendarComponent.h index 50e069ee5..589b7dbb6 100644 --- a/SoObjects/Appointments/SOGoCalendarComponent.h +++ b/SoObjects/Appointments/SOGoCalendarComponent.h @@ -34,6 +34,7 @@ @interface SOGoCalendarComponent : SOGoContentObject { iCalCalendar *calendar; + NSString *calContent; } - (NSString *) componentTag; diff --git a/SoObjects/Appointments/SOGoCalendarComponent.m b/SoObjects/Appointments/SOGoCalendarComponent.m index c5e6e3111..c79091a72 100644 --- a/SoObjects/Appointments/SOGoCalendarComponent.m +++ b/SoObjects/Appointments/SOGoCalendarComponent.m @@ -68,6 +68,7 @@ static BOOL sendEMailNotifications = NO; if ((self = [super init])) { calendar = nil; + calContent = nil; } return self; @@ -77,6 +78,8 @@ static BOOL sendEMailNotifications = NO; { if (calendar) [calendar release]; + if (calContent) + [calContent release]; [super dealloc]; } @@ -92,6 +95,69 @@ static BOOL sendEMailNotifications = NO; return nil; } +- (void) _filterPrivateComponent: (iCalEntityObject *) component +{ + [component setSummary: @""]; + [component setComment: @""]; + [component setUserComment: @""]; + [component setLocation: @""]; + [component setCategories: @""]; + [component setUrl: @""]; + [component removeAllAttendees]; + [component removeAllAlarms]; +} + +- (NSString *) contentAsString +{ + NSString *tmpContent, *email; + iCalCalendar *tmpCalendar; + iCalRepeatableEntityObject *tmpComponent; + WOContext *context; + + if (!calContent) + { + tmpContent = [super contentAsString]; + calContent = tmpContent; + if ([tmpContent length] > 0) + { + tmpCalendar = [iCalCalendar parseSingleFromSource: tmpContent]; + tmpComponent = (iCalRepeatableEntityObject *) [tmpCalendar firstChildWithTag: [self componentTag]]; + if (![tmpComponent isPublic]) + { + context = [[WOApplication application] context]; + email = [[context activeUser] email]; + if (!([tmpComponent isOrganizer: email] + || [tmpComponent isParticipant: email])) + { + // content = tmpContent; + [self _filterPrivateComponent: tmpComponent]; + calContent = [tmpCalendar versitString]; + } + } + } + + [calContent retain]; + } + + return calContent; +} + +- (NSException *) saveContentString: (NSString *) contentString + baseVersion: (unsigned int) baseVersion +{ + NSException *result; + + result = [super saveContentString: contentString + baseVersion: baseVersion]; + if (!result && calContent) + { + [calContent release]; + calContent = nil; + } + + return result; +} + - (iCalCalendar *) calendar { NSString *iCalString;