From 6a211407f7360793795ca408ff642ee127d4a939 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Sun, 18 Mar 2007 15:10:03 +0000 Subject: [PATCH] Monotone-Parent: affe7d2d4111c2a72ec7f3cb14b36af674fcc41c Monotone-Revision: a69abbeb98d87b2c2133114138ad7fa46a7b220d Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2007-03-18T15:10:03 Monotone-Branch: ca.inverse.sogo --- .../Appointments/SOGoAppointmentObject.m | 57 +++++++++---------- SoObjects/Appointments/SOGoTaskObject.m | 4 +- 2 files changed, 28 insertions(+), 33 deletions(-) diff --git a/SoObjects/Appointments/SOGoAppointmentObject.m b/SoObjects/Appointments/SOGoAppointmentObject.m index e2ce7232c..4fbebbdb0 100644 --- a/SoObjects/Appointments/SOGoAppointmentObject.m +++ b/SoObjects/Appointments/SOGoAppointmentObject.m @@ -208,7 +208,6 @@ - send iMIP mail for all folders not found */ AgenorUserManager *um; - iCalCalendar *newCalendar; iCalEvent *oldApt, *newApt; iCalEventChanges *changes; iCalPerson *organizer; @@ -220,10 +219,9 @@ updateForcesReconsider = NO; - if ([_iCal length] == 0) { - return [NSException exceptionWithHTTPStatus:400 /* Bad Request */ - reason:@"got no iCalendar content to store!"]; - } + if ([_iCal length] == 0) + return [NSException exceptionWithHTTPStatus: 400 /* Bad Request */ + reason: @"got no iCalendar content to store!"]; um = [AgenorUserManager sharedUserManager]; @@ -237,7 +235,7 @@ oldApt = nil; } else - oldApt = (iCalEvent *) [self component]; + oldApt = (iCalEvent *) [self component: NO]; /* compare sequence if requested */ @@ -245,28 +243,23 @@ // TODO } - /* handle new content */ - newCalendar = [iCalCalendar parseSingleFromSource: _iCal]; - newApt = (iCalEvent *) [newCalendar firstChildWithTag: [self componentTag]]; - if (newApt == nil) { - return [NSException exceptionWithHTTPStatus:400 /* Bad Request */ - reason:@"could not parse iCalendar content!"]; - } - + newApt = (iCalEvent *) [self component: NO]; + if (!newApt) + return [NSException exceptionWithHTTPStatus: 400 /* Bad Request */ + reason: @"could not parse iCalendar content!"]; + /* diff */ - changes = [iCalEventChanges changesFromEvent: oldApt - toEvent: newApt]; + changes = [iCalEventChanges changesFromEvent: oldApt toEvent: newApt]; + uids = [um getUIDsForICalPersons: [changes deletedAttendees] + applyStrictMapping: NO]; + removedUIDs = [NSMutableArray arrayWithArray: uids]; - uids = [um getUIDsForICalPersons:[changes deletedAttendees] - applyStrictMapping:NO]; - removedUIDs = [NSMutableArray arrayWithArray:uids]; - - uids = [um getUIDsForICalPersons:[newApt attendees] - applyStrictMapping:NO]; - storeUIDs = [NSMutableArray arrayWithArray:uids]; + uids = [um getUIDsForICalPersons: [newApt attendees] + applyStrictMapping: NO]; + storeUIDs = [NSMutableArray arrayWithArray: uids]; props = [changes updatedProperties]; /* detect whether sequence has to be increased */ @@ -276,7 +269,9 @@ /* preserve organizer */ organizer = [newApt organizer]; - uid = [um getUIDForICalPerson:organizer]; + uid = [um getUIDForICalPerson: organizer]; + if (!uid) + uid = [self ownerInContext: nil]; if (uid) { if (![storeUIDs containsObject:uid]) [storeUIDs addObject:uid]; @@ -304,9 +299,9 @@ */ if (oldApt != nil && - ([props containsObject:@"startDate"] || - [props containsObject:@"endDate"] || - [props containsObject:@"duration"])) + ([props containsObject: @"startDate"] || + [props containsObject: @"endDate"] || + [props containsObject: @"duration"])) { NSArray *ps; unsigned i, count; @@ -326,8 +321,8 @@ /* perform storing */ - storeError = [self saveContentString:_iCal inUIDs:storeUIDs]; - delError = [self deleteInUIDs:removedUIDs]; + storeError = [self saveContentString: _iCal inUIDs: storeUIDs]; + delError = [self deleteInUIDs: removedUIDs]; // TODO: make compound if (storeError != nil) return storeError; @@ -393,7 +388,7 @@ /* load existing content */ - apt = (iCalEvent *) [self component]; + apt = (iCalEvent *) [self component: NO]; /* compare sequence if requested */ @@ -445,7 +440,7 @@ ex = nil; // TODO: do we need to use SOGoAppointment? (prefer iCalEvent?) - apt = (iCalEvent *) [self component]; + apt = (iCalEvent *) [self component: NO]; if (apt) { diff --git a/SoObjects/Appointments/SOGoTaskObject.m b/SoObjects/Appointments/SOGoTaskObject.m index a70cf10eb..87dbef17e 100644 --- a/SoObjects/Appointments/SOGoTaskObject.m +++ b/SoObjects/Appointments/SOGoTaskObject.m @@ -413,7 +413,7 @@ static NSString *mailTemplateDefaultLanguage = nil; /* load existing content */ - task = (iCalToDo *) [self component]; + task = (iCalToDo *) [self component: NO]; /* compare sequence if requested */ @@ -462,7 +462,7 @@ static NSString *mailTemplateDefaultLanguage = nil; NSString *myEMail; // TODO: do we need to use SOGoTask? (prefer iCalToDo?) - task = (iCalToDo *) [self component]; + task = (iCalToDo *) [self component: NO]; if (task == nil) { return [NSException exceptionWithHTTPStatus:500 /* Server Error */