2006-10-11 20:59:06 +02:00
|
|
|
/*
|
2016-02-11 16:54:07 +01:00
|
|
|
Copyright (C) 2006-2014-2016 Inverse inc.
|
2006-10-11 20:59:06 +02:00
|
|
|
|
2012-04-24 13:47:32 +02:00
|
|
|
This file is part of SOGo.
|
2006-10-11 20:59:06 +02:00
|
|
|
|
2012-04-24 13:47:32 +02:00
|
|
|
SOGo is free software; you can redistribute it and/or modify it under
|
2006-10-11 20:59:06 +02:00
|
|
|
the terms of the GNU Lesser General Public License as published by the
|
|
|
|
Free Software Foundation; either version 2, or (at your option) any
|
|
|
|
later version.
|
|
|
|
|
2012-04-24 13:47:32 +02:00
|
|
|
SOGo is distributed in the hope that it will be useful, but WITHOUT ANY
|
2006-10-11 20:59:06 +02:00
|
|
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
|
|
|
License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
|
|
License along with OGo; see the file COPYING. If not, write to the
|
|
|
|
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
|
|
|
|
02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
2014-09-12 14:34:15 +02:00
|
|
|
#import <Foundation/NSCalendarDate.h>
|
2006-12-14 22:20:13 +01:00
|
|
|
|
2016-03-23 18:41:08 +01:00
|
|
|
#import <NGObjWeb/WOResponse.h>
|
|
|
|
#import <NGObjWeb/WOContext+SoObjects.h>
|
2007-08-09 22:58:01 +02:00
|
|
|
#import <NGExtensions/NSObject+Logs.h>
|
|
|
|
#import <NGExtensions/NSNull+misc.h>
|
2006-12-14 22:20:13 +01:00
|
|
|
#import <NGCards/iCalCalendar.h>
|
|
|
|
#import <NGCards/iCalToDo.h>
|
2007-08-09 22:58:01 +02:00
|
|
|
|
2006-10-11 20:59:06 +02:00
|
|
|
|
2012-07-13 22:31:41 +02:00
|
|
|
#import "iCalCalendar+SOGo.h"
|
2006-10-11 20:59:06 +02:00
|
|
|
#import "NSArray+Appointments.h"
|
2008-07-17 23:12:43 +02:00
|
|
|
#import "SOGoTaskOccurence.h"
|
2007-08-09 22:58:01 +02:00
|
|
|
|
|
|
|
#import "SOGoTaskObject.h"
|
2006-10-11 20:59:06 +02:00
|
|
|
|
|
|
|
@implementation SOGoTaskObject
|
|
|
|
|
2007-02-15 21:59:02 +01:00
|
|
|
- (NSString *) componentTag
|
2006-10-11 20:59:06 +02:00
|
|
|
{
|
2007-02-15 21:59:02 +01:00
|
|
|
return @"vtodo";
|
2006-10-11 20:59:06 +02:00
|
|
|
}
|
|
|
|
|
2012-07-13 22:31:41 +02:00
|
|
|
- (iCalRepeatableEntityObject *) lookupOccurrence: (NSString *) recID
|
|
|
|
{
|
|
|
|
return [[self calendar: NO secure: NO] todoWithRecurrenceID: recID];
|
|
|
|
}
|
|
|
|
|
2008-07-17 23:12:43 +02:00
|
|
|
- (SOGoComponentOccurence *) occurence: (iCalRepeatableEntityObject *) occ
|
|
|
|
{
|
2009-03-16 22:08:19 +01:00
|
|
|
NSArray *allTodos;
|
|
|
|
|
|
|
|
allTodos = [[occ parent] todos];
|
|
|
|
|
2008-07-17 23:12:43 +02:00
|
|
|
return [SOGoTaskOccurence occurenceWithComponent: occ
|
2009-03-16 22:08:19 +01:00
|
|
|
withMasterComponent: [allTodos objectAtIndex: 0]
|
2008-07-17 23:12:43 +02:00
|
|
|
inContainer: self];
|
|
|
|
}
|
|
|
|
|
2011-02-24 21:18:21 +01:00
|
|
|
#warning this code should be put in SOGoCalendarComponent once the UID hack\
|
|
|
|
in SOGoAppointmentObject is resolved
|
2014-07-30 20:51:00 +02:00
|
|
|
- (NSException *) saveComponent: (id) theComponent
|
|
|
|
baseVersion: (unsigned int) newVersion
|
2011-02-24 21:18:21 +01:00
|
|
|
{
|
|
|
|
NSException *ex;
|
|
|
|
|
2014-07-30 20:51:00 +02:00
|
|
|
ex = [super saveComponent: theComponent baseVersion: newVersion];
|
2011-02-24 21:18:21 +01:00
|
|
|
[fullCalendar release];
|
|
|
|
fullCalendar = nil;
|
|
|
|
[safeCalendar release];
|
|
|
|
safeCalendar = nil;
|
|
|
|
[originalCalendar release];
|
|
|
|
originalCalendar = nil;
|
|
|
|
|
|
|
|
return ex;
|
|
|
|
}
|
|
|
|
|
2014-09-12 14:34:15 +02:00
|
|
|
- (iCalRepeatableEntityObject *) newOccurenceWithID: (NSString *) theRecurrenceID
|
|
|
|
{
|
|
|
|
iCalToDo *newOccurence, *master;
|
|
|
|
NSCalendarDate *date, *firstDate;
|
|
|
|
NSTimeInterval interval;
|
|
|
|
|
|
|
|
newOccurence = (iCalToDo *) [super newOccurenceWithID: theRecurrenceID];
|
|
|
|
date = [newOccurence recurrenceId];
|
2016-10-24 22:31:59 +02:00
|
|
|
[newOccurence setStartDate: date];
|
2014-09-12 14:34:15 +02:00
|
|
|
|
|
|
|
master = [self component: NO secure: NO];
|
|
|
|
|
2016-10-24 22:31:59 +02:00
|
|
|
if ([master due])
|
|
|
|
{
|
|
|
|
firstDate = [master startDate];
|
|
|
|
interval = [[master due]
|
|
|
|
timeIntervalSinceDate: (NSDate *)firstDate];
|
2014-09-12 14:34:15 +02:00
|
|
|
|
2016-10-24 22:31:59 +02:00
|
|
|
[newOccurence setDue: [date addYear: 0
|
|
|
|
month: 0
|
|
|
|
day: 0
|
|
|
|
hour: 0
|
|
|
|
minute: 0
|
|
|
|
second: interval]];
|
|
|
|
}
|
2014-09-12 14:34:15 +02:00
|
|
|
|
|
|
|
return newOccurence;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) prepareDeleteOccurence: (iCalToDo *) occurence
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-03-23 18:41:08 +01:00
|
|
|
- (id) PUTAction: (WOContext *) _ctx
|
|
|
|
{
|
|
|
|
iCalCalendar *rqCalendar;
|
|
|
|
WORequest *rq;
|
|
|
|
|
|
|
|
rq = [_ctx request];
|
|
|
|
rqCalendar = [iCalCalendar parseSingleFromSource: [rq contentAsString]];
|
|
|
|
[self adjustClassificationInRequestCalendar: rqCalendar];
|
|
|
|
[rq setContent: [[rqCalendar versitString] dataUsingEncoding: [rq contentEncoding]]];
|
|
|
|
|
|
|
|
return [super PUTAction: _ctx];
|
|
|
|
}
|
|
|
|
|
2006-10-11 20:59:06 +02:00
|
|
|
@end /* SOGoTaskObject */
|