Monotone-Parent: 35af78ab6487909f71c8663f60be09f9c1055a75

Monotone-Revision: 602ce15244a3cf50b41b2c16feb1c88a2d9bcc37

Monotone-Author: wsourdeau@inverse.ca
Monotone-Date: 2008-06-30T20:18:32
Monotone-Branch: ca.inverse.sogo
This commit is contained in:
Wolfgang Sourdeau
2008-06-30 20:18:32 +00:00
parent 44b95d362a
commit 83014e4b53
2 changed files with 87 additions and 16 deletions

View File

@@ -1,5 +1,10 @@
2008-06-30 Wolfgang Sourdeau <wsourdeau@inverse.ca>
* SoObjects/Appointments/SOGoAppointmentFolder.m
([SOGoAppointmentFolder
-caldavEventRequest:eventfrom:originatorto:recipients]): handle
caldav replies.
* SoObjects/Appointments/SOGoUserFolder+Appointments.m ([SOGoUserFolder -davCalendarHomeSet])
([SOGoUserFolder -davCalendarScheduleInboxURL])
([SOGoUserFolder -davCalendarScheduleOutboxURL])

View File

@@ -63,6 +63,7 @@
#import <SOGo/SOGoUser.h>
#import <SOGo/SOGoUserFolder.h>
#import <SOGo/SOGoWebDAVAclManager.h>
#import <SoObjects/SOGo/iCalEntityObject+Utilities.h>
#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;