From cbc9ffe3f4fa34107db3fd6c6058d4f7c595d4ed Mon Sep 17 00:00:00 2001 From: znek Date: Wed, 25 Aug 2004 11:53:11 +0000 Subject: [PATCH] finished proposal's edit git-svn-id: http://svn.opengroupware.org/SOGo/trunk@266 d1b88da0-ebda-0310-925b-ed51d893ca5b --- SOGo/UI/Scheduler/ChangeLog | 10 ++++ SOGo/UI/Scheduler/UIxAppointmentEditor.m | 65 +++++++++++++++++++++- SOGo/UI/Scheduler/UIxAppointmentProposal.m | 22 +++++++- SOGo/UI/Scheduler/Version | 2 +- 4 files changed, 94 insertions(+), 5 deletions(-) diff --git a/SOGo/UI/Scheduler/ChangeLog b/SOGo/UI/Scheduler/ChangeLog index 5885bd30..7db31e9e 100644 --- a/SOGo/UI/Scheduler/ChangeLog +++ b/SOGo/UI/Scheduler/ChangeLog @@ -1,3 +1,13 @@ +2004-08-25 Marcus Mueller + + * v0.9.69 + + * UIxAppointmentProposal.m: completed edit functionality. Resources and + participants are now passed as query parameters. + + * UIxAppointmentEditor.m: Resources and Participants are now properly + constructed from existing query parameters. + 2004-08-24 Marcus Mueller * v0.9.68 diff --git a/SOGo/UI/Scheduler/UIxAppointmentEditor.m b/SOGo/UI/Scheduler/UIxAppointmentEditor.m index d06a662e..f27a0fe4 100644 --- a/SOGo/UI/Scheduler/UIxAppointmentEditor.m +++ b/SOGo/UI/Scheduler/UIxAppointmentEditor.m @@ -53,6 +53,11 @@ - (NSArray *)getICalPersonsFromFormValues:(NSArray *)_values treatAsResource:(BOOL)_isResource; +- (NSString *)iCalParticipantsAndResourcesStringFromQueryParameters; +- (NSString *)iCalParticipantsStringFromQueryParameters; +- (NSString *)iCalResourcesStringFromQueryParameters; +- (NSString *)iCalStringFromQueryParameter:(NSString *)_qp + format:(NSString *)_format; @end #include "common.h" @@ -179,8 +184,10 @@ @"DTEND:%@\n" @"TRANSP:OPAQUE\n" @"SEQUENCE:1\n" + @"%@" @"END:VEVENT\n" @"END:VCALENDAR"; + NSCalendarDate *lStartDate, *lEndDate; NSString *template, *s; unsigned minutes; @@ -192,19 +199,71 @@ else { minutes = 60; } - lStartDate = [self selectedDate]; lEndDate = [lStartDate dateByAddingYears:0 months:0 days:0 - hours:0 minutes:minutes seconds:0]; + hours:0 minutes:minutes seconds:0]; + s = [self iCalParticipantsAndResourcesStringFromQueryParameters]; template = [NSString stringWithFormat:iCalStringTemplate, [[self clientObject] nameInContainer], [[NSCalendarDate date] icalString], [lStartDate icalString], - [lEndDate icalString]]; + [lEndDate icalString], + s]; return template; } +- (NSString *)iCalParticipantsAndResourcesStringFromQueryParameters { + NSString *s; + + s = [self iCalParticipantsStringFromQueryParameters]; + return [s stringByAppendingString: + [self iCalResourcesStringFromQueryParameters]]; +} + +- (NSString *)iCalParticipantsStringFromQueryParameters { + static NSString *iCalParticipantString = \ + @"ATTENDEE;ROLE=REQ-PARTICIPANT;CN=\"%@\":mailto:%@\n"; + + return [self iCalStringFromQueryParameter:@"ps" + format:iCalParticipantString]; +} + +- (NSString *)iCalResourcesStringFromQueryParameters { + static NSString *iCalResourceString = \ + @"ATTENDEE;ROLE=NON-PARTICIPANT;CN=\"%@\":mailto:%@\n"; + + return [self iCalStringFromQueryParameter:@"rs" + format:iCalResourceString]; +} + +- (NSString *)iCalStringFromQueryParameter:(NSString *)_qp + format:(NSString *)_format +{ + AgenorUserManager *um; + NSMutableString *iCalRep; + NSString *s; + + um = [AgenorUserManager sharedUserManager]; + iCalRep = (NSMutableString *)[NSMutableString string]; + s = [self queryParameterForKey:_qp]; + if(s && [s length] > 0) { + NSArray *es; + unsigned i, count; + + es = [s componentsSeparatedByString:@","]; + count = [es count]; + for(i = 0; i < count; i++) { + NSString *email, *cn; + + email = [es objectAtIndex:i]; + cn = [um getCNForUID:[um getUIDForEmail:email]]; + [iCalRep appendFormat:_format, cn, email]; + } + } + return iCalRep; +} + /* helper */ - (NSString *)_completeURIForMethod:(NSString *)_method { diff --git a/SOGo/UI/Scheduler/UIxAppointmentProposal.m b/SOGo/UI/Scheduler/UIxAppointmentProposal.m index 47bd022f..99858480 100644 --- a/SOGo/UI/Scheduler/UIxAppointmentProposal.m +++ b/SOGo/UI/Scheduler/UIxAppointmentProposal.m @@ -50,10 +50,13 @@ - (NSMutableDictionary *)currentQueryParameters; - (NSDictionary *)currentHourQueryParametersForFirstHalf:(BOOL)_first; + +- (void)setICalPersons:(NSArray *)_ps asQueryParameter:(NSString *)_qp; @end #include #include +#include "iCalPerson+UIx.h" #include "common.h" @implementation UIxAppointmentProposal @@ -430,11 +433,28 @@ if(!self->currentQueryParameters) { self->currentQueryParameters = [[self queryParameters] mutableCopy]; [self->currentQueryParameters setObject:[self duration] forKey:@"dur"]; - // TODO: add participants + [self setICalPersons:[self resources] asQueryParameter:@"rs"]; + [self setICalPersons:[self participants] asQueryParameter:@"ps"]; } return self->currentQueryParameters; } +- (void)setICalPersons:(NSArray *)_ps asQueryParameter:(NSString *)_qp { + NSMutableString *s; + unsigned i, count; + + s = [[NSMutableString alloc] init]; + count = [_ps count]; + for(i = 0; i < count; i++) { + iCalPerson *p = [_ps objectAtIndex:i]; + [s appendString:[p rfc822Email]]; + if(i != (count - 1)) + [s appendString:@","]; + } + [[self currentQueryParameters] setObject:s forKey:_qp]; + [s release]; +} + - (NSDictionary *)currentHourQueryParametersForFirstHalf:(BOOL)_first { NSMutableDictionary *qp; NSString *hmString; diff --git a/SOGo/UI/Scheduler/Version b/SOGo/UI/Scheduler/Version index e5294622..daa21696 100644 --- a/SOGo/UI/Scheduler/Version +++ b/SOGo/UI/Scheduler/Version @@ -1,6 +1,6 @@ # $Id$ -SUBMINOR_VERSION:=68 +SUBMINOR_VERSION:=69 # v0.9.67 requires SOPE 4.3 # v0.9.61 requires libNGExtensions v4.2.102 -- 2.39.5