Monotone-Parent: 9475f39d99549bfa74e7f88be7e54d9650beb0d5

Monotone-Revision: d953e1b8cae8bcdf2a3cff4219ea365af8391941

Monotone-Author: wsourdeau@inverse.ca
Monotone-Date: 2012-07-13T20:31:41
maint-2.0.2
Wolfgang Sourdeau 2012-07-13 20:31:41 +00:00
parent caf58a7c4a
commit 82f3f1b3d9
8 changed files with 152 additions and 42 deletions

View File

@ -1,5 +1,13 @@
2012-07-13 Wolfgang Sourdeau <wsourdeau@inverse.ca>
* SoObjects/Appointments/SOGoCalendarComponent.m
(-lookupOccurrence:): now a virtual method forcing the use by
subclasses of the new methods below.
* SoObjects/Appointments/iCalCalendar+SOGo.m: new category module.
(-eventWithRecurrenceId, -todoWithRecurrenceId): new method that
return as recurrence based on the id passed as parameter.
* Tests/Integration/test-caldav-scheduling.py
(CalDAVSchedulingTest.setUp): use the proper password for
attendee1_delegate.

View File

@ -9,6 +9,7 @@ Appointments_PRINCIPAL_CLASS = SOGoAppointmentsProduct
Appointments_OBJC_FILES = \
Product.m \
NSArray+Appointments.m \
iCalCalendar+SOGo.m \
iCalEntityObject+SOGo.m \
iCalRepeatableEntityObject+SOGo.m \
iCalEvent+SOGo.m \

View File

@ -53,6 +53,7 @@
#import <SOGo/SOGoWebDAVValue.h>
#import <SOGo/WORequest+SOGo.h>
#import "iCalCalendar+SOGo.h"
#import "iCalEventChanges+SOGo.h"
#import "iCalEntityObject+SOGo.h"
#import "iCalPerson+SOGo.h"
@ -121,6 +122,12 @@
return newOccurence;
}
- (iCalRepeatableEntityObject *) lookupOccurrence: (NSString *) recID
{
return [[self calendar: NO secure: NO] eventWithRecurrenceID: recID];
}
- (SOGoAppointmentObject *) _lookupEvent: (NSString *) eventUID
forUID: (NSString *) uid
{
@ -839,7 +846,7 @@ inRecurrenceExceptionsForEvent: (iCalEvent *) theEvent
// If recurrenceId is defined, find the specified occurence
// within the repeating vEvent.
recurrenceTime = [NSString stringWithFormat: @"%f", [recurrenceId timeIntervalSince1970]];
oldEvent = (iCalEvent*)[self lookupOccurence: recurrenceTime];
oldEvent = (iCalEvent*)[self lookupOccurrence: recurrenceTime];
if (oldEvent == nil)
// If no occurence found, create one
oldEvent = (iCalEvent *)[self newOccurenceWithID: recurrenceTime];
@ -906,7 +913,7 @@ inRecurrenceExceptionsForEvent: (iCalEvent *) theEvent
// If recurrenceId is defined, find the specified occurence
// within the repeating vEvent.
recurrenceTime = [NSString stringWithFormat: @"%f", [recurrenceId timeIntervalSince1970]];
event = [eventObject lookupOccurence: recurrenceTime];
event = [eventObject lookupOccurrence: recurrenceTime];
if (event == nil)
// If no occurence found, create one
@ -1348,7 +1355,7 @@ inRecurrenceExceptionsForEvent: (iCalEvent *) theEvent
// If _recurrenceId is defined, find the specified occurence
// within the repeating vEvent.
recurrenceTime = [NSString stringWithFormat: @"%f", [_recurrenceId timeIntervalSince1970]];
event = (iCalEvent*)[self lookupOccurence: recurrenceTime];
event = (iCalEvent*)[self lookupOccurrence: recurrenceTime];
if (event == nil)
// If no occurence found, create one

View File

@ -86,7 +86,8 @@
- (NSArray *) getUIDsForICalPersons: (NSArray *) iCalPersons;
/* recurrences */
- (iCalRepeatableEntityObject *) lookupOccurence: (NSString *) recID;
/* same as above, but refers to the existing calendar component */
- (iCalRepeatableEntityObject *) lookupOccurrence: (NSString *) recID;
- (SOGoComponentOccurence *) occurence: (iCalRepeatableEntityObject *) component;
- (iCalRepeatableEntityObject *) newOccurenceWithID: (NSString *) recID;

View File

@ -269,45 +269,11 @@
return iCalString;
}
static inline BOOL _occurenceHasID (iCalRepeatableEntityObject *occurence,
NSString *recID)
- (iCalRepeatableEntityObject *) lookupOccurrence: (NSString *) recID
{
unsigned int seconds, recSeconds;
seconds = [recID intValue];
recSeconds = [[occurence recurrenceId] timeIntervalSince1970];
[self subclassResponsibility: _cmd];
return (seconds == recSeconds);
}
- (iCalRepeatableEntityObject *) lookupOccurence: (NSString *) recID
{
iCalRepeatableEntityObject *component, *occurence, *currentOccurence;
NSArray *occurences;
unsigned int count, max;
occurence = nil;
component = [self component: NO secure: NO];
if ([component hasRecurrenceRules])
{
occurences = [[self calendar: NO secure: NO] allObjects];
max = [occurences count];
count = 1; // skip master event
while (!occurence && count < max)
{
currentOccurence = [occurences objectAtIndex: count];
if (_occurenceHasID (currentOccurence, recID))
occurence = currentOccurence;
else
count++;
}
}
else if (_occurenceHasID (component, recID))
/* The "master" event could be that occurrence. */
occurence = component;
return occurence;
return nil;
}
- (SOGoComponentOccurence *) occurence: (iCalRepeatableEntityObject *) component
@ -397,7 +363,7 @@ static inline BOOL _occurenceHasID (iCalRepeatableEntityObject *occurence,
else if ([lookupName hasPrefix: @"occurence"])
{
recID = [lookupName substringFromIndex: 9];
occurence = [self lookupOccurence: recID];
occurence = [self lookupOccurrence: recID];
if (occurence)
isNewOccurence = NO;
else

View File

@ -32,6 +32,7 @@
#import <SoObjects/SOGo/SOGoMailer.h>
#import "iCalCalendar+SOGo.h"
#import "NSArray+Appointments.h"
#import "SOGoAptMailNotification.h"
#import "SOGoAppointmentFolder.h"
@ -46,6 +47,11 @@
return @"vtodo";
}
- (iCalRepeatableEntityObject *) lookupOccurrence: (NSString *) recID
{
return [[self calendar: NO secure: NO] todoWithRecurrenceID: recID];
}
- (SOGoComponentOccurence *) occurence: (iCalRepeatableEntityObject *) occ
{
NSArray *allTodos;

View File

@ -0,0 +1,39 @@
/* iCalCalendar+SOGo.h - this file is part of SOGo
*
* Copyright (C) 2012 Inverse inc
*
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
*
* This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This file is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef ICALCALENDAR_SOGO_H
#define ICALCALENDAR_SOGO_H
#import <NGCards/iCalCalendar.h>
@class NSString;
@class iCalEvent;
@class iCalToDo;
@interface iCalCalendar (SOGoExtensions)
- (iCalEvent *) eventWithRecurrenceID: (NSString *) recID;
- (iCalToDo *) todoWithRecurrenceID: (NSString *) recID;
@end
#endif /* ICALCALENDAR_SOGO_H */

View File

@ -0,0 +1,82 @@
/* iCalCalendar+SOGo.m - this file is part of $PROJECT_NAME_HERE$
*
* Copyright (C) 2012 Inverse inc
*
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
*
* This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This file is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#import <Foundation/NSArray.h>
#import <Foundation/NSString.h>
#import <NGCards/iCalRepeatableEntityObject.h>
#import "iCalCalendar+SOGo.h"
@implementation iCalCalendar (SOGoExtensions)
- (id) _occurrence: (NSString *) recID
inArray: (NSArray *) components
{
id occurrence;
iCalRepeatableEntityObject *component;
NSUInteger count, max, seconds, recSeconds;
occurrence = nil;
seconds = [recID intValue];
max = [components count];
/* master occurrence */
component = [components objectAtIndex: 0];
if ([component hasRecurrenceRules])
{
count = 1; // skip master event
while (!occurrence && count < max)
{
component = [components objectAtIndex: count];
recSeconds = [[component recurrenceId] timeIntervalSince1970];
if (recSeconds == seconds)
occurrence = component;
else
count++;
}
}
else
{
/* The "master" event could be that occurrence. */
recSeconds = [[component recurrenceId] timeIntervalSince1970];
if (recSeconds == seconds)
occurrence = component;
}
return occurrence;
}
- (iCalEvent *) eventWithRecurrenceID: (NSString *) recID
{
return [self _occurrence: recID inArray: [self events]];
}
- (iCalToDo *) todoWithRecurrenceID: (NSString *) recID;
{
return [self _occurrence: recID inArray: [self todos]];
}
@end