Monotone-Parent: 493dd9034b71a42f4fc3df70a482872a7c50cc22
Monotone-Revision: f071f53cbc4a39b0b852c58e7e57332f05ef1e0c Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2012-07-13T20:59:09maint-2.0.2
parent
ee723f9694
commit
6cd17dc9b8
|
@ -1,5 +1,11 @@
|
||||||
2012-07-13 Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
2012-07-13 Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||||
|
|
||||||
|
* SoObjects/Appointments/SOGoAppointmentObject.m
|
||||||
|
(-updateContentWithCalendar:fromRequest:): new method spawned from
|
||||||
|
the previous incarnation of PUTRequest:, designed to centralize
|
||||||
|
all the processed performed on an iCalendar instance, new or
|
||||||
|
derived from the original.
|
||||||
|
|
||||||
* SoObjects/Appointments/SOGoCalendarComponent.m
|
* SoObjects/Appointments/SOGoCalendarComponent.m
|
||||||
(-lookupOccurrence:): now a virtual method forcing the use by
|
(-lookupOccurrence:): now a virtual method forcing the use by
|
||||||
subclasses of the new methods below.
|
subclasses of the new methods below.
|
||||||
|
|
|
@ -28,6 +28,8 @@
|
||||||
@class NSException;
|
@class NSException;
|
||||||
@class NSString;
|
@class NSString;
|
||||||
|
|
||||||
|
@class WORequest;
|
||||||
|
|
||||||
@class iCalEvent;
|
@class iCalEvent;
|
||||||
@class iCalCalendar;
|
@class iCalCalendar;
|
||||||
|
|
||||||
|
@ -49,6 +51,9 @@
|
||||||
- (NSArray *) postCalDAVEventReplyTo: (NSArray *) recipients from: (NSString *) originator;
|
- (NSArray *) postCalDAVEventReplyTo: (NSArray *) recipients from: (NSString *) originator;
|
||||||
- (NSArray *) postCalDAVEventCancelTo: (NSArray *) recipients from: (NSString *) originator;
|
- (NSArray *) postCalDAVEventCancelTo: (NSArray *) recipients from: (NSString *) originator;
|
||||||
|
|
||||||
|
- (NSException *) updateContentWithCalendar: (iCalCalendar *) calendar
|
||||||
|
fromRequest: (WORequest *) rq;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
#endif /* __Appointments_SOGoAppointmentObject_H__ */
|
#endif /* __Appointments_SOGoAppointmentObject_H__ */
|
||||||
|
|
|
@ -188,54 +188,37 @@
|
||||||
SOGoAppointmentObject *attendeeObject;
|
SOGoAppointmentObject *attendeeObject;
|
||||||
NSString *iCalString;
|
NSString *iCalString;
|
||||||
|
|
||||||
|
iCalString = nil;
|
||||||
attendeeObject = [self _lookupEvent: [theEvent uid] forUID: theUID];
|
attendeeObject = [self _lookupEvent: [theEvent uid] forUID: theUID];
|
||||||
|
|
||||||
// We must add an occurence to a non-existing event. We have
|
// We must add an occurence to a non-existing event. We have
|
||||||
// to handle this with care, as in the postCalDAVEventRequestTo:from:
|
// to handle this with care, as in the postCalDAVEventRequestTo:from:
|
||||||
if ([attendeeObject isNew] && [theEvent recurrenceId])
|
if ([attendeeObject isNew] && [theEvent recurrenceId])
|
||||||
{
|
{
|
||||||
SOGoAppointmentObject *ownerObject;
|
|
||||||
NSArray *attendees;
|
|
||||||
iCalEvent *ownerEvent;
|
iCalEvent *ownerEvent;
|
||||||
iCalPerson *person;
|
iCalPerson *person;
|
||||||
SOGoUser *user;
|
SOGoUser *user;
|
||||||
BOOL found;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
// We check if the attendee that was added to a single occurence is
|
// We check if the attendee that was added to a single occurence is
|
||||||
// present in the master component. If not, we add it with a participation
|
// present in the master component. If not, we add it with a participation
|
||||||
// status set to "DECLINED".
|
// status set to "DECLINED".
|
||||||
user = [SOGoUser userWithLogin: theUID];
|
|
||||||
person = [iCalPerson elementWithTag: @"attendee"];
|
|
||||||
[person setCn: [user cn]];
|
|
||||||
[person setEmail: [[user allEmails] objectAtIndex: 0]];
|
|
||||||
[person setParticipationStatus: iCalPersonPartStatDeclined];
|
|
||||||
[person setRsvp: @"TRUE"];
|
|
||||||
[person setRole: @"REQ-PARTICIPANT"];
|
|
||||||
|
|
||||||
ownerObject = [self _lookupEvent: [theEvent uid] forUID: theOwner];
|
|
||||||
ownerEvent = [[[theEvent parent] events] objectAtIndex: 0];
|
ownerEvent = [[[theEvent parent] events] objectAtIndex: 0];
|
||||||
attendees = [ownerEvent attendees];
|
user = [SOGoUser userWithLogin: theUID];
|
||||||
found = NO;
|
if (![ownerEvent userAsAttendee: user])
|
||||||
|
|
||||||
for (i = 0; i < [attendees count]; i++)
|
|
||||||
{
|
|
||||||
if ([[attendees objectAtIndex: i] hasSameEmailAddress: person])
|
|
||||||
{
|
|
||||||
found = YES;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!found)
|
|
||||||
{
|
{
|
||||||
// Update the master event in the owner's calendar with the
|
// Update the master event in the owner's calendar with the
|
||||||
// status of the new attendee set as "DECLINED".
|
// status of the new attendee set as "DECLINED".
|
||||||
|
person = [iCalPerson elementWithTag: @"attendee"];
|
||||||
|
[person setCn: [user cn]];
|
||||||
|
[person setEmail: [[user allEmails] objectAtIndex: 0]];
|
||||||
|
[person setParticipationStatus: iCalPersonPartStatDeclined];
|
||||||
|
[person setRsvp: @"TRUE"];
|
||||||
|
[person setRole: @"REQ-PARTICIPANT"];
|
||||||
[ownerEvent addToAttendees: person];
|
[ownerEvent addToAttendees: person];
|
||||||
iCalString = [[ownerEvent parent] versitString];
|
|
||||||
[ownerObject saveContentString: iCalString];
|
iCalString = [[ownerEvent parent] versitString];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// TODO : if [theEvent recurrenceId], only update this occurrence
|
// TODO : if [theEvent recurrenceId], only update this occurrence
|
||||||
|
@ -249,7 +232,8 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save the event in the attendee's calendar
|
// Save the event in the attendee's calendar
|
||||||
[attendeeObject saveContentString: iCalString];
|
if (iCalString)
|
||||||
|
[attendeeObject saveContentString: iCalString];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -277,7 +261,7 @@
|
||||||
folder = [[SOGoUser userWithLogin: theUID]
|
folder = [[SOGoUser userWithLogin: theUID]
|
||||||
personalCalendarFolderInContext: context];
|
personalCalendarFolderInContext: context];
|
||||||
object = [folder lookupName: nameInContainer
|
object = [folder lookupName: nameInContainer
|
||||||
inContext: context acquire: NO];
|
inContext: context acquire: NO];
|
||||||
if (![object isKindOfClass: [NSException class]])
|
if (![object isKindOfClass: [NSException class]])
|
||||||
{
|
{
|
||||||
if (recurrenceId == nil)
|
if (recurrenceId == nil)
|
||||||
|
@ -458,7 +442,7 @@
|
||||||
NSEnumerator *enumerator;
|
NSEnumerator *enumerator;
|
||||||
NSString *currentUID;
|
NSString *currentUID;
|
||||||
SOGoUser *user;
|
SOGoUser *user;
|
||||||
|
|
||||||
enumerator = [theAttendees objectEnumerator];
|
enumerator = [theAttendees objectEnumerator];
|
||||||
|
|
||||||
while ((currentAttendee = [enumerator nextObject]))
|
while ((currentAttendee = [enumerator nextObject]))
|
||||||
|
@ -654,7 +638,7 @@ inRecurrenceExceptionsForEvent: (iCalEvent *) theEvent
|
||||||
[e addToAttendees: [theAttendees objectAtIndex: j]];
|
[e addToAttendees: [theAttendees objectAtIndex: j]];
|
||||||
else
|
else
|
||||||
[e removeFromAttendees: [theAttendees objectAtIndex: j]];
|
[e removeFromAttendees: [theAttendees objectAtIndex: j]];
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -801,7 +785,7 @@ inRecurrenceExceptionsForEvent: (iCalEvent *) theEvent
|
||||||
SOGoUser *ownerUser;
|
SOGoUser *ownerUser;
|
||||||
NSArray *attendees;
|
NSArray *attendees;
|
||||||
NSException *ex;
|
NSException *ex;
|
||||||
|
|
||||||
[[newEvent parent] setMethod: @""];
|
[[newEvent parent] setMethod: @""];
|
||||||
ownerUser = [SOGoUser userWithLogin: owner];
|
ownerUser = [SOGoUser userWithLogin: owner];
|
||||||
|
|
||||||
|
@ -1026,7 +1010,7 @@ inRecurrenceExceptionsForEvent: (iCalEvent *) theEvent
|
||||||
statusChange: (NSString *) newStatus
|
statusChange: (NSString *) newStatus
|
||||||
inEvent: (iCalEvent *) event
|
inEvent: (iCalEvent *) event
|
||||||
{
|
{
|
||||||
NSString *newContent, *currentStatus, *organizerUID;
|
NSString *currentStatus, *organizerUID;
|
||||||
SOGoUser *ownerUser, *currentUser;
|
SOGoUser *ownerUser, *currentUser;
|
||||||
NSException *ex;
|
NSException *ex;
|
||||||
|
|
||||||
|
@ -1171,14 +1155,18 @@ inRecurrenceExceptionsForEvent: (iCalEvent *) theEvent
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
// We generate the updated iCalendar file and we save it in the database.
|
// We generate the updated iCalendar file and we save it in the database.
|
||||||
// We do this ONLY when using SOGo from the Web interface. Over DAV, it'll
|
// We do this ONLY when using SOGo from the Web interface. Over DAV, it'll
|
||||||
// be handled directly in PUTAction:
|
// be handled directly in PUTAction:
|
||||||
|
|
||||||
if (![context request] || [[context request] handledByDefaultHandler])
|
if (![context request] || [[context request] handledByDefaultHandler])
|
||||||
{
|
{
|
||||||
|
NSString *newContent;
|
||||||
newContent = [[event parent] versitString];
|
newContent = [[event parent] versitString];
|
||||||
ex = [self saveContentString: newContent];
|
ex = [self saveContentString: newContent];
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
// If the current user isn't the organizer of the event
|
// If the current user isn't the organizer of the event
|
||||||
// that has just been updated, we update the event and
|
// that has just been updated, we update the event and
|
||||||
|
@ -1350,7 +1338,8 @@ inRecurrenceExceptionsForEvent: (iCalEvent *) theEvent
|
||||||
ex = nil;
|
ex = nil;
|
||||||
delegatedUser = nil;
|
delegatedUser = nil;
|
||||||
|
|
||||||
calendar = [self calendar: NO secure: NO];
|
calendar = [[self calendar: NO secure: NO] mutableCopy];
|
||||||
|
[calendar autorelease];
|
||||||
if (calendar)
|
if (calendar)
|
||||||
{
|
{
|
||||||
if (_recurrenceId)
|
if (_recurrenceId)
|
||||||
|
@ -1545,11 +1534,9 @@ inRecurrenceExceptionsForEvent: (iCalEvent *) theEvent
|
||||||
return partStats;
|
return partStats;
|
||||||
}
|
}
|
||||||
|
|
||||||
#warning parseSingleFromSource is invoked far too many times: maybe we should use an additional ivar to store the new iCalendar
|
- (void) _setupResponseInRequestCalendar: (iCalCalendar *) rqCalendar
|
||||||
- (void) _setupResponseCalendarInRequest: (WORequest *) rq
|
|
||||||
{
|
{
|
||||||
iCalCalendar *calendar, *putCalendar;
|
iCalCalendar *calendar;
|
||||||
NSData *newContent;
|
|
||||||
NSArray *keys;
|
NSArray *keys;
|
||||||
NSDictionary *partStats, *newPartStats;
|
NSDictionary *partStats, *newPartStats;
|
||||||
NSString *partStat, *key;
|
NSString *partStat, *key;
|
||||||
|
@ -1561,8 +1548,7 @@ inRecurrenceExceptionsForEvent: (iCalEvent *) theEvent
|
||||||
max = [keys count];
|
max = [keys count];
|
||||||
if (max > 0)
|
if (max > 0)
|
||||||
{
|
{
|
||||||
putCalendar = [iCalCalendar parseSingleFromSource: [rq contentAsString]];
|
newPartStats = [self _partStatsFromCalendar: rqCalendar];
|
||||||
newPartStats = [self _partStatsFromCalendar: putCalendar];
|
|
||||||
if ([keys isEqualToArray: [newPartStats allKeys]])
|
if ([keys isEqualToArray: [newPartStats allKeys]])
|
||||||
{
|
{
|
||||||
for (count = 0; count < max; count++)
|
for (count = 0; count < max; count++)
|
||||||
|
@ -1573,37 +1559,23 @@ inRecurrenceExceptionsForEvent: (iCalEvent *) theEvent
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
newContent = [[calendar versitString]
|
|
||||||
dataUsingEncoding: [rq contentEncoding]];
|
|
||||||
[rq setContent: newContent];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) _adjustTransparencyInRequest: (WORequest *) rq
|
- (void) _adjustTransparencyInRequestCalendar: (iCalCalendar *) rqCalendar
|
||||||
{
|
{
|
||||||
iCalCalendar *calendar;
|
|
||||||
NSArray *allEvents;
|
NSArray *allEvents;
|
||||||
iCalEvent *event;
|
iCalEvent *event;
|
||||||
int i;
|
int i;
|
||||||
BOOL modified;
|
|
||||||
|
|
||||||
calendar = [iCalCalendar parseSingleFromSource: [rq contentAsString]];
|
allEvents = [rqCalendar events];
|
||||||
allEvents = [calendar events];
|
|
||||||
modified = NO;
|
|
||||||
|
|
||||||
for (i = 0; i < [allEvents count]; i++)
|
for (i = 0; i < [allEvents count]; i++)
|
||||||
{
|
{
|
||||||
event = [allEvents objectAtIndex: i];
|
event = [allEvents objectAtIndex: i];
|
||||||
|
|
||||||
if ([event isAllDay] && [event isOpaque])
|
if ([event isAllDay] && [event isOpaque])
|
||||||
{
|
{
|
||||||
[event setTransparency: @"TRANSPARENT"];
|
[event setTransparency: @"TRANSPARENT"];
|
||||||
modified = YES;
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (modified)
|
|
||||||
[rq setContent: [[calendar versitString] dataUsingEncoding: [rq contentEncoding]]];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1611,17 +1583,13 @@ inRecurrenceExceptionsForEvent: (iCalEvent *) theEvent
|
||||||
* Currently only check if the events have an end date or a duration.
|
* Currently only check if the events have an end date or a duration.
|
||||||
* @param rq the HTTP PUT request
|
* @param rq the HTTP PUT request
|
||||||
*/
|
*/
|
||||||
- (void) _adjustEventsInRequest: (WORequest *) rq
|
- (void) _adjustEventsInRequestCalendar: (iCalCalendar *) rqCalendar
|
||||||
{
|
{
|
||||||
iCalCalendar *calendar;
|
|
||||||
NSArray *allEvents;
|
NSArray *allEvents;
|
||||||
iCalEvent *event;
|
iCalEvent *event;
|
||||||
NSUInteger i;
|
NSUInteger i;
|
||||||
BOOL modified;
|
|
||||||
|
|
||||||
calendar = [iCalCalendar parseSingleFromSource: [rq contentAsString]];
|
allEvents = [rqCalendar events];
|
||||||
allEvents = [calendar events];
|
|
||||||
modified = NO;
|
|
||||||
|
|
||||||
for (i = 0; i < [allEvents count]; i++)
|
for (i = 0; i < [allEvents count]; i++)
|
||||||
{
|
{
|
||||||
|
@ -1634,28 +1602,16 @@ inRecurrenceExceptionsForEvent: (iCalEvent *) theEvent
|
||||||
[event setDuration: @"P1D"];
|
[event setDuration: @"P1D"];
|
||||||
else
|
else
|
||||||
[event setDuration: @"PT1H"];
|
[event setDuration: @"PT1H"];
|
||||||
|
[self warnWithFormat: @"Invalid event: no end date; setting duration to %@", [event duration]];
|
||||||
modified = YES;
|
|
||||||
[self errorWithFormat: @"Invalid event: no end date; setting duration to %@", [event duration]];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (modified)
|
|
||||||
[rq setContent: [[calendar versitString] dataUsingEncoding: [rq contentEncoding]]];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) _decomposeGroupsInRequest: (WORequest *) rq
|
- (void) _decomposeGroupsInRequestCalendar: (iCalCalendar *) rqCalendar
|
||||||
{
|
{
|
||||||
iCalCalendar *calendar;
|
|
||||||
NSArray *allEvents;
|
NSArray *allEvents;
|
||||||
iCalEvent *event;
|
iCalEvent *event;
|
||||||
int i;
|
int i;
|
||||||
BOOL modified;
|
|
||||||
|
|
||||||
// If we decomposed at least one group, let's rewrite the content
|
|
||||||
// of the request. Otherwise, leave it as is in case this rewrite
|
|
||||||
// isn't totaly lossless.
|
|
||||||
calendar = [iCalCalendar parseSingleFromSource: [rq contentAsString]];
|
|
||||||
|
|
||||||
// The algorithm is pretty straightforward:
|
// The algorithm is pretty straightforward:
|
||||||
//
|
//
|
||||||
|
@ -1664,20 +1620,12 @@ inRecurrenceExceptionsForEvent: (iCalEvent *) theEvent
|
||||||
// If some are groups, we decompose them
|
// If some are groups, we decompose them
|
||||||
// We regenerate the iCalendar string
|
// We regenerate the iCalendar string
|
||||||
//
|
//
|
||||||
allEvents = [calendar events];
|
allEvents = [rqCalendar events];
|
||||||
modified = NO;
|
|
||||||
|
|
||||||
for (i = 0; i < [allEvents count]; i++)
|
for (i = 0; i < [allEvents count]; i++)
|
||||||
{
|
{
|
||||||
event = [allEvents objectAtIndex: i];
|
event = [allEvents objectAtIndex: i];
|
||||||
modified |= [self expandGroupsInEvent: event];
|
[self expandGroupsInEvent: event];
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we decomposed at least one group, let's rewrite the content
|
|
||||||
// of the request. Otherwise, leave it as is in case this rewrite
|
|
||||||
// isn't totaly lossless.
|
|
||||||
if (modified)
|
|
||||||
[rq setContent: [[calendar versitString] dataUsingEncoding: [rq contentEncoding]]];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1741,25 +1689,28 @@ inRecurrenceExceptionsForEvent: (iCalEvent *) theEvent
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// If we see "X-SOGo: NoGroupsDecomposition" in the HTTP headers, we
|
// This method is meant to be the common point of any save operation from web
|
||||||
// simply invoke super's PUTAction.
|
// and DAV requests, as well as from code making use of SOGo as a library
|
||||||
|
// (OpenChange)
|
||||||
//
|
//
|
||||||
// We also check if we must force transparency on all day events
|
- (NSException *) updateContentWithCalendar: (iCalCalendar *) calendar
|
||||||
// from iPhone clients.
|
fromRequest: (WORequest *) rq
|
||||||
//
|
|
||||||
- (id) PUTAction: (WOContext *) _ctx
|
|
||||||
{
|
{
|
||||||
NSException *ex;
|
NSException *ex;
|
||||||
NSString *etag;
|
|
||||||
NSArray *roles;
|
NSArray *roles;
|
||||||
WORequest *rq;
|
SOGoUser *ownerUser;
|
||||||
id response;
|
|
||||||
|
|
||||||
unsigned int baseVersion;
|
if (calendar == fullCalendar
|
||||||
|
|| calendar == safeCalendar
|
||||||
|
|| calendar == originalCalendar)
|
||||||
|
[NSException raise: NSInvalidArgumentException
|
||||||
|
format: @"the 'calendar' argument must be a distinct instance"
|
||||||
|
@" from the original object"];
|
||||||
|
|
||||||
rq = [_ctx request];
|
ownerUser = [SOGoUser userWithLogin: owner];
|
||||||
roles = [[context activeUser] rolesForObject: self inContext: context];
|
|
||||||
|
|
||||||
|
roles = [[context activeUser] rolesForObject: self
|
||||||
|
inContext: context];
|
||||||
//
|
//
|
||||||
// We check if we gave only the "Respond To" right and someone is actually
|
// We check if we gave only the "Respond To" right and someone is actually
|
||||||
// responding to one of our invitation. In this case, _setupResponseCalendarInRequest
|
// responding to one of our invitation. In this case, _setupResponseCalendarInRequest
|
||||||
|
@ -1767,24 +1718,20 @@ inRecurrenceExceptionsForEvent: (iCalEvent *) theEvent
|
||||||
//
|
//
|
||||||
if ([roles containsObject: @"ComponentResponder"]
|
if ([roles containsObject: @"ComponentResponder"]
|
||||||
&& ![roles containsObject: @"ComponentModifier"])
|
&& ![roles containsObject: @"ComponentModifier"])
|
||||||
[self _setupResponseCalendarInRequest: rq];
|
[self _setupResponseInRequestCalendar: calendar];
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SOGoUser *user;
|
|
||||||
|
|
||||||
user = [SOGoUser userWithLogin: owner];
|
|
||||||
|
|
||||||
if (![[rq headersForKey: @"X-SOGo"]
|
if (![[rq headersForKey: @"X-SOGo"]
|
||||||
containsObject: @"NoGroupsDecomposition"])
|
containsObject: @"NoGroupsDecomposition"])
|
||||||
[self _decomposeGroupsInRequest: rq];
|
[self _decomposeGroupsInRequestCalendar: calendar];
|
||||||
|
|
||||||
if ([[user domainDefaults] iPhoneForceAllDayTransparency]
|
if ([[ownerUser domainDefaults] iPhoneForceAllDayTransparency]
|
||||||
&& [rq isIPhone])
|
&& [rq isIPhone])
|
||||||
{
|
{
|
||||||
[self _adjustTransparencyInRequest: rq];
|
[self _adjustTransparencyInRequestCalendar: calendar];
|
||||||
}
|
}
|
||||||
|
|
||||||
[self _adjustEventsInRequest: rq];
|
[self _adjustEventsInRequestCalendar: calendar];
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -1792,25 +1739,20 @@ inRecurrenceExceptionsForEvent: (iCalEvent *) theEvent
|
||||||
//
|
//
|
||||||
if ([self isNew])
|
if ([self isNew])
|
||||||
{
|
{
|
||||||
iCalCalendar *calendar;
|
iCalEvent *event;
|
||||||
SOGoUser *ownerUser;
|
|
||||||
iCalEvent *event, *conflictingEvent;
|
|
||||||
NSArray *attendees;
|
NSArray *attendees;
|
||||||
|
|
||||||
NSString *eventUID;
|
NSString *eventUID;
|
||||||
BOOL scheduling;
|
BOOL scheduling;
|
||||||
|
|
||||||
calendar = [iCalCalendar parseSingleFromSource: [rq contentAsString]];
|
|
||||||
attendees = nil;
|
attendees = nil;
|
||||||
|
|
||||||
event = [[calendar events] objectAtIndex: 0];
|
event = [[calendar events] objectAtIndex: 0];
|
||||||
eventUID = [event uid];
|
eventUID = [event uid];
|
||||||
ownerUser = [SOGoUser userWithLogin: owner];
|
|
||||||
scheduling = [self _shouldScheduleEvent: [event organizer]];
|
scheduling = [self _shouldScheduleEvent: [event organizer]];
|
||||||
|
|
||||||
// make sure eventUID doesn't conflict with an existing event - see bug #1853
|
// make sure eventUID doesn't conflict with an existing event - see bug #1853
|
||||||
// TODO: send out a no-uid-conflict (DAV:href) xml element (rfc4791 section 5.3.2.1)
|
// TODO: send out a no-uid-conflict (DAV:href) xml element (rfc4791 section 5.3.2.1)
|
||||||
if (conflictingEvent = [container resourceNameForEventUID: eventUID])
|
if ([container resourceNameForEventUID: eventUID])
|
||||||
{
|
{
|
||||||
return [NSException exceptionWithHTTPStatus: 403
|
return [NSException exceptionWithHTTPStatus: 403
|
||||||
reason: [NSString stringWithFormat: @"Event UID already in use. (%s)", eventUID]];
|
reason: [NSString stringWithFormat: @"Event UID already in use. (%s)", eventUID]];
|
||||||
|
@ -1862,33 +1804,21 @@ inRecurrenceExceptionsForEvent: (iCalEvent *) theEvent
|
||||||
} // if ([self isNew])
|
} // if ([self isNew])
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
iCalCalendar *oldCalendar, *newCalendar;
|
iCalCalendar *oldCalendar;
|
||||||
iCalEvent *oldEvent, *newEvent;
|
iCalEvent *oldEvent, *newEvent;
|
||||||
iCalEventChanges *changes;
|
iCalEventChanges *changes;
|
||||||
NSMutableArray *oldEvents, *newEvents;
|
NSArray *oldEvents, *newEvents;
|
||||||
NSCalendarDate *recurrenceId;
|
NSCalendarDate *recurrenceId;
|
||||||
NSException *error;
|
|
||||||
BOOL master;
|
BOOL master;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
//
|
|
||||||
// We must check for etag changes prior doing anything since an attendee could
|
|
||||||
// have changed its participation status and the organizer didn't get the
|
|
||||||
// copy and is trying to do a modification to the event.
|
|
||||||
//
|
|
||||||
error = [self matchesRequestConditionInContext: _ctx];
|
|
||||||
|
|
||||||
if (error)
|
|
||||||
return (WOResponse *)error;
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// We check what has changed in the event and react accordingly.
|
// We check what has changed in the event and react accordingly.
|
||||||
//
|
//
|
||||||
newCalendar = [iCalCalendar parseSingleFromSource: [rq contentAsString]];
|
newEvents = [calendar events];
|
||||||
newEvents = [NSMutableArray arrayWithArray: [newCalendar events]];
|
|
||||||
|
|
||||||
oldCalendar = [self calendar: NO secure: NO];
|
oldCalendar = [self calendar: NO secure: NO];
|
||||||
oldEvents = [NSMutableArray arrayWithArray: [oldCalendar events]];
|
oldEvents = [oldCalendar events];
|
||||||
recurrenceId = nil;
|
recurrenceId = nil;
|
||||||
master = NO;
|
master = NO;
|
||||||
|
|
||||||
|
@ -1921,8 +1851,8 @@ inRecurrenceExceptionsForEvent: (iCalEvent *) theEvent
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
[newEvents removeObject: oldEvent];
|
[calendar removeChild: oldEvent];
|
||||||
[oldEvents removeObject: newEvent];
|
[oldCalendar removeChild: newEvent];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1991,13 +1921,6 @@ inRecurrenceExceptionsForEvent: (iCalEvent *) theEvent
|
||||||
{
|
{
|
||||||
if ((ex = [self _handleUpdatedEvent: newEvent fromOldEvent: oldEvent]))
|
if ((ex = [self _handleUpdatedEvent: newEvent fromOldEvent: oldEvent]))
|
||||||
return ex;
|
return ex;
|
||||||
else
|
|
||||||
{
|
|
||||||
// We might have auto-accepted resources here. If that's the
|
|
||||||
// case, let's regenerate the versitstring and replace the
|
|
||||||
// one from the request.
|
|
||||||
[rq setContent: [[[newEvent parent] versitString] dataUsingEncoding: [rq contentEncoding]]];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
// else => attendee is responding
|
// else => attendee is responding
|
||||||
|
@ -2068,23 +1991,57 @@ inRecurrenceExceptionsForEvent: (iCalEvent *) theEvent
|
||||||
}
|
}
|
||||||
} // else of if (isNew) ...
|
} // else of if (isNew) ...
|
||||||
|
|
||||||
|
unsigned int baseVersion;
|
||||||
// We must NOT invoke [super PUTAction:] here as it'll resave
|
// We must NOT invoke [super PUTAction:] here as it'll resave
|
||||||
// the content string and we could have etag mismatches.
|
// the content string and we could have etag mismatches.
|
||||||
response = [_ctx response];
|
|
||||||
|
|
||||||
baseVersion = (isNew ? 0 : version);
|
baseVersion = (isNew ? 0 : version);
|
||||||
|
|
||||||
ex = [self saveContentString: [rq contentAsString]
|
ex = [self saveContentString: [calendar versitString]
|
||||||
baseVersion: baseVersion];
|
baseVersion: baseVersion];
|
||||||
|
|
||||||
|
return ex;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// If we see "X-SOGo: NoGroupsDecomposition" in the HTTP headers, we
|
||||||
|
// simply invoke super's PUTAction.
|
||||||
|
//
|
||||||
|
// We also check if we must force transparency on all day events
|
||||||
|
// from iPhone clients.
|
||||||
|
//
|
||||||
|
- (id) PUTAction: (WOContext *) _ctx
|
||||||
|
{
|
||||||
|
NSException *ex;
|
||||||
|
NSString *etag;
|
||||||
|
WORequest *rq;
|
||||||
|
WOResponse *response;
|
||||||
|
iCalCalendar *rqCalendar;
|
||||||
|
|
||||||
|
rq = [_ctx request];
|
||||||
|
rqCalendar = [iCalCalendar parseSingleFromSource: [rq contentAsString]];
|
||||||
|
|
||||||
|
if (![self isNew])
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// We must check for etag changes prior doing anything since an attendee could
|
||||||
|
// have changed its participation status and the organizer didn't get the
|
||||||
|
// copy and is trying to do a modification to the event.
|
||||||
|
//
|
||||||
|
ex = [self matchesRequestConditionInContext: context];
|
||||||
|
if (ex)
|
||||||
|
return ex;
|
||||||
|
}
|
||||||
|
|
||||||
|
ex = [self updateContentWithCalendar: rqCalendar fromRequest: rq];
|
||||||
if (ex)
|
if (ex)
|
||||||
response = (WOResponse *) ex;
|
response = (WOResponse *) ex;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
response = [_ctx response];
|
||||||
if (isNew)
|
if (isNew)
|
||||||
[response setStatus: 201 /* Created */];
|
[response setStatus: 201 /* Created */];
|
||||||
else
|
else
|
||||||
[response setStatus: 204 /* No Content */];
|
[response setStatus: 204 /* No Content */];
|
||||||
|
|
||||||
etag = [self davEntityTag];
|
etag = [self davEntityTag];
|
||||||
if (etag)
|
if (etag)
|
||||||
[response setHeader: etag forKey: @"etag"];
|
[response setHeader: etag forKey: @"etag"];
|
||||||
|
|
Loading…
Reference in New Issue