From 83014e4b5307bb2472c4079f23fc18ee7162c9f9 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Mon, 30 Jun 2008 20:18:32 +0000 Subject: [PATCH] Monotone-Parent: 35af78ab6487909f71c8663f60be09f9c1055a75 Monotone-Revision: 602ce15244a3cf50b41b2c16feb1c88a2d9bcc37 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2008-06-30T20:18:32 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 5 + .../Appointments/SOGoAppointmentFolder.m | 98 ++++++++++++++++--- 2 files changed, 87 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index b876f4ae6..caeec1b2e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2008-06-30 Wolfgang Sourdeau + * SoObjects/Appointments/SOGoAppointmentFolder.m + ([SOGoAppointmentFolder + -caldavEventRequest:eventfrom:originatorto:recipients]): handle + caldav replies. + * SoObjects/Appointments/SOGoUserFolder+Appointments.m ([SOGoUserFolder -davCalendarHomeSet]) ([SOGoUserFolder -davCalendarScheduleInboxURL]) ([SOGoUserFolder -davCalendarScheduleOutboxURL]) diff --git a/SoObjects/Appointments/SOGoAppointmentFolder.m b/SoObjects/Appointments/SOGoAppointmentFolder.m index 591ecbe0f..346f9ce1e 100644 --- a/SoObjects/Appointments/SOGoAppointmentFolder.m +++ b/SoObjects/Appointments/SOGoAppointmentFolder.m @@ -63,6 +63,7 @@ #import #import #import +#import #import "SOGoAppointmentObject.h" #import "SOGoAppointmentFolders.h" @@ -1717,10 +1718,15 @@ _selectorForProperty (NSString *property) return responseElement; } -- (void) _saveCalDAVEvent: (iCalEvent *) event +- (NSDictionary *) _postCalDAVEventRequest: (iCalEvent *) event + to: (NSArray *) recipients { NSString *filename, *iCalString; SOGoAppointmentObject *apt; + NSDictionary *responseElement; + NSMutableArray *elements, *content; + NSString *recipient; + unsigned int count, max; filename = [NSString stringWithFormat: @"%@.ics", [event uid]]; apt = [self lookupName: filename inContext: context acquire: NO]; @@ -1730,19 +1736,8 @@ _selectorForProperty (NSString *property) apt = [self _createChildComponentWithName: filename andContent: iCalString]; } +#warning cleanup: add a method to POST requests from CalDAV from SOGoAppointmentObject [apt saveComponent: event]; -} - -- (NSDictionary *) caldavEventRequest: (iCalEvent *) event - from: (NSString *) originator - to: (NSArray *) recipients -{ - NSDictionary *responseElement; - NSMutableArray *elements, *content; - NSString *recipient; - unsigned int count, max; - - [self _saveCalDAVEvent: event]; elements = [NSMutableArray new]; max = [recipients count]; @@ -1751,10 +1746,13 @@ _selectorForProperty (NSString *property) /* this is a fake success status */ recipient = [recipients objectAtIndex: count]; content = [NSMutableArray new]; - [content addObject: davElementWithContent (@"recipient", XMLNS_CALDAV, recipient)]; - [content addObject: davElementWithContent (@"request-status", XMLNS_CALDAV, + [content addObject: davElementWithContent (@"recipient", XMLNS_CALDAV, + recipient)]; + [content addObject: davElementWithContent (@"request-status", + XMLNS_CALDAV, @"2.0;Success")]; - [elements addObject: davElementWithContent (@"response", XMLNS_CALDAV, content)]; + [elements addObject: davElementWithContent (@"response", XMLNS_CALDAV, + content)]; [content release]; } @@ -1765,6 +1763,74 @@ _selectorForProperty (NSString *property) return responseElement; } +- (NSDictionary *) _postCalDAVEventReply: (iCalEvent *) event + from: (NSString *) originator +{ + NSDictionary *responseElement, *attendeeCode; + NSMutableArray *content; + NSString *filename; + iCalPerson *attendee; + NSException *ex; + SOGoAppointmentObject *apt; + + /* this is a fake success status */ + filename = [NSString stringWithFormat: @"%@.ics", [event uid]]; + apt = [self lookupName: filename inContext: context acquire: NO]; + if ([apt isKindOfClass: [SOGoAppointmentObject class]]) + { + content = [NSMutableArray new]; + [content addObject: davElementWithContent (@"recipient", XMLNS_CALDAV, + originator)]; + +#warning cleanup: add a method to POST replies from CalDAV from SOGoAppointmentObject + attendee = [event findParticipant: [context activeUser]]; + if (attendee) + { + ex = [apt changeParticipationStatus: [attendee partStat]]; + if (ex) + attendeeCode = davElementWithContent (@"request-status", XMLNS_CALDAV, + @"3.1;Invalid property value"); + else + attendeeCode = davElementWithContent (@"request-status", XMLNS_CALDAV, + @"2.0;Success"); + } + else + attendeeCode = davElementWithContent (@"request-status", XMLNS_CALDAV, + @"3.7;Invalid Calendar User"); + [content addObject: attendeeCode]; + + responseElement + = davElementWithContent (@"schedule-response", XMLNS_CALDAV, + davElementWithContent (@"response", XMLNS_CALDAV, + content)); + [content release]; + } + else + responseElement = nil; + + return responseElement; +} + +- (NSDictionary *) caldavEventRequest: (iCalEvent *) event + from: (NSString *) originator + to: (NSArray *) recipients +{ + NSDictionary *responseElement; + NSString *method; + + method = [[event parent] method]; + if ([method isEqualToString: @"REQUEST"]) + responseElement = [self _postCalDAVEventRequest: event + to: recipients]; + else if ([method isEqualToString: @"REPLY"]) + responseElement = [self _postCalDAVEventReply: event + from: originator]; + else + responseElement = nil; + + return responseElement; +} + - (WOResponse *) _caldavScheduleResponse: (NSDictionary *) tags { WOResponse *response;