From 4d69440f3da452fccf86d1b7c781c3638bcc474e Mon Sep 17 00:00:00 2001 From: znek Date: Thu, 9 Dec 2004 14:32:53 +0000 Subject: [PATCH] ability to set appointments' accessClass and transparency, in preparation of bugfix for SOGo bug #1052 git-svn-id: http://svn.opengroupware.org/SOGo/trunk@465 d1b88da0-ebda-0310-925b-ed51d893ca5b --- SOGo/UI/Scheduler/ChangeLog | 18 +++ .../Scheduler/English.lproj/default.strings | 2 + SOGo/UI/Scheduler/UIxAppointmentEditor.m | 109 +++++++++++++++--- SOGo/UI/Scheduler/UIxAppointmentEditor.wox | 15 +++ SOGo/UI/Scheduler/Version | 2 +- SOGoLogic/ChangeLog | 14 +++ SOGoLogic/SOGoAppointment.h | 6 + SOGoLogic/SOGoAppointment.m | 66 ++++++++--- SOGoLogic/SOGoAppointmentICalRenderer.m | 11 +- SOGoLogic/Version | 2 +- 10 files changed, 206 insertions(+), 39 deletions(-) diff --git a/SOGo/UI/Scheduler/ChangeLog b/SOGo/UI/Scheduler/ChangeLog index 40dbb69e..1a86657f 100644 --- a/SOGo/UI/Scheduler/ChangeLog +++ b/SOGo/UI/Scheduler/ChangeLog @@ -1,3 +1,21 @@ +2004-12-09 Marcus Mueller + + * v0.9.97 + + * UIxAppointmentEditor.[wox,m]: provided API and UI for marking an + event as being private or public, public being the default. + + * English.lproj/default.strings: provided additional localizable + strings for event "classification" (private/public). + + * UIxAppointmentEditor.m: set 'transparency' of new items to + 'TRANSPARENT' instead of 'OPAQUE'. In agenor FreeBusy information is + constrained by a folder flag instead of individual events, however + the intent is to permit retrieval of FreeBusy information in general. + Please note that the according information isn't properly parsed/set + in loadValues/saveValues as of now - the underlying iCalEvent doesn't + handle this as of now. + 2004-12-08 Marcus Mueller * v0.9.96 diff --git a/SOGo/UI/Scheduler/English.lproj/default.strings b/SOGo/UI/Scheduler/English.lproj/default.strings index ecae51a9..16dc7e64 100644 --- a/SOGo/UI/Scheduler/English.lproj/default.strings +++ b/SOGo/UI/Scheduler/English.lproj/default.strings @@ -99,6 +99,7 @@ "Location" = "Location"; "Priority" = "Priority"; "Categories" = "Categories"; +"Classification" = "Classification"; "Duration" = "Duration"; "Participants" = "Participants"; "Resources" = "Resources"; @@ -107,6 +108,7 @@ "attributes" = "Attributes"; "participants" = "Participants"; +"is private" = "is private"; /* Searching */ diff --git a/SOGo/UI/Scheduler/UIxAppointmentEditor.m b/SOGo/UI/Scheduler/UIxAppointmentEditor.m index 0a3525e8..5f447c5f 100644 --- a/SOGo/UI/Scheduler/UIxAppointmentEditor.m +++ b/SOGo/UI/Scheduler/UIxAppointmentEditor.m @@ -44,11 +44,16 @@ NSArray *resources; /* array of iCalPerson's */ NSString *priority; NSArray *categories; + NSString *accessClass; + BOOL isPrivate; /* default: NO */ } - (NSString *)iCalStringTemplate; - (NSString *)iCalString; +- (void)setIsPrivate:(BOOL)_yn; +- (void)setAccessClass:(NSString *)_class; + - (NSString *)_completeURIForMethod:(NSString *)_method; - (iCalPerson *)getOrganizer; @@ -78,19 +83,29 @@ @implementation UIxAppointmentEditor +- (id)init { + self = [super init]; + if(self) { + [self setIsPrivate:NO]; + } + return self; +} + - (void)dealloc { + [self->iCalString release]; [self->errorText release]; - [self->participants release]; - [self->resources release]; + [self->item release]; + [self->startDate release]; [self->endDate release]; [self->title release]; [self->location release]; [self->comment release]; + [self->participants release]; + [self->resources release]; [self->priority release]; [self->categories release]; - [self->iCalString release]; - [self->item release]; + [self->accessClass release]; [super dealloc]; } @@ -173,8 +188,11 @@ 5 == normal 1 == high */ - return [NSArray arrayWithObjects: - @"0", @"5", @"1", nil]; + static NSArray *priorities = nil; + + if (!priorities) + priorities = [[NSArray arrayWithObjects:@"0", @"5", @"1", nil] retain]; + return priorities; } - (NSString *)itemPriorityText { @@ -205,13 +223,17 @@ – holidays, – phone. */ - return [NSArray arrayWithObjects: - @"APPOINTMENT", - @"NOT IN OFFICE", - @"MEETING", - @"HOLIDAY", - @"PHONE CALL", - nil]; + static NSArray *categoryItems = nil; + + if (!categoryItems) { + categoryItems = [[NSArray arrayWithObjects:@"APPOINTMENT", + @"NOT IN OFFICE", + @"MEETING", + @"HOLIDAY", + @"PHONE CALL", + nil] retain]; + } + return categoryItems; } - (NSString *)itemCategoryText { @@ -225,6 +247,45 @@ return self->categories; } +/* class */ + +#if 0 +- (NSArray *)accessClassItems { + static NSArray classItems = nil; + + if (!classItems) { + return [[NSArray arrayWithObjects:@"PUBLIC", @"PRIVATE", nil] retain]; + } + return classItems; +} +#endif + +- (void)setAccessClass:(NSString *)_class { + ASSIGN(self->accessClass, _class); +} +- (NSString *)accessClass { + return self->accessClass; +} + +- (void)setIsPrivate:(BOOL)_yn { + if (_yn) + [self setAccessClass:@"PRIVATE"]; + else + [self setAccessClass:@"PUBLIC"]; + self->isPrivate = _yn; +} + +- (BOOL)isPrivate { + return self->isPrivate; +} + + +/* transparency */ + +- (NSString *)transparency { + return @"TRANSPARENT"; +} + /* iCal */ @@ -243,12 +304,12 @@ @"VERSION:2.0\r\n" @"BEGIN:VEVENT\r\n" @"UID:%@\r\n" - @"CLASS:PRIVATE\r\n" + @"CLASS:PUBLIC\r\n" @"STATUS:CONFIRMED\r\n" @"DTSTAMP:%@\r\n" @"DTSTART:%@\r\n" @"DTEND:%@\r\n" - @"TRANSP:OPAQUE\r\n" + @"TRANSP:%@\r\n" @"SEQUENCE:1\r\n" @"PRIORITY:5\r\n" @"%@" @@ -276,6 +337,7 @@ [[NSCalendarDate date] icalString], [lStartDate icalString], [lEndDate icalString], + [self transparency], s]; return template; } @@ -456,11 +518,13 @@ } - (void)loadValuesFromAppointment:(SOGoAppointment *)_appointment { + NSString *s; + if ((self->startDate = [[_appointment startDate] copy]) == nil) - self->startDate = [[[[NSCalendarDate date] date] hour:11 minute:0] copy]; - if ((self->endDate = [[_appointment endDate] copy]) == nil) { + self->startDate = [[[NSCalendarDate date] hour:11 minute:0] copy]; + if ((self->endDate = [[_appointment endDate] copy]) == nil) { self->endDate = - [[self->startDate hour:[self->startDate hourOfDay]+1 minute:0] copy]; + [[self->startDate hour:[self->startDate hourOfDay] + 1 minute:0] copy]; } [self->startDate setTimeZone:[self viewTimeZone]]; [self->endDate setTimeZone:[self viewTimeZone]]; @@ -472,6 +536,12 @@ self->categories = [[_appointment categories] retain]; self->participants = [[_appointment participants] retain]; self->resources = [[_appointment resources] retain]; + + s = [_appointment accessClass]; + if(!s || [s isEqualToString:@"PUBLIC"]) + [self setIsPrivate:NO]; + else + [self setIsPrivate:YES]; /* we're possibly loosing information here */ } - (void)saveValuesIntoAppointment:(SOGoAppointment *)_appointment { @@ -487,6 +557,9 @@ [_appointment setPriority:[self priority]]; [_appointment setCategories:[self categories]]; + [_appointment setAccessClass:[self accessClass]]; + [_appointment setTransparency:[self transparency]]; + attendees = [self participants]; lResources = [self resources]; if ([lResources count] > 0) { diff --git a/SOGo/UI/Scheduler/UIxAppointmentEditor.wox b/SOGo/UI/Scheduler/UIxAppointmentEditor.wox index 2d003e34..cc4b2695 100644 --- a/SOGo/UI/Scheduler/UIxAppointmentEditor.wox +++ b/SOGo/UI/Scheduler/UIxAppointmentEditor.wox @@ -132,6 +132,21 @@ + + + + : + + + + + + + + diff --git a/SOGo/UI/Scheduler/Version b/SOGo/UI/Scheduler/Version index c9612d69..64f03077 100644 --- a/SOGo/UI/Scheduler/Version +++ b/SOGo/UI/Scheduler/Version @@ -1,6 +1,6 @@ # $Id$ -SUBMINOR_VERSION:=96 +SUBMINOR_VERSION:=97 # v0.9.96 requires SOGoLogic v0.9.27 # v0.9.94 requires NGExtensions v4.5.136 diff --git a/SOGoLogic/ChangeLog b/SOGoLogic/ChangeLog index eab2500d..2823fc62 100644 --- a/SOGoLogic/ChangeLog +++ b/SOGoLogic/ChangeLog @@ -1,3 +1,17 @@ +2004-12-09 Marcus Mueller + + * v0.9.28 + + * SOGoAppointment.[hm]: added API for accessClass ("CLASS:") and + transparency ("TRANSP:"). While accessClass is properly handled + by the underlying iCalEvent, transparency is not. SOGoAppointment + handles the default cases for agenor currently, so other parts + can rely on this information. + + * SOGoAppointmentICalRenderer.m: removed static assumptions for + accessClass and transparency, changed to query SOGoAppointment + for this information. + 2004-12-08 Marcus Mueller * SOGoAppointment.[hm]: added checks to see whether a given email diff --git a/SOGoLogic/SOGoAppointment.h b/SOGoLogic/SOGoAppointment.h index 6b180202..a45db146 100644 --- a/SOGoLogic/SOGoAppointment.h +++ b/SOGoLogic/SOGoAppointment.h @@ -84,6 +84,12 @@ - (void)setOrganizer:(iCalPerson *)_organizer; - (iCalPerson *)organizer; +- (void)setAccessClass:(NSString *)_value; +- (NSString *)accessClass; + +- (void)setTransparency:(NSString *)_value; +- (NSString *)transparency; + - (void)removeAllAttendees; - (void)addToAttendees:(iCalPerson *)_person; - (void)appendAttendees:(NSArray *)_persons; diff --git a/SOGoLogic/SOGoAppointment.m b/SOGoLogic/SOGoAppointment.m index 80853d14..bcecc698 100644 --- a/SOGoLogic/SOGoAppointment.m +++ b/SOGoLogic/SOGoAppointment.m @@ -27,29 +27,39 @@ #include "SOGoAppointmentICalRenderer.h" #include "common.h" +@interface iCalPerson(UIx_Privates) +- (NSString *)rfc822Email; +@end + @interface SOGoAppointment (PrivateAPI) - (NSArray *)_filteredAttendeesThinkingOfPersons:(BOOL)_persons; @end @implementation SOGoAppointment -static id parser = nil; -static SaxObjectDecoder *sax = nil; +static id parser = nil; +static SaxObjectDecoder *sax = nil; +static NGLogger *logger = nil; + (void)initialize { - if (parser == nil) { - parser = [[[SaxXMLReaderFactory standardXMLReaderFactory] - createXMLReaderForMimeType:@"text/calendar"] - retain]; - if (parser == nil) - NSLog(@"ERROR: did not find a parser for text/calendar!"); - } - if (sax == nil) { - sax = [[SaxObjectDecoder alloc] initWithMappingNamed:@"NGiCal"]; - if (sax == nil) - NSLog(@"ERROR: could not create the iCal SAX handler!"); - } - + NGLoggerManager *lm; + SaxXMLReaderFactory *factory; + static BOOL didInit = NO; + + if (didInit) return; + + lm = [NGLoggerManager defaultLoggerManager]; + logger = [lm loggerForClass:self]; + + factory = [SaxXMLReaderFactory standardXMLReaderFactory]; + parser = [[factory createXMLReaderForMimeType:@"text/calendar"] + retain]; + if (parser == nil) + [logger fatalWithFormat:@"did not find a parser for text/calendar!"]; + sax = [[SaxObjectDecoder alloc] initWithMappingNamed:@"NGiCal"]; + if (sax == nil) + [logger fatalWithFormat:@"could not create the iCal SAX handler!"]; + [parser setContentHandler:sax]; [parser setErrorHandler:sax]; } @@ -260,6 +270,26 @@ static SaxObjectDecoder *sax = nil; return [self->event durationAsTimeInterval]; } +- (void)setAccessClass:(NSString *)_value { + [self->event setAccessClass:_value]; +} +- (NSString *)accessClass { + NSString *s; + + s = [self->event accessClass]; + if(!s) + s = @"PUBLIC"; /* default for agenor */ + return s; +} + +- (void)setTransparency:(NSString *)_value { + [self debugWithFormat:@"transparency currently unsupported by iCalEvent!"]; +} +- (NSString *)transparency { + [self debugWithFormat:@"returning bogus transparency information!"]; + return @"TRANSPARENT"; +} + - (void)setOrganizer:(iCalPerson *)_organizer { [self->event setOrganizer:_organizer]; } @@ -358,4 +388,10 @@ static SaxObjectDecoder *sax = nil; return ms; } +/* logging */ + +- (id)logger { + return logger; +} + @end /* SOGoAppointment */ diff --git a/SOGoLogic/SOGoAppointmentICalRenderer.m b/SOGoLogic/SOGoAppointmentICalRenderer.m index 653e5d28..32e0739d 100644 --- a/SOGoLogic/SOGoAppointmentICalRenderer.m +++ b/SOGoLogic/SOGoAppointmentICalRenderer.m @@ -174,10 +174,13 @@ static unsigned DefaultICalStringCapacity = 1024; [s appendString:[_apt status]]; [s appendString:@"\r\n"]; - - /* what's all this? */ - [s appendString:@"TRANSP:OPAQUE\r\n"]; /* transparency */ - [s appendString:@"CLASS:PRIVATE\r\n"]; /* classification [like 'top secret'] */ + [s appendString:@"TRANSP:"]; + [s appendString:[_apt transparency]]; + [s appendString:@"\r\n"]; + + [s appendString:@"CLASS:"]; + [s appendString:[_apt accessClass]]; + [s appendString:@"\r\n"]; [self addOrganizer:[_apt organizer] toString:s]; [self addAttendees:[_apt attendees] toString:s]; diff --git a/SOGoLogic/Version b/SOGoLogic/Version index d3d84aae..17e30d89 100644 --- a/SOGoLogic/Version +++ b/SOGoLogic/Version @@ -1,6 +1,6 @@ # Version file -SUBMINOR_VERSION:=27 +SUBMINOR_VERSION:=28 # v0.9.26 requires NGExtensions v4.5.136 # v0.9.23 requires NGiCal v4.3.32 -- 2.39.5