2006-06-15 21:34:10 +02:00
|
|
|
/*
|
|
|
|
Copyright (C) 2004-2005 SKYRIX Software AG
|
|
|
|
|
|
|
|
This file is part of OpenGroupware.org.
|
|
|
|
|
|
|
|
OGo is free software; you can redistribute it and/or modify it under
|
|
|
|
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.
|
|
|
|
|
|
|
|
OGo 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 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.
|
|
|
|
*/
|
|
|
|
|
2007-08-07 20:37:31 +02:00
|
|
|
#import <Foundation/NSCalendarDate.h>
|
|
|
|
#import <Foundation/NSEnumerator.h>
|
|
|
|
#import <Foundation/NSValue.h>
|
|
|
|
|
|
|
|
#import <NGObjWeb/NSException+HTTP.h>
|
|
|
|
#import <NGObjWeb/SoObject+SoDAV.h>
|
|
|
|
#import <NGObjWeb/WOContext+SoObjects.h>
|
2007-02-09 22:21:35 +01:00
|
|
|
#import <NGObjWeb/WOMessage.h>
|
2007-08-07 20:37:31 +02:00
|
|
|
#import <NGObjWeb/WORequest.h>
|
|
|
|
#import <NGObjWeb/WOResponse.h>
|
|
|
|
#import <NGExtensions/NGLoggerManager.h>
|
|
|
|
#import <NGExtensions/NSString+misc.h>
|
|
|
|
#import <GDLContentStore/GCSFolder.h>
|
|
|
|
#import <DOM/DOMProtocols.h>
|
|
|
|
#import <EOControl/EOQualifier.h>
|
|
|
|
#import <NGCards/iCalDateTime.h>
|
|
|
|
#import <NGCards/iCalPerson.h>
|
|
|
|
#import <NGCards/iCalRecurrenceCalculator.h>
|
|
|
|
#import <NGCards/NSString+NGCards.h>
|
2006-10-11 20:48:25 +02:00
|
|
|
#import <NGExtensions/NGCalendarDateRange.h>
|
2007-08-07 20:37:31 +02:00
|
|
|
#import <NGExtensions/NSNull+misc.h>
|
|
|
|
#import <NGExtensions/NSObject+Logs.h>
|
2007-03-10 00:10:43 +01:00
|
|
|
#import <SaxObjC/SaxObjC.h>
|
|
|
|
#import <SaxObjC/XMLNamespaces.h>
|
2006-10-11 20:48:25 +02:00
|
|
|
|
2007-02-09 22:21:35 +01:00
|
|
|
// #import <NGObjWeb/SoClassSecurityInfo.h>
|
2006-11-02 22:53:27 +01:00
|
|
|
#import <SOGo/SOGoCustomGroupFolder.h>
|
2007-05-09 20:25:51 +02:00
|
|
|
#import <SOGo/LDAPUserManager.h>
|
2006-12-14 22:20:13 +01:00
|
|
|
#import <SOGo/SOGoPermissions.h>
|
2007-07-27 19:30:57 +02:00
|
|
|
#import <SOGo/NSString+Utilities.h>
|
2007-03-07 22:27:19 +01:00
|
|
|
#import <SOGo/SOGoUser.h>
|
2006-11-02 22:53:27 +01:00
|
|
|
|
2006-09-27 00:27:34 +02:00
|
|
|
#import "SOGoAppointmentObject.h"
|
2006-10-11 20:48:25 +02:00
|
|
|
#import "SOGoTaskObject.h"
|
|
|
|
|
|
|
|
#import "SOGoAppointmentFolder.h"
|
2006-09-27 00:27:34 +02:00
|
|
|
|
2006-06-15 21:34:10 +02:00
|
|
|
#if APPLE_Foundation_LIBRARY || NeXT_Foundation_LIBRARY
|
|
|
|
@interface NSDate(UsedPrivates)
|
|
|
|
- (id)initWithTimeIntervalSince1970:(NSTimeInterval)_interval;
|
|
|
|
@end
|
|
|
|
#endif
|
|
|
|
|
|
|
|
@implementation SOGoAppointmentFolder
|
|
|
|
|
|
|
|
static NGLogger *logger = nil;
|
|
|
|
static NSNumber *sharedYes = nil;
|
|
|
|
|
2006-08-16 00:04:37 +02:00
|
|
|
+ (int) version
|
|
|
|
{
|
2006-06-15 21:34:10 +02:00
|
|
|
return [super version] + 1 /* v1 */;
|
|
|
|
}
|
2006-08-16 00:04:37 +02:00
|
|
|
|
|
|
|
+ (void) initialize
|
|
|
|
{
|
2006-06-15 21:34:10 +02:00
|
|
|
NGLoggerManager *lm;
|
|
|
|
static BOOL didInit = NO;
|
2007-02-09 22:21:35 +01:00
|
|
|
// SoClassSecurityInfo *securityInfo;
|
2006-06-15 21:34:10 +02:00
|
|
|
|
|
|
|
if (didInit) return;
|
|
|
|
didInit = YES;
|
|
|
|
|
|
|
|
NSAssert2([super version] == 0,
|
|
|
|
@"invalid superclass (%@) version %i !",
|
|
|
|
NSStringFromClass([self superclass]), [super version]);
|
|
|
|
|
|
|
|
lm = [NGLoggerManager defaultLoggerManager];
|
2007-04-02 21:24:49 +02:00
|
|
|
logger = [lm loggerForDefaultKey: @"SOGoAppointmentFolderDebugEnabled"];
|
2006-06-15 21:34:10 +02:00
|
|
|
|
2007-02-08 17:27:26 +01:00
|
|
|
// securityInfo = [self soClassSecurityInfo];
|
|
|
|
// [securityInfo declareRole: SOGoRole_Delegate
|
|
|
|
// asDefaultForPermission: SoPerm_AddDocumentsImagesAndFiles];
|
|
|
|
// [securityInfo declareRole: SOGoRole_Delegate
|
|
|
|
// asDefaultForPermission: SoPerm_ChangeImagesAndFiles];
|
|
|
|
// [securityInfo declareRoles: [NSArray arrayWithObjects:
|
|
|
|
// SOGoRole_Delegate,
|
|
|
|
// SOGoRole_Assistant, nil]
|
|
|
|
// asDefaultForPermission: SoPerm_View];
|
2006-12-14 22:20:13 +01:00
|
|
|
|
2007-04-11 21:08:58 +02:00
|
|
|
sharedYes = [[NSNumber numberWithBool: YES] retain];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (id) initWithName: (NSString *) name
|
|
|
|
inContainer: (id) newContainer
|
|
|
|
{
|
|
|
|
if ((self = [super initWithName: name inContainer: newContainer]))
|
|
|
|
{
|
|
|
|
timeZone = [[context activeUser] timeZone];
|
|
|
|
}
|
|
|
|
|
|
|
|
return self;
|
2006-06-15 21:34:10 +02:00
|
|
|
}
|
|
|
|
|
2006-08-16 00:04:37 +02:00
|
|
|
- (void) dealloc
|
|
|
|
{
|
2007-04-11 21:08:58 +02:00
|
|
|
[uidToFilename release];
|
2006-06-15 21:34:10 +02:00
|
|
|
[super dealloc];
|
|
|
|
}
|
|
|
|
|
|
|
|
/* logging */
|
|
|
|
|
2006-08-16 00:04:37 +02:00
|
|
|
- (id) debugLogger
|
|
|
|
{
|
2006-06-15 21:34:10 +02:00
|
|
|
return logger;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* selection */
|
|
|
|
|
2006-08-16 00:04:37 +02:00
|
|
|
- (NSArray *) calendarUIDs
|
|
|
|
{
|
2006-06-15 21:34:10 +02:00
|
|
|
/* this is used for group calendars (this folder just returns itself) */
|
|
|
|
NSString *s;
|
|
|
|
|
|
|
|
s = [[self container] nameInContainer];
|
2007-04-11 21:08:58 +02:00
|
|
|
// [self logWithFormat:@"CAL UID: %@", s];
|
2006-06-15 21:34:10 +02:00
|
|
|
return [s isNotNull] ? [NSArray arrayWithObjects:&s count:1] : nil;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* name lookup */
|
|
|
|
|
2006-08-16 00:04:37 +02:00
|
|
|
- (BOOL) isValidAppointmentName: (NSString *)_key
|
|
|
|
{
|
2006-10-11 20:48:25 +02:00
|
|
|
return ([_key length] != 0);
|
2006-09-27 00:27:34 +02:00
|
|
|
}
|
|
|
|
|
2006-10-11 20:48:25 +02:00
|
|
|
- (void) appendObject: (NSDictionary *) object
|
|
|
|
withBaseURL: (NSString *) baseURL
|
|
|
|
toREPORTResponse: (WOResponse *) r
|
2006-09-27 00:27:34 +02:00
|
|
|
{
|
2007-03-07 22:27:19 +01:00
|
|
|
SOGoCalendarComponent *component;
|
|
|
|
Class componentClass;
|
2007-07-27 19:30:57 +02:00
|
|
|
NSString *name, *etagLine, *calString;
|
2006-09-27 00:27:34 +02:00
|
|
|
|
2007-07-27 19:30:57 +02:00
|
|
|
name = [object objectForKey: @"c_name"];
|
2006-09-27 00:27:34 +02:00
|
|
|
|
2007-07-24 20:45:52 +02:00
|
|
|
if ([[object objectForKey: @"c_component"] isEqualToString: @"vevent"])
|
2007-03-07 22:27:19 +01:00
|
|
|
componentClass = [SOGoAppointmentObject class];
|
|
|
|
else
|
|
|
|
componentClass = [SOGoTaskObject class];
|
|
|
|
|
2007-07-27 19:30:57 +02:00
|
|
|
component = [componentClass objectWithName: name inContainer: self];
|
2006-09-27 00:27:34 +02:00
|
|
|
|
|
|
|
[r appendContentString: @" <D:response>\r\n"];
|
|
|
|
[r appendContentString: @" <D:href>"];
|
|
|
|
[r appendContentString: baseURL];
|
|
|
|
if (![baseURL hasSuffix: @"/"])
|
|
|
|
[r appendContentString: @"/"];
|
2007-07-27 19:30:57 +02:00
|
|
|
[r appendContentString: name];
|
2006-09-27 00:27:34 +02:00
|
|
|
[r appendContentString: @"</D:href>\r\n"];
|
|
|
|
|
|
|
|
[r appendContentString: @" <D:propstat>\r\n"];
|
|
|
|
[r appendContentString: @" <D:prop>\r\n"];
|
|
|
|
etagLine = [NSString stringWithFormat: @" <D:getetag>%@</D:getetag>\r\n",
|
2007-03-07 22:27:19 +01:00
|
|
|
[component davEntityTag]];
|
2006-09-27 00:27:34 +02:00
|
|
|
[r appendContentString: etagLine];
|
|
|
|
[r appendContentString: @" </D:prop>\r\n"];
|
|
|
|
[r appendContentString: @" <D:status>HTTP/1.1 200 OK</D:status>\r\n"];
|
|
|
|
[r appendContentString: @" </D:propstat>\r\n"];
|
2007-01-08 17:11:49 +01:00
|
|
|
[r appendContentString: @" <C:calendar-data>"];
|
2007-03-07 22:27:19 +01:00
|
|
|
calString = [[component contentAsString] stringByEscapingXMLString];
|
2007-01-08 17:11:49 +01:00
|
|
|
[r appendContentString: calString];
|
|
|
|
[r appendContentString: @"</C:calendar-data>\r\n"];
|
2006-09-27 00:27:34 +02:00
|
|
|
[r appendContentString: @" </D:response>\r\n"];
|
|
|
|
}
|
|
|
|
|
2006-10-17 21:57:14 +02:00
|
|
|
- (void) _appendTimeRange: (id <DOMElement>) timeRangeElement
|
|
|
|
toFilter: (NSMutableDictionary *) filter
|
|
|
|
{
|
|
|
|
NSCalendarDate *parsedDate;
|
|
|
|
|
|
|
|
parsedDate = [[timeRangeElement attribute: @"start"] asCalendarDate];
|
|
|
|
[filter setObject: parsedDate forKey: @"start"];
|
|
|
|
parsedDate = [[timeRangeElement attribute: @"end"] asCalendarDate];
|
|
|
|
[filter setObject: parsedDate forKey: @"end"];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSDictionary *) _parseCalendarFilter: (id <DOMElement>) filterElement
|
|
|
|
{
|
|
|
|
NSMutableDictionary *filterData;
|
2006-12-14 22:20:13 +01:00
|
|
|
id <DOMNode> parentNode;
|
2006-10-17 21:57:14 +02:00
|
|
|
id <DOMNodeList> ranges;
|
|
|
|
NSString *componentName;
|
|
|
|
|
|
|
|
parentNode = [filterElement parentNode];
|
|
|
|
if ([[parentNode tagName] isEqualToString: @"comp-filter"]
|
|
|
|
&& [[parentNode attribute: @"name"] isEqualToString: @"VCALENDAR"])
|
|
|
|
{
|
|
|
|
componentName = [[filterElement attribute: @"name"] lowercaseString];
|
|
|
|
filterData = [NSMutableDictionary new];
|
|
|
|
[filterData autorelease];
|
|
|
|
[filterData setObject: componentName forKey: @"name"];
|
|
|
|
ranges = [filterElement getElementsByTagName: @"time-range"];
|
|
|
|
if ([ranges count])
|
|
|
|
[self _appendTimeRange: [ranges objectAtIndex: 0]
|
|
|
|
toFilter: filterData];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
filterData = nil;
|
|
|
|
|
|
|
|
return filterData;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSArray *) _parseCalendarFilters: (id <DOMElement>) parentNode
|
|
|
|
{
|
|
|
|
NSEnumerator *children;
|
|
|
|
id<DOMElement> node;
|
|
|
|
NSMutableArray *filters;
|
|
|
|
NSDictionary *filter;
|
|
|
|
|
|
|
|
filters = [NSMutableArray new];
|
|
|
|
|
2007-04-02 21:24:49 +02:00
|
|
|
children = [[parentNode getElementsByTagName: @"comp-filter"]
|
|
|
|
objectEnumerator];
|
2006-10-17 21:57:14 +02:00
|
|
|
node = [children nextObject];
|
|
|
|
while (node)
|
|
|
|
{
|
|
|
|
filter = [self _parseCalendarFilter: node];
|
|
|
|
if (filter)
|
|
|
|
[filters addObject: filter];
|
|
|
|
node = [children nextObject];
|
|
|
|
}
|
|
|
|
|
|
|
|
return filters;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) _appendComponentsMatchingFilters: (NSArray *) filters
|
|
|
|
toResponse: (WOResponse *) response
|
2006-09-27 00:27:34 +02:00
|
|
|
{
|
|
|
|
NSArray *apts;
|
2006-10-17 21:57:14 +02:00
|
|
|
unsigned int count, max;
|
|
|
|
NSDictionary *currentFilter, *appointment;
|
2006-09-27 00:27:34 +02:00
|
|
|
NSEnumerator *appointments;
|
2006-10-17 21:57:14 +02:00
|
|
|
NSString *baseURL;
|
2006-09-27 00:27:34 +02:00
|
|
|
|
|
|
|
baseURL = [self baseURLInContext: context];
|
2006-10-17 21:57:14 +02:00
|
|
|
|
|
|
|
max = [filters count];
|
|
|
|
for (count = 0; count < max; count++)
|
|
|
|
{
|
|
|
|
currentFilter = [filters objectAtIndex: 0];
|
|
|
|
apts = [self fetchCoreInfosFrom: [currentFilter objectForKey: @"start"]
|
|
|
|
to: [currentFilter objectForKey: @"end"]
|
|
|
|
component: [currentFilter objectForKey: @"name"]];
|
|
|
|
appointments = [apts objectEnumerator];
|
|
|
|
appointment = [appointments nextObject];
|
|
|
|
while (appointment)
|
|
|
|
{
|
|
|
|
[self appendObject: appointment
|
|
|
|
withBaseURL: baseURL
|
|
|
|
toREPORTResponse: response];
|
|
|
|
appointment = [appointments nextObject];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-07-22 22:42:00 +02:00
|
|
|
- (NSArray *) davNamespaces
|
|
|
|
{
|
|
|
|
return [NSArray arrayWithObject: @"urn:ietf:params:xml:ns:caldav"];
|
|
|
|
}
|
|
|
|
|
2007-04-11 21:08:58 +02:00
|
|
|
- (id) davCalendarQuery: (id) queryContext
|
2006-10-17 21:57:14 +02:00
|
|
|
{
|
|
|
|
WOResponse *r;
|
|
|
|
NSArray *filters;
|
|
|
|
id <DOMDocument> document;
|
|
|
|
|
2006-09-27 00:27:34 +02:00
|
|
|
r = [context response];
|
|
|
|
[r setStatus: 207];
|
|
|
|
[r setContentEncoding: NSUTF8StringEncoding];
|
|
|
|
[r setHeader: @"text/xml; charset=\"utf-8\"" forKey: @"content-type"];
|
|
|
|
[r setHeader: @"no-cache" forKey: @"pragma"];
|
|
|
|
[r setHeader: @"no-cache" forKey: @"cache-control"];
|
|
|
|
[r appendContentString:@"<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n"];
|
|
|
|
[r appendContentString: @"<D:multistatus xmlns:D=\"DAV:\""
|
|
|
|
@" xmlns:C=\"urn:ietf:params:xml:ns:caldav\">\r\n"];
|
2006-09-28 19:22:44 +02:00
|
|
|
|
2006-10-17 21:57:14 +02:00
|
|
|
document = [[context request] contentAsDOMDocument];
|
|
|
|
filters = [self _parseCalendarFilters: [document documentElement]];
|
|
|
|
[self _appendComponentsMatchingFilters: filters
|
2007-04-11 21:08:58 +02:00
|
|
|
toResponse: r];
|
2006-09-27 00:27:34 +02:00
|
|
|
[r appendContentString:@"</D:multistatus>\r\n"];
|
|
|
|
|
|
|
|
return r;
|
2006-06-15 21:34:10 +02:00
|
|
|
}
|
|
|
|
|
2006-10-11 20:48:25 +02:00
|
|
|
- (Class) objectClassForContent: (NSString *) content
|
|
|
|
{
|
|
|
|
iCalCalendar *calendar;
|
|
|
|
NSArray *elements;
|
|
|
|
NSString *firstTag;
|
|
|
|
Class objectClass;
|
|
|
|
|
|
|
|
objectClass = Nil;
|
|
|
|
|
|
|
|
calendar = [iCalCalendar parseSingleFromSource: content];
|
|
|
|
if (calendar)
|
|
|
|
{
|
|
|
|
elements = [calendar allObjects];
|
|
|
|
if ([elements count])
|
|
|
|
{
|
|
|
|
firstTag = [[[elements objectAtIndex: 0] tag] uppercaseString];
|
|
|
|
if ([firstTag isEqualToString: @"VEVENT"])
|
|
|
|
objectClass = [SOGoAppointmentObject class];
|
|
|
|
else if ([firstTag isEqualToString: @"VTODO"])
|
|
|
|
objectClass = [SOGoTaskObject class];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return objectClass;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (id) deduceObjectForName: (NSString *)_key
|
|
|
|
inContext: (id)_ctx
|
|
|
|
{
|
|
|
|
WORequest *request;
|
|
|
|
NSString *method;
|
|
|
|
Class objectClass;
|
|
|
|
id obj;
|
|
|
|
|
|
|
|
request = [_ctx request];
|
|
|
|
method = [request method];
|
|
|
|
if ([method isEqualToString: @"PUT"])
|
|
|
|
objectClass = [self objectClassForContent: [request contentAsString]];
|
|
|
|
else
|
|
|
|
objectClass = [self objectClassForResourceNamed: _key];
|
|
|
|
|
|
|
|
if (objectClass)
|
|
|
|
obj = [objectClass objectWithName: _key inContainer: self];
|
|
|
|
else
|
|
|
|
obj = nil;
|
|
|
|
|
|
|
|
return obj;
|
|
|
|
}
|
|
|
|
|
2006-11-02 22:53:27 +01:00
|
|
|
- (BOOL) requestNamedIsHandledLater: (NSString *) name
|
|
|
|
{
|
|
|
|
return [name isEqualToString: @"OPTIONS"];
|
|
|
|
}
|
|
|
|
|
2006-08-16 00:04:37 +02:00
|
|
|
- (id) lookupName: (NSString *)_key
|
|
|
|
inContext: (id)_ctx
|
|
|
|
acquire: (BOOL)_flag
|
|
|
|
{
|
2006-06-15 21:34:10 +02:00
|
|
|
id obj;
|
2006-10-11 20:48:25 +02:00
|
|
|
NSString *url;
|
2006-11-02 22:53:27 +01:00
|
|
|
BOOL handledLater;
|
2006-10-11 20:48:25 +02:00
|
|
|
|
2006-06-15 21:34:10 +02:00
|
|
|
/* first check attributes directly bound to the application */
|
2007-04-11 21:08:58 +02:00
|
|
|
handledLater = [self requestNamedIsHandledLater: _key];
|
2006-11-02 22:53:27 +01:00
|
|
|
if (handledLater)
|
|
|
|
obj = nil;
|
|
|
|
else
|
2006-10-11 20:48:25 +02:00
|
|
|
{
|
2006-11-02 22:53:27 +01:00
|
|
|
obj = [super lookupName:_key inContext:_ctx acquire:NO];
|
|
|
|
if (!obj)
|
2006-10-11 20:48:25 +02:00
|
|
|
{
|
2007-07-22 22:42:00 +02:00
|
|
|
if ([self isValidAppointmentName:_key])
|
2006-11-02 22:53:27 +01:00
|
|
|
{
|
|
|
|
url = [[[_ctx request] uri] urlWithoutParameters];
|
|
|
|
if ([url hasSuffix: @"AsTask"])
|
|
|
|
obj = [SOGoTaskObject objectWithName: _key
|
|
|
|
inContainer: self];
|
|
|
|
else if ([url hasSuffix: @"AsAppointment"])
|
|
|
|
obj = [SOGoAppointmentObject objectWithName: _key
|
|
|
|
inContainer: self];
|
|
|
|
else
|
|
|
|
obj = [self deduceObjectForName: _key
|
|
|
|
inContext: _ctx];
|
|
|
|
}
|
2006-10-11 20:48:25 +02:00
|
|
|
}
|
2006-11-02 22:53:27 +01:00
|
|
|
if (!obj)
|
|
|
|
obj = [NSException exceptionWithHTTPStatus:404 /* Not Found */];
|
2006-10-11 20:48:25 +02:00
|
|
|
}
|
2006-09-27 00:27:34 +02:00
|
|
|
|
2006-10-11 20:48:25 +02:00
|
|
|
return obj;
|
2006-06-15 21:34:10 +02:00
|
|
|
}
|
|
|
|
|
2006-11-02 22:53:27 +01:00
|
|
|
- (NSArray *) davComplianceClassesInContext: (id)_ctx
|
|
|
|
{
|
|
|
|
NSMutableArray *classes;
|
|
|
|
NSArray *primaryClasses;
|
|
|
|
|
|
|
|
classes = [NSMutableArray new];
|
|
|
|
[classes autorelease];
|
|
|
|
|
|
|
|
primaryClasses = [super davComplianceClassesInContext: _ctx];
|
|
|
|
if (primaryClasses)
|
|
|
|
[classes addObjectsFromArray: primaryClasses];
|
|
|
|
[classes addObject: @"access-control"];
|
|
|
|
[classes addObject: @"calendar-access"];
|
|
|
|
|
|
|
|
return classes;
|
|
|
|
}
|
|
|
|
|
2007-04-23 19:55:03 +02:00
|
|
|
- (NSArray *) groupDavResourceType
|
2006-12-14 22:20:13 +01:00
|
|
|
{
|
2007-04-23 19:55:03 +02:00
|
|
|
return [NSArray arrayWithObjects: @"vevent-collection",
|
|
|
|
@"vtodo-collection", nil];
|
2006-12-14 22:20:13 +01:00
|
|
|
}
|
|
|
|
|
2007-03-10 00:10:43 +01:00
|
|
|
- (NSArray *) davResourceType
|
|
|
|
{
|
|
|
|
static NSArray *colType = nil;
|
2007-04-25 17:14:40 +02:00
|
|
|
NSArray *cdCol, *gdRT, *gdVEventCol, *gdVTodoCol;
|
2007-03-10 00:10:43 +01:00
|
|
|
|
|
|
|
if (!colType)
|
|
|
|
{
|
2007-04-25 17:14:40 +02:00
|
|
|
gdRT = [self groupDavResourceType];
|
|
|
|
gdVEventCol = [NSArray arrayWithObjects: [gdRT objectAtIndex: 0],
|
|
|
|
XMLNS_GROUPDAV, nil];
|
|
|
|
gdVTodoCol = [NSArray arrayWithObjects: [gdRT objectAtIndex: 1],
|
|
|
|
XMLNS_GROUPDAV, nil];
|
2007-03-10 00:10:43 +01:00
|
|
|
cdCol = [NSArray arrayWithObjects: @"calendar", XMLNS_CALDAV, nil];
|
2007-04-25 17:14:40 +02:00
|
|
|
colType = [NSArray arrayWithObjects: @"collection", cdCol,
|
|
|
|
gdVEventCol, gdVTodoCol, nil];
|
2007-03-10 00:10:43 +01:00
|
|
|
[colType retain];
|
|
|
|
}
|
|
|
|
|
|
|
|
return colType;
|
|
|
|
}
|
|
|
|
|
2006-06-15 21:34:10 +02:00
|
|
|
/* vevent UID handling */
|
|
|
|
|
2006-08-16 00:04:37 +02:00
|
|
|
- (NSString *) resourceNameForEventUID: (NSString *)_u
|
|
|
|
inFolder: (GCSFolder *)_f
|
|
|
|
{
|
2006-06-15 21:34:10 +02:00
|
|
|
static NSArray *nameFields = nil;
|
|
|
|
EOQualifier *qualifier;
|
|
|
|
NSArray *records;
|
|
|
|
|
|
|
|
if (![_u isNotNull]) return nil;
|
|
|
|
if (_f == nil) {
|
|
|
|
[self errorWithFormat:@"(%s): missing folder for fetch!",
|
|
|
|
__PRETTY_FUNCTION__];
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nameFields == nil)
|
2007-04-02 21:24:49 +02:00
|
|
|
nameFields = [[NSArray alloc] initWithObjects: @"c_name", nil];
|
2006-06-15 21:34:10 +02:00
|
|
|
|
2007-07-27 19:30:57 +02:00
|
|
|
qualifier = [EOQualifier qualifierWithQualifierFormat:@"c_uid = %@", _u];
|
2006-10-17 21:57:14 +02:00
|
|
|
records = [_f fetchFields: nameFields matchingQualifier: qualifier];
|
2006-06-15 21:34:10 +02:00
|
|
|
|
|
|
|
if ([records count] == 1)
|
|
|
|
return [[records objectAtIndex:0] valueForKey:@"c_name"];
|
|
|
|
if ([records count] == 0)
|
|
|
|
return nil;
|
|
|
|
|
|
|
|
[self errorWithFormat:
|
|
|
|
@"The storage contains more than file with the same UID!"];
|
|
|
|
return [[records objectAtIndex:0] valueForKey:@"c_name"];
|
|
|
|
}
|
|
|
|
|
2006-08-16 00:04:37 +02:00
|
|
|
- (NSString *) resourceNameForEventUID: (NSString *) _uid
|
|
|
|
{
|
2006-06-15 21:34:10 +02:00
|
|
|
/* caches UIDs */
|
|
|
|
GCSFolder *folder;
|
|
|
|
NSString *rname;
|
|
|
|
|
|
|
|
if (![_uid isNotNull])
|
|
|
|
return nil;
|
2007-04-11 21:08:58 +02:00
|
|
|
if ((rname = [uidToFilename objectForKey:_uid]) != nil)
|
2006-06-15 21:34:10 +02:00
|
|
|
return [rname isNotNull] ? rname : nil;
|
|
|
|
|
|
|
|
if ((folder = [self ocsFolder]) == nil) {
|
|
|
|
[self errorWithFormat:@"(%s): missing folder for fetch!",
|
|
|
|
__PRETTY_FUNCTION__];
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
2007-04-11 21:08:58 +02:00
|
|
|
if (uidToFilename == nil)
|
|
|
|
uidToFilename = [[NSMutableDictionary alloc] initWithCapacity:16];
|
2006-06-15 21:34:10 +02:00
|
|
|
|
|
|
|
if ((rname = [self resourceNameForEventUID:_uid inFolder:folder]) == nil)
|
2007-04-11 21:08:58 +02:00
|
|
|
[uidToFilename setObject:[NSNull null] forKey:_uid];
|
2006-06-15 21:34:10 +02:00
|
|
|
else
|
2007-04-11 21:08:58 +02:00
|
|
|
[uidToFilename setObject:rname forKey:_uid];
|
2006-06-15 21:34:10 +02:00
|
|
|
|
|
|
|
return rname;
|
|
|
|
}
|
|
|
|
|
2007-07-27 19:30:57 +02:00
|
|
|
- (Class) objectClassForResourceNamed: (NSString *) name
|
2006-10-11 20:48:25 +02:00
|
|
|
{
|
|
|
|
EOQualifier *qualifier;
|
|
|
|
NSArray *records;
|
|
|
|
NSString *component;
|
|
|
|
Class objectClass;
|
|
|
|
|
2007-07-27 19:30:57 +02:00
|
|
|
qualifier = [EOQualifier qualifierWithQualifierFormat:@"c_name = %@", name];
|
2007-07-24 20:45:52 +02:00
|
|
|
records = [[self ocsFolder] fetchFields: [NSArray arrayWithObject: @"c_component"]
|
2006-10-11 20:48:25 +02:00
|
|
|
matchingQualifier: qualifier];
|
|
|
|
|
|
|
|
if ([records count])
|
|
|
|
{
|
2007-07-24 20:45:52 +02:00
|
|
|
component = [[records objectAtIndex:0] valueForKey: @"c_component"];
|
2006-10-11 20:48:25 +02:00
|
|
|
if ([component isEqualToString: @"vevent"])
|
|
|
|
objectClass = [SOGoAppointmentObject class];
|
|
|
|
else if ([component isEqualToString: @"vtodo"])
|
|
|
|
objectClass = [SOGoTaskObject class];
|
|
|
|
else
|
|
|
|
objectClass = Nil;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
objectClass = Nil;
|
|
|
|
|
|
|
|
return objectClass;
|
|
|
|
}
|
|
|
|
|
2006-06-15 21:34:10 +02:00
|
|
|
/* fetching */
|
|
|
|
|
2006-08-16 00:04:37 +02:00
|
|
|
- (NSMutableDictionary *) fixupRecord: (NSDictionary *) _record
|
|
|
|
fetchRange: (NGCalendarDateRange *) _r
|
2006-06-15 21:34:10 +02:00
|
|
|
{
|
|
|
|
NSMutableDictionary *md;
|
|
|
|
id tmp;
|
|
|
|
|
|
|
|
md = [[_record mutableCopy] autorelease];
|
|
|
|
|
2007-07-24 20:45:52 +02:00
|
|
|
if ((tmp = [_record objectForKey:@"c_startdate"])) {
|
2006-06-15 21:34:10 +02:00
|
|
|
tmp = [[NSCalendarDate alloc] initWithTimeIntervalSince1970:
|
|
|
|
(NSTimeInterval)[tmp unsignedIntValue]];
|
2007-04-11 21:08:58 +02:00
|
|
|
[tmp setTimeZone: timeZone];
|
2006-06-15 21:34:10 +02:00
|
|
|
if (tmp) [md setObject:tmp forKey:@"startDate"];
|
|
|
|
[tmp release];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
[self logWithFormat:@"missing 'startdate' in record?"];
|
|
|
|
|
2007-07-24 20:45:52 +02:00
|
|
|
if ((tmp = [_record objectForKey:@"c_enddate"])) {
|
2006-06-15 21:34:10 +02:00
|
|
|
tmp = [[NSCalendarDate alloc] initWithTimeIntervalSince1970:
|
|
|
|
(NSTimeInterval)[tmp unsignedIntValue]];
|
2007-04-11 21:08:58 +02:00
|
|
|
[tmp setTimeZone: timeZone];
|
2006-06-15 21:34:10 +02:00
|
|
|
if (tmp) [md setObject:tmp forKey:@"endDate"];
|
|
|
|
[tmp release];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
[self logWithFormat:@"missing 'enddate' in record?"];
|
|
|
|
|
|
|
|
return md;
|
|
|
|
}
|
|
|
|
|
2006-08-16 00:04:37 +02:00
|
|
|
- (NSMutableDictionary *) fixupCycleRecord: (NSDictionary *) _record
|
|
|
|
cycleRange: (NGCalendarDateRange *) _r
|
2006-06-15 21:34:10 +02:00
|
|
|
{
|
|
|
|
NSMutableDictionary *md;
|
|
|
|
id tmp;
|
|
|
|
|
|
|
|
md = [[_record mutableCopy] autorelease];
|
|
|
|
|
|
|
|
/* cycle is in _r */
|
|
|
|
tmp = [_r startDate];
|
2007-04-11 21:08:58 +02:00
|
|
|
[tmp setTimeZone: timeZone];
|
2006-06-15 21:34:10 +02:00
|
|
|
[md setObject:tmp forKey:@"startDate"];
|
|
|
|
tmp = [_r endDate];
|
2007-04-11 21:08:58 +02:00
|
|
|
[tmp setTimeZone: timeZone];
|
2006-06-15 21:34:10 +02:00
|
|
|
[md setObject:tmp forKey:@"endDate"];
|
|
|
|
|
|
|
|
return md;
|
|
|
|
}
|
|
|
|
|
2007-04-11 21:08:58 +02:00
|
|
|
- (NSArray *) fixupRecords: (NSArray *) records
|
|
|
|
fetchRange: (NGCalendarDateRange *) r
|
|
|
|
{
|
|
|
|
// TODO: is the result supposed to be sorted by date?
|
|
|
|
NSMutableArray *ma;
|
|
|
|
unsigned count, max;
|
|
|
|
id row; // TODO: what is the type of the record?
|
|
|
|
|
|
|
|
if (records)
|
|
|
|
{
|
|
|
|
max = [records count];
|
|
|
|
ma = [NSMutableArray arrayWithCapacity: max];
|
|
|
|
for (count = 0; count < max; count++)
|
|
|
|
{
|
|
|
|
row = [self fixupRecord: [records objectAtIndex: count]
|
|
|
|
fetchRange: r];
|
|
|
|
if (row)
|
|
|
|
[ma addObject: row];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ma = nil;
|
|
|
|
|
|
|
|
return ma;
|
|
|
|
}
|
|
|
|
|
2006-08-16 00:04:37 +02:00
|
|
|
- (void) _flattenCycleRecord: (NSDictionary *) _row
|
|
|
|
forRange: (NGCalendarDateRange *) _r
|
|
|
|
intoArray: (NSMutableArray *) _ma
|
2006-06-15 21:34:10 +02:00
|
|
|
{
|
|
|
|
NSMutableDictionary *row;
|
|
|
|
NSDictionary *cycleinfo;
|
|
|
|
NSCalendarDate *startDate, *endDate;
|
|
|
|
NGCalendarDateRange *fir;
|
|
|
|
NSArray *rules, *exRules, *exDates, *ranges;
|
|
|
|
unsigned i, count;
|
|
|
|
|
2007-07-24 20:45:52 +02:00
|
|
|
cycleinfo = [[_row objectForKey:@"c_cycleinfo"] propertyList];
|
2006-06-15 21:34:10 +02:00
|
|
|
if (cycleinfo == nil) {
|
|
|
|
[self errorWithFormat:@"cyclic record doesn't have cycleinfo -> %@", _row];
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-10-11 20:48:25 +02:00
|
|
|
row = [self fixupRecord:_row fetchRange: _r];
|
2007-07-24 20:45:52 +02:00
|
|
|
[row removeObjectForKey: @"c_cycleinfo"];
|
|
|
|
[row setObject: sharedYes forKey:@"isRecurrentEvent"];
|
2006-06-15 21:34:10 +02:00
|
|
|
|
2007-07-27 19:30:57 +02:00
|
|
|
startDate = [row objectForKey:@"startDate"];
|
|
|
|
endDate = [row objectForKey:@"endDate"];
|
2006-06-15 21:34:10 +02:00
|
|
|
fir = [NGCalendarDateRange calendarDateRangeWithStartDate:startDate
|
|
|
|
endDate:endDate];
|
2007-07-27 19:30:57 +02:00
|
|
|
rules = [cycleinfo objectForKey:@"rules"];
|
|
|
|
exRules = [cycleinfo objectForKey:@"exRules"];
|
|
|
|
exDates = [cycleinfo objectForKey:@"exDates"];
|
2006-06-15 21:34:10 +02:00
|
|
|
|
|
|
|
ranges = [iCalRecurrenceCalculator recurrenceRangesWithinCalendarDateRange:_r
|
|
|
|
firstInstanceCalendarDateRange:fir
|
|
|
|
recurrenceRules:rules
|
|
|
|
exceptionRules:exRules
|
|
|
|
exceptionDates:exDates];
|
|
|
|
count = [ranges count];
|
|
|
|
for (i = 0; i < count; i++) {
|
|
|
|
NGCalendarDateRange *rRange;
|
|
|
|
id fixedRow;
|
|
|
|
|
|
|
|
rRange = [ranges objectAtIndex:i];
|
|
|
|
fixedRow = [self fixupCycleRecord:row cycleRange:rRange];
|
|
|
|
if (fixedRow != nil) [_ma addObject:fixedRow];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-08-16 00:04:37 +02:00
|
|
|
- (NSArray *) fixupCyclicRecords: (NSArray *) _records
|
|
|
|
fetchRange: (NGCalendarDateRange *) _r
|
2006-06-15 21:34:10 +02:00
|
|
|
{
|
|
|
|
// TODO: is the result supposed to be sorted by date?
|
|
|
|
NSMutableArray *ma;
|
|
|
|
unsigned i, count;
|
|
|
|
|
|
|
|
if (_records == nil) return nil;
|
|
|
|
if ((count = [_records count]) == 0)
|
|
|
|
return _records;
|
|
|
|
|
|
|
|
ma = [NSMutableArray arrayWithCapacity:count];
|
|
|
|
for (i = 0; i < count; i++) {
|
|
|
|
id row; // TODO: what is the type of the record?
|
|
|
|
|
|
|
|
row = [_records objectAtIndex:i];
|
|
|
|
[self _flattenCycleRecord:row forRange:_r intoArray:ma];
|
|
|
|
}
|
|
|
|
return ma;
|
|
|
|
}
|
|
|
|
|
2006-10-11 20:48:25 +02:00
|
|
|
- (NSString *) _sqlStringForComponent: (id) _component
|
|
|
|
{
|
|
|
|
NSString *sqlString;
|
|
|
|
NSArray *components;
|
|
|
|
|
|
|
|
if (_component)
|
|
|
|
{
|
|
|
|
if ([_component isKindOfClass: [NSArray class]])
|
|
|
|
components = _component;
|
|
|
|
else
|
|
|
|
components = [NSArray arrayWithObject: _component];
|
|
|
|
|
|
|
|
sqlString
|
2007-07-24 20:45:52 +02:00
|
|
|
= [NSString stringWithFormat: @" AND (c_component = '%@')",
|
|
|
|
[components componentsJoinedByString: @"' OR c_component = '"]];
|
2006-10-11 20:48:25 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
sqlString = @"";
|
|
|
|
|
|
|
|
return sqlString;
|
|
|
|
}
|
|
|
|
|
2006-10-30 23:39:31 +01:00
|
|
|
- (NSString *) _sqlStringRangeFrom: (NSCalendarDate *) _startDate
|
|
|
|
to: (NSCalendarDate *) _endDate
|
|
|
|
{
|
|
|
|
unsigned int start, end;
|
|
|
|
|
|
|
|
start = (unsigned int) [_startDate timeIntervalSince1970];
|
|
|
|
end = (unsigned int) [_endDate timeIntervalSince1970];
|
|
|
|
|
|
|
|
return [NSString stringWithFormat:
|
2007-07-24 20:45:52 +02:00
|
|
|
@" AND (c_startdate <= %u) AND (c_enddate >= %u)",
|
2006-10-30 23:39:31 +01:00
|
|
|
end, start];
|
|
|
|
}
|
|
|
|
|
2007-04-26 03:16:19 +02:00
|
|
|
- (NSString *) _privacyClassificationStringsForUID: (NSString *) uid
|
|
|
|
{
|
|
|
|
NSMutableString *classificationString;
|
|
|
|
NSString *currentRole;
|
|
|
|
unsigned int counter;
|
|
|
|
iCalAccessClass classes[] = {iCalAccessPublic, iCalAccessPrivate,
|
|
|
|
iCalAccessConfidential};
|
|
|
|
|
|
|
|
classificationString = [NSMutableString string];
|
|
|
|
for (counter = 0; counter < 3; counter++)
|
|
|
|
{
|
|
|
|
currentRole = [self roleForComponentsWithAccessClass: classes[counter]
|
|
|
|
forUser: uid];
|
|
|
|
if ([currentRole length] > 0)
|
2007-07-27 19:30:57 +02:00
|
|
|
[classificationString appendFormat: @"c_classification = %d or ",
|
2007-04-26 03:16:19 +02:00
|
|
|
classes[counter]];
|
|
|
|
}
|
|
|
|
|
|
|
|
return classificationString;
|
|
|
|
}
|
|
|
|
|
2007-03-07 22:27:19 +01:00
|
|
|
- (NSString *) _privacySqlString
|
|
|
|
{
|
2007-06-01 06:15:56 +02:00
|
|
|
NSString *privacySqlString, *login, *email;
|
2007-03-07 22:27:19 +01:00
|
|
|
SOGoUser *activeUser;
|
|
|
|
|
|
|
|
activeUser = [context activeUser];
|
2007-04-26 18:39:09 +02:00
|
|
|
login = [activeUser login];
|
2007-03-07 22:27:19 +01:00
|
|
|
|
2007-04-26 18:39:09 +02:00
|
|
|
if ([login isEqualToString: owner])
|
2007-03-07 22:27:19 +01:00
|
|
|
privacySqlString = @"";
|
2007-04-26 18:39:09 +02:00
|
|
|
else if ([login isEqualToString: @"freebusy"])
|
2007-07-27 19:30:57 +02:00
|
|
|
privacySqlString = @"and (c_isopaque = 1)";
|
2007-03-07 22:27:19 +01:00
|
|
|
else
|
|
|
|
{
|
2007-09-15 00:01:02 +02:00
|
|
|
#warning we do not manage all the possible user emails
|
2007-08-15 22:13:41 +02:00
|
|
|
email = [[activeUser primaryIdentity] objectForKey: @"email"];
|
2007-04-26 03:16:19 +02:00
|
|
|
|
2007-03-07 22:27:19 +01:00
|
|
|
privacySqlString
|
|
|
|
= [NSString stringWithFormat:
|
2007-07-27 19:30:57 +02:00
|
|
|
@"(%@(c_orgmail = '%@')"
|
|
|
|
@" or ((c_partmails caseInsensitiveLike '%@%%'"
|
|
|
|
@" or c_partmails caseInsensitiveLike '%%\n%@%%')))",
|
2007-04-26 18:39:09 +02:00
|
|
|
[self _privacyClassificationStringsForUID: login],
|
2007-04-26 03:16:19 +02:00
|
|
|
email, email, email];
|
2007-03-07 22:27:19 +01:00
|
|
|
}
|
2007-06-29 23:59:40 +02:00
|
|
|
|
2007-03-07 22:27:19 +01:00
|
|
|
return privacySqlString;
|
|
|
|
}
|
|
|
|
|
2007-04-26 03:16:19 +02:00
|
|
|
- (NSString *) roleForComponentsWithAccessClass: (iCalAccessClass) accessClass
|
|
|
|
forUser: (NSString *) uid
|
|
|
|
{
|
|
|
|
NSString *accessRole, *prefix, *currentRole, *suffix;
|
|
|
|
NSEnumerator *acls;
|
|
|
|
|
|
|
|
accessRole = nil;
|
|
|
|
|
|
|
|
if (accessClass == iCalAccessPublic)
|
|
|
|
prefix = @"Public";
|
|
|
|
else if (accessClass == iCalAccessPrivate)
|
|
|
|
prefix = @"Private";
|
|
|
|
else
|
|
|
|
prefix = @"Confidential";
|
|
|
|
|
|
|
|
acls = [[self aclsForUser: uid] objectEnumerator];
|
|
|
|
currentRole = [acls nextObject];
|
|
|
|
while (currentRole && !accessRole)
|
|
|
|
if ([currentRole hasPrefix: prefix])
|
|
|
|
{
|
|
|
|
suffix = [currentRole substringFromIndex: [prefix length]];
|
|
|
|
accessRole = [NSString stringWithFormat: @"Component%@", suffix];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
currentRole = [acls nextObject];
|
|
|
|
|
|
|
|
return accessRole;
|
|
|
|
}
|
|
|
|
|
2006-08-16 00:04:37 +02:00
|
|
|
- (NSArray *) fetchFields: (NSArray *) _fields
|
|
|
|
fromFolder: (GCSFolder *) _folder
|
|
|
|
from: (NSCalendarDate *) _startDate
|
|
|
|
to: (NSCalendarDate *) _endDate
|
2006-10-11 20:48:25 +02:00
|
|
|
component: (id) _component
|
2006-06-15 21:34:10 +02:00
|
|
|
{
|
2006-10-11 20:48:25 +02:00
|
|
|
EOQualifier *qualifier;
|
|
|
|
NSMutableArray *fields, *ma = nil;
|
|
|
|
NSArray *records;
|
2007-06-01 06:15:56 +02:00
|
|
|
NSString *sql, *dateSqlString, *componentSqlString, *privacySqlString;
|
2006-06-15 21:34:10 +02:00
|
|
|
NGCalendarDateRange *r;
|
|
|
|
|
|
|
|
if (_folder == nil) {
|
|
|
|
[self errorWithFormat:@"(%s): missing folder for fetch!",
|
|
|
|
__PRETTY_FUNCTION__];
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
2006-10-11 20:48:25 +02:00
|
|
|
if (_startDate && _endDate)
|
|
|
|
{
|
|
|
|
r = [NGCalendarDateRange calendarDateRangeWithStartDate: _startDate
|
|
|
|
endDate: _endDate];
|
2006-10-30 23:39:31 +01:00
|
|
|
dateSqlString = [self _sqlStringRangeFrom: _startDate to: _endDate];
|
2006-10-11 20:48:25 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
r = nil;
|
|
|
|
dateSqlString = @"";
|
|
|
|
}
|
|
|
|
|
|
|
|
componentSqlString = [self _sqlStringForComponent: _component];
|
2007-03-07 22:27:19 +01:00
|
|
|
privacySqlString = [self _privacySqlString];
|
2006-06-15 21:34:10 +02:00
|
|
|
|
|
|
|
/* prepare mandatory fields */
|
|
|
|
|
2006-10-11 20:48:25 +02:00
|
|
|
fields = [NSMutableArray arrayWithArray: _fields];
|
2007-07-24 20:45:52 +02:00
|
|
|
[fields addObject: @"c_uid"];
|
|
|
|
[fields addObject: @"c_startdate"];
|
|
|
|
[fields addObject: @"c_enddate"];
|
2006-10-11 20:48:25 +02:00
|
|
|
|
2006-06-15 21:34:10 +02:00
|
|
|
if (logger)
|
|
|
|
[self debugWithFormat:@"should fetch (%@=>%@) ...", _startDate, _endDate];
|
2006-10-11 20:48:25 +02:00
|
|
|
|
2007-07-24 20:45:52 +02:00
|
|
|
sql = [NSString stringWithFormat: @"(c_iscycle = 0)%@%@%@",
|
2007-03-07 22:27:19 +01:00
|
|
|
dateSqlString, componentSqlString, privacySqlString];
|
2006-06-15 21:34:10 +02:00
|
|
|
|
|
|
|
/* fetch non-recurrent apts first */
|
2006-10-11 20:48:25 +02:00
|
|
|
qualifier = [EOQualifier qualifierWithQualifierFormat: sql];
|
|
|
|
|
|
|
|
records = [_folder fetchFields: fields matchingQualifier: qualifier];
|
|
|
|
if (records)
|
|
|
|
{
|
|
|
|
if (r)
|
|
|
|
records = [self fixupRecords: records fetchRange: r];
|
|
|
|
if (logger)
|
|
|
|
[self debugWithFormat: @"fetched %i records: %@",
|
|
|
|
[records count], records];
|
|
|
|
ma = [NSMutableArray arrayWithArray: records];
|
|
|
|
}
|
|
|
|
|
2006-06-15 21:34:10 +02:00
|
|
|
/* fetch recurrent apts now */
|
2007-07-24 20:45:52 +02:00
|
|
|
sql = [NSString stringWithFormat: @"(c_iscycle = 1)%@%@%@",
|
2007-03-07 22:27:19 +01:00
|
|
|
dateSqlString, componentSqlString, privacySqlString];
|
2006-10-11 20:48:25 +02:00
|
|
|
qualifier = [EOQualifier qualifierWithQualifierFormat: sql];
|
|
|
|
|
2007-07-24 20:45:52 +02:00
|
|
|
[fields addObject: @"c_cycleinfo"];
|
2006-10-11 20:48:25 +02:00
|
|
|
|
|
|
|
records = [_folder fetchFields: fields matchingQualifier: qualifier];
|
|
|
|
if (records)
|
|
|
|
{
|
|
|
|
if (logger)
|
|
|
|
[self debugWithFormat: @"fetched %i cyclic records: %@",
|
|
|
|
[records count], records];
|
|
|
|
if (r)
|
|
|
|
records = [self fixupCyclicRecords: records fetchRange: r];
|
|
|
|
if (!ma)
|
|
|
|
ma = [NSMutableArray arrayWithCapacity: [records count]];
|
2006-10-16 20:43:14 +02:00
|
|
|
|
2006-10-11 20:48:25 +02:00
|
|
|
[ma addObjectsFromArray: records];
|
|
|
|
}
|
|
|
|
else if (!ma)
|
|
|
|
{
|
|
|
|
[self errorWithFormat: @"(%s): fetch failed!", __PRETTY_FUNCTION__];
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
2006-06-15 21:34:10 +02:00
|
|
|
if (logger)
|
|
|
|
[self debugWithFormat:@"returning %i records", [ma count]];
|
2006-10-11 20:48:25 +02:00
|
|
|
|
2006-12-19 18:02:15 +01:00
|
|
|
// [ma makeObjectsPerform: @selector (setObject:forKey:)
|
|
|
|
// withObject: owner
|
|
|
|
// withObject: @"owner"];
|
2006-10-16 20:43:14 +02:00
|
|
|
|
2006-06-15 21:34:10 +02:00
|
|
|
return ma;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* override this in subclasses */
|
2006-08-16 00:04:37 +02:00
|
|
|
- (NSArray *) fetchFields: (NSArray *) _fields
|
|
|
|
from: (NSCalendarDate *) _startDate
|
|
|
|
to: (NSCalendarDate *) _endDate
|
2006-10-11 20:48:25 +02:00
|
|
|
component: (id) _component
|
2006-06-15 21:34:10 +02:00
|
|
|
{
|
|
|
|
GCSFolder *folder;
|
|
|
|
|
|
|
|
if ((folder = [self ocsFolder]) == nil) {
|
|
|
|
[self errorWithFormat:@"(%s): missing folder for fetch!",
|
|
|
|
__PRETTY_FUNCTION__];
|
|
|
|
return nil;
|
|
|
|
}
|
2006-10-11 20:48:25 +02:00
|
|
|
|
|
|
|
return [self fetchFields: _fields fromFolder: folder
|
|
|
|
from: _startDate to: _endDate
|
|
|
|
component: _component];
|
2006-06-15 21:34:10 +02:00
|
|
|
}
|
|
|
|
|
2006-12-14 22:20:13 +01:00
|
|
|
- (NSArray *) fetchFreeBusyInfosFrom: (NSCalendarDate *) _startDate
|
2006-08-16 00:04:37 +02:00
|
|
|
to: (NSCalendarDate *) _endDate
|
2006-06-15 21:34:10 +02:00
|
|
|
{
|
|
|
|
static NSArray *infos = nil; // TODO: move to a plist file
|
2006-10-26 02:08:24 +02:00
|
|
|
|
|
|
|
if (!infos)
|
2007-07-24 20:45:52 +02:00
|
|
|
infos = [[NSArray alloc] initWithObjects: @"c_partmails", @"c_partstates",
|
|
|
|
@"c_isopaque", @"c_status", nil];
|
2006-06-15 21:34:10 +02:00
|
|
|
|
2006-10-26 02:08:24 +02:00
|
|
|
return [self fetchFields: infos from: _startDate to: _endDate
|
|
|
|
component: @"vevent"];
|
|
|
|
}
|
2006-06-15 21:34:10 +02:00
|
|
|
|
2006-08-16 00:04:37 +02:00
|
|
|
- (NSArray *) fetchCoreInfosFrom: (NSCalendarDate *) _startDate
|
2006-10-11 20:48:25 +02:00
|
|
|
to: (NSCalendarDate *) _endDate
|
|
|
|
component: (id) _component
|
2006-06-15 21:34:10 +02:00
|
|
|
{
|
|
|
|
static NSArray *infos = nil; // TODO: move to a plist file
|
2006-08-16 00:04:37 +02:00
|
|
|
|
2006-10-11 20:48:25 +02:00
|
|
|
if (!infos)
|
|
|
|
infos = [[NSArray alloc] initWithObjects:
|
2007-07-24 20:45:52 +02:00
|
|
|
@"c_name", @"c_component",
|
|
|
|
@"c_title", @"c_location", @"c_orgmail",
|
|
|
|
@"c_status", @"c_classification",
|
|
|
|
@"c_isallday", @"c_isopaque",
|
|
|
|
@"c_participants", @"c_partmails",
|
|
|
|
@"c_partstates", @"c_sequence", @"c_priority",
|
|
|
|
nil];
|
2006-10-11 20:48:25 +02:00
|
|
|
|
2007-03-05 23:35:12 +01:00
|
|
|
return [self fetchFields: infos from: _startDate to: _endDate
|
|
|
|
component: _component];
|
2006-06-15 21:34:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* URL generation */
|
|
|
|
|
2006-08-16 00:04:37 +02:00
|
|
|
- (NSString *) baseURLForAptWithUID: (NSString *)_uid
|
|
|
|
inContext: (id)_ctx
|
|
|
|
{
|
2006-06-15 21:34:10 +02:00
|
|
|
// TODO: who calls this?
|
|
|
|
NSString *url;
|
|
|
|
|
|
|
|
if ([_uid length] == 0)
|
|
|
|
return nil;
|
|
|
|
|
|
|
|
url = [self baseURLInContext:_ctx];
|
2007-06-01 06:15:56 +02:00
|
|
|
if (![url hasSuffix: @"/"])
|
|
|
|
url = [url stringByAppendingString: @"/"];
|
2006-06-15 21:34:10 +02:00
|
|
|
|
|
|
|
// TODO: this should run a query to determine the uid!
|
|
|
|
return [url stringByAppendingString:_uid];
|
|
|
|
}
|
|
|
|
|
|
|
|
/* folder management */
|
|
|
|
|
2006-08-16 00:04:37 +02:00
|
|
|
- (id) lookupHomeFolderForUID: (NSString *) _uid
|
|
|
|
inContext: (id)_ctx
|
|
|
|
{
|
2006-06-15 21:34:10 +02:00
|
|
|
// TODO: DUP to SOGoGroupFolder
|
|
|
|
NSException *error = nil;
|
|
|
|
NSArray *path;
|
|
|
|
id ctx, result;
|
|
|
|
|
|
|
|
if (![_uid isNotNull])
|
|
|
|
return nil;
|
2007-06-01 06:15:56 +02:00
|
|
|
|
2006-06-15 21:34:10 +02:00
|
|
|
/* create subcontext, so that we don't destroy our environment */
|
|
|
|
|
2007-04-11 21:08:58 +02:00
|
|
|
if ((ctx = [context createSubContext]) == nil) {
|
2006-06-15 21:34:10 +02:00
|
|
|
[self errorWithFormat:@"could not create SOPE subcontext!"];
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* build path */
|
|
|
|
|
|
|
|
path = _uid != nil ? [NSArray arrayWithObjects:&_uid count:1] : nil;
|
|
|
|
|
|
|
|
/* traverse path */
|
|
|
|
|
|
|
|
result = [[ctx application] traversePathArray:path inContext:ctx
|
|
|
|
error:&error acquire:NO];
|
|
|
|
if (error != nil) {
|
2007-07-27 19:30:57 +02:00
|
|
|
[self errorWithFormat: @"folder lookup failed (c_uid=%@): %@",
|
2006-06-15 21:34:10 +02:00
|
|
|
_uid, error];
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
|
|
|
[self debugWithFormat:@"Note: got folder for uid %@ path %@: %@",
|
|
|
|
_uid, [path componentsJoinedByString:@"=>"], result];
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2007-01-04 15:37:07 +01:00
|
|
|
- (SOGoAppointmentFolder *) lookupCalendarFolderForUID: (NSString *) uid
|
|
|
|
{
|
|
|
|
SOGoFolder *upperContainer;
|
|
|
|
SOGoUserFolder *userFolder;
|
|
|
|
SOGoAppointmentFolder *calendarFolder;
|
|
|
|
|
|
|
|
upperContainer = [[self container] container];
|
|
|
|
userFolder = [SOGoUserFolder objectWithName: uid
|
|
|
|
inContainer: upperContainer];
|
|
|
|
calendarFolder = [SOGoAppointmentFolder objectWithName: @"Calendar"
|
|
|
|
inContainer: userFolder];
|
|
|
|
[calendarFolder
|
2007-08-24 22:38:36 +02:00
|
|
|
setOCSPath: [NSString stringWithFormat: @"/Users/%@/Calendar/personal", uid]];
|
2007-01-04 15:37:07 +01:00
|
|
|
[calendarFolder setOwner: uid];
|
|
|
|
|
|
|
|
return calendarFolder;
|
|
|
|
}
|
|
|
|
|
2006-08-16 00:04:37 +02:00
|
|
|
- (NSArray *) lookupCalendarFoldersForUIDs: (NSArray *) _uids
|
|
|
|
inContext: (id)_ctx
|
|
|
|
{
|
2006-06-15 21:34:10 +02:00
|
|
|
/* Note: can return NSNull objects in the array! */
|
|
|
|
NSMutableArray *folders;
|
|
|
|
NSEnumerator *e;
|
2007-09-15 00:01:02 +02:00
|
|
|
NSString *uid, *ownerLogin;
|
|
|
|
id folder;
|
|
|
|
|
|
|
|
ownerLogin = [self ownerInContext: context];
|
|
|
|
|
2006-06-15 21:34:10 +02:00
|
|
|
if ([_uids count] == 0) return nil;
|
|
|
|
folders = [NSMutableArray arrayWithCapacity:16];
|
|
|
|
e = [_uids objectEnumerator];
|
2007-09-15 00:01:02 +02:00
|
|
|
while ((uid = [e nextObject]))
|
|
|
|
{
|
|
|
|
if ([uid isEqualToString: ownerLogin])
|
|
|
|
folder = self;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
folder = [self lookupCalendarFolderForUID: uid];
|
|
|
|
if (![folder isNotNull])
|
|
|
|
[self logWithFormat:@"Note: did not find folder for uid: '%@'", uid];
|
|
|
|
}
|
2006-06-15 21:34:10 +02:00
|
|
|
|
2007-09-15 00:01:02 +02:00
|
|
|
[folders addObject: folder];
|
|
|
|
}
|
|
|
|
|
2006-06-15 21:34:10 +02:00
|
|
|
return folders;
|
|
|
|
}
|
|
|
|
|
2006-08-16 00:04:37 +02:00
|
|
|
- (NSArray *) lookupFreeBusyObjectsForUIDs: (NSArray *) _uids
|
|
|
|
inContext: (id) _ctx
|
|
|
|
{
|
2006-06-15 21:34:10 +02:00
|
|
|
/* Note: can return NSNull objects in the array! */
|
|
|
|
NSMutableArray *objs;
|
|
|
|
NSEnumerator *e;
|
|
|
|
NSString *uid;
|
|
|
|
|
|
|
|
if ([_uids count] == 0) return nil;
|
|
|
|
objs = [NSMutableArray arrayWithCapacity:16];
|
|
|
|
e = [_uids objectEnumerator];
|
|
|
|
while ((uid = [e nextObject])) {
|
|
|
|
id obj;
|
|
|
|
|
|
|
|
obj = [self lookupHomeFolderForUID:uid inContext:nil];
|
|
|
|
if ([obj isNotNull]) {
|
|
|
|
obj = [obj lookupName:@"freebusy.ifb" inContext:nil acquire:NO];
|
|
|
|
if ([obj isKindOfClass:[NSException class]])
|
|
|
|
obj = nil;
|
|
|
|
}
|
|
|
|
if (![obj isNotNull])
|
|
|
|
[self logWithFormat:@"Note: did not find freebusy.ifb for uid: '%@'", uid];
|
|
|
|
|
|
|
|
/* Note: intentionally add 'null' folders to allow a mapping */
|
|
|
|
[objs addObject:obj ? obj : [NSNull null]];
|
|
|
|
}
|
|
|
|
return objs;
|
|
|
|
}
|
|
|
|
|
2006-08-16 00:04:37 +02:00
|
|
|
- (NSArray *) uidsFromICalPersons: (NSArray *) _persons
|
|
|
|
{
|
2006-06-15 21:34:10 +02:00
|
|
|
/* Note: can return NSNull objects in the array! */
|
|
|
|
NSMutableArray *uids;
|
2007-05-09 20:25:51 +02:00
|
|
|
LDAPUserManager *um;
|
2006-06-15 21:34:10 +02:00
|
|
|
unsigned i, count;
|
|
|
|
|
|
|
|
if (_persons == nil)
|
|
|
|
return nil;
|
|
|
|
|
|
|
|
count = [_persons count];
|
|
|
|
uids = [NSMutableArray arrayWithCapacity:count + 1];
|
2007-05-09 20:25:51 +02:00
|
|
|
um = [LDAPUserManager sharedUserManager];
|
2006-06-15 21:34:10 +02:00
|
|
|
|
|
|
|
for (i = 0; i < count; i++) {
|
|
|
|
iCalPerson *person;
|
|
|
|
NSString *email;
|
|
|
|
NSString *uid;
|
|
|
|
|
|
|
|
person = [_persons objectAtIndex:i];
|
|
|
|
email = [person rfc822Email];
|
|
|
|
if ([email isNotNull]) {
|
|
|
|
uid = [um getUIDForEmail:email];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
uid = nil;
|
|
|
|
|
|
|
|
[uids addObject:(uid != nil ? uid : (id)[NSNull null])];
|
|
|
|
}
|
|
|
|
return uids;
|
|
|
|
}
|
|
|
|
|
2006-08-16 00:04:37 +02:00
|
|
|
- (NSArray *)lookupCalendarFoldersForICalPerson: (NSArray *) _persons
|
|
|
|
inContext: (id) _ctx
|
2006-06-15 21:34:10 +02:00
|
|
|
{
|
|
|
|
/* Note: can return NSNull objects in the array! */
|
|
|
|
NSArray *uids;
|
|
|
|
|
|
|
|
if ((uids = [self uidsFromICalPersons:_persons]) == nil)
|
|
|
|
return nil;
|
|
|
|
|
|
|
|
return [self lookupCalendarFoldersForUIDs:uids inContext:_ctx];
|
|
|
|
}
|
|
|
|
|
2006-08-16 00:04:37 +02:00
|
|
|
- (id) lookupGroupFolderForUIDs: (NSArray *) _uids
|
|
|
|
inContext: (id)_ctx
|
|
|
|
{
|
2006-06-15 21:34:10 +02:00
|
|
|
SOGoCustomGroupFolder *folder;
|
|
|
|
|
|
|
|
if (_uids == nil)
|
|
|
|
return nil;
|
|
|
|
|
|
|
|
folder = [[SOGoCustomGroupFolder alloc] initWithUIDs:_uids inContainer:self];
|
|
|
|
return [folder autorelease];
|
|
|
|
}
|
2006-08-16 00:04:37 +02:00
|
|
|
|
|
|
|
- (id) lookupGroupCalendarFolderForUIDs: (NSArray *) _uids
|
|
|
|
inContext: (id) _ctx
|
|
|
|
{
|
2006-06-15 21:34:10 +02:00
|
|
|
SOGoCustomGroupFolder *folder;
|
|
|
|
|
|
|
|
if ((folder = [self lookupGroupFolderForUIDs:_uids inContext:_ctx]) == nil)
|
|
|
|
return nil;
|
|
|
|
|
|
|
|
folder = [folder lookupName:@"Calendar" inContext:_ctx acquire:NO];
|
|
|
|
if (![folder isNotNull])
|
|
|
|
return nil;
|
|
|
|
if ([folder isKindOfClass:[NSException class]]) {
|
|
|
|
[self debugWithFormat:@"Note: could not lookup 'Calendar' in folder: %@",
|
|
|
|
folder];
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
|
|
|
return folder;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* bulk fetches */
|
|
|
|
|
2006-08-16 00:04:37 +02:00
|
|
|
- (NSArray *) fetchAllSOGoAppointments
|
|
|
|
{
|
2006-06-15 21:34:10 +02:00
|
|
|
/*
|
|
|
|
Note: very expensive method, do not use unless absolutely required.
|
|
|
|
returns an array of SOGoAppointment objects.
|
|
|
|
|
|
|
|
Note that we can leave out the filenames, supposed to be stored
|
|
|
|
in the 'uid' field of the iCalendar object!
|
|
|
|
*/
|
|
|
|
NSMutableArray *events;
|
|
|
|
NSDictionary *files;
|
|
|
|
NSEnumerator *contents;
|
|
|
|
NSString *content;
|
|
|
|
|
|
|
|
/* fetch all raw contents */
|
|
|
|
|
|
|
|
files = [self fetchContentStringsAndNamesOfAllObjects];
|
|
|
|
if (![files isNotNull]) return nil;
|
|
|
|
if ([files isKindOfClass:[NSException class]]) return (id)files;
|
|
|
|
|
|
|
|
/* transform to SOGo appointments */
|
|
|
|
|
|
|
|
events = [NSMutableArray arrayWithCapacity:[files count]];
|
|
|
|
contents = [files objectEnumerator];
|
2006-09-28 19:22:44 +02:00
|
|
|
while ((content = [contents nextObject]) != nil)
|
2006-09-29 20:31:20 +02:00
|
|
|
[events addObject: [iCalCalendar parseSingleFromSource: content]];
|
2006-06-15 21:34:10 +02:00
|
|
|
|
|
|
|
return events;
|
|
|
|
}
|
|
|
|
|
2007-09-15 00:01:02 +02:00
|
|
|
// #warning We only support ONE calendar per user at this time
|
|
|
|
// - (BOOL) _appendSubscribedFolders: (NSDictionary *) subscribedFolders
|
|
|
|
// toFolderList: (NSMutableArray *) calendarFolders
|
|
|
|
// {
|
|
|
|
// NSEnumerator *keys;
|
|
|
|
// NSString *currentKey;
|
|
|
|
// NSMutableDictionary *currentCalendar;
|
|
|
|
// BOOL firstShouldBeActive;
|
|
|
|
// unsigned int count;
|
|
|
|
|
|
|
|
// firstShouldBeActive = YES;
|
|
|
|
|
|
|
|
// keys = [[subscribedFolders allKeys] objectEnumerator];
|
|
|
|
// currentKey = [keys nextObject];
|
|
|
|
// count = 1;
|
|
|
|
// while (currentKey)
|
|
|
|
// {
|
|
|
|
// currentCalendar = [NSMutableDictionary new];
|
|
|
|
// [currentCalendar autorelease];
|
|
|
|
// [currentCalendar
|
|
|
|
// setDictionary: [subscribedFolders objectForKey: currentKey]];
|
|
|
|
// [currentCalendar setObject: currentKey forKey: @"folder"];
|
|
|
|
// [calendarFolders addObject: currentCalendar];
|
|
|
|
// if ([[currentCalendar objectForKey: @"active"] boolValue])
|
|
|
|
// firstShouldBeActive = NO;
|
|
|
|
// count++;
|
|
|
|
// currentKey = [keys nextObject];
|
|
|
|
// }
|
|
|
|
|
|
|
|
// return firstShouldBeActive;
|
|
|
|
// }
|
2007-04-02 21:24:49 +02:00
|
|
|
|
2007-09-15 00:01:02 +02:00
|
|
|
// - (NSArray *) calendarFolders
|
|
|
|
// {
|
|
|
|
// NSMutableDictionary *userCalendar, *calendarDict;
|
|
|
|
// NSMutableArray *calendarFolders;
|
|
|
|
// SOGoUser *calendarUser;
|
|
|
|
// BOOL firstActive;
|
|
|
|
|
|
|
|
// calendarFolders = [NSMutableArray new];
|
|
|
|
// [calendarFolders autorelease];
|
|
|
|
|
|
|
|
// calendarUser = [SOGoUser userWithLogin: [self ownerInContext: context]
|
|
|
|
// roles: nil];
|
|
|
|
// userCalendar = [NSMutableDictionary new];
|
|
|
|
// [userCalendar autorelease];
|
|
|
|
// [userCalendar setObject: @"/" forKey: @"folder"];
|
|
|
|
// [userCalendar setObject: @"Calendar" forKey: @"displayName"];
|
|
|
|
// [calendarFolders addObject: userCalendar];
|
|
|
|
|
|
|
|
// calendarDict = [[calendarUser userSettings] objectForKey: @"Calendar"];
|
|
|
|
// firstActive = [[calendarDict objectForKey: @"activateUserFolder"] boolValue];
|
|
|
|
// firstActive = ([self _appendSubscribedFolders:
|
|
|
|
// [calendarDict objectForKey: @"SubscribedFolders"]
|
|
|
|
// toFolderList: calendarFolders]
|
|
|
|
// || firstActive);
|
|
|
|
// [userCalendar setObject: [NSNumber numberWithBool: firstActive]
|
|
|
|
// forKey: @"active"];
|
|
|
|
|
|
|
|
// return calendarFolders;
|
|
|
|
// }
|
2007-04-02 21:24:49 +02:00
|
|
|
|
2007-06-01 06:15:56 +02:00
|
|
|
// - (NSArray *) fetchContentObjectNames
|
|
|
|
// {
|
|
|
|
// NSMutableArray *objectNames;
|
|
|
|
// NSArray *records;
|
|
|
|
// NSCalendarDate *today, *startDate, *endDate;
|
|
|
|
|
|
|
|
// #warning this should be user-configurable
|
|
|
|
// objectNames = [NSMutableArray array];
|
|
|
|
// today = [[NSCalendarDate calendarDate] beginOfDay];
|
|
|
|
// [today setTimeZone: timeZone];
|
|
|
|
|
|
|
|
// startDate = [today dateByAddingYears: 0 months: 0 days: -1
|
|
|
|
// hours: 0 minutes: 0 seconds: 0];
|
|
|
|
// endDate = [startDate dateByAddingYears: 0 months: 0 days: 2
|
|
|
|
// hours: 0 minutes: 0 seconds: 0];
|
|
|
|
// records = [self fetchFields: [NSArray arrayWithObject: @"c_name"]
|
|
|
|
// from: startDate to: endDate
|
|
|
|
// component: @"vevent"];
|
|
|
|
// [objectNames addObjectsFromArray: [records valueForKey: @"c_name"]];
|
|
|
|
// records = [self fetchFields: [NSArray arrayWithObject: @"c_name"]
|
|
|
|
// from: startDate to: endDate
|
|
|
|
// component: @"vtodo"];
|
|
|
|
// [objectNames addObjectsFromArray: [records valueForKey: @"c_name"]];
|
|
|
|
|
|
|
|
// return objectNames;
|
|
|
|
// }
|
2007-05-15 23:49:50 +02:00
|
|
|
|
2006-06-15 21:34:10 +02:00
|
|
|
/* folder type */
|
|
|
|
|
2007-02-09 22:21:35 +01:00
|
|
|
- (NSString *) folderType
|
|
|
|
{
|
|
|
|
return @"Appointment";
|
|
|
|
}
|
|
|
|
|
2006-08-16 00:04:37 +02:00
|
|
|
- (NSString *) outlookFolderClass
|
|
|
|
{
|
2006-06-15 21:34:10 +02:00
|
|
|
return @"IPF.Appointment";
|
|
|
|
}
|
|
|
|
|
2007-09-15 00:01:02 +02:00
|
|
|
- (BOOL) isActive
|
2007-08-24 20:47:32 +02:00
|
|
|
{
|
2007-09-15 00:01:02 +02:00
|
|
|
NSUserDefaults *settings;
|
|
|
|
NSArray *activeFolders;
|
2007-08-24 20:47:32 +02:00
|
|
|
|
2007-09-15 00:01:02 +02:00
|
|
|
settings = [[context activeUser] userSettings];
|
|
|
|
activeFolders
|
|
|
|
= [[settings objectForKey: @"Calendar"] objectForKey: @"ActiveFolders"];
|
2007-08-24 20:47:32 +02:00
|
|
|
|
2007-09-15 00:01:02 +02:00
|
|
|
return [activeFolders containsObject: nameInContainer];
|
2007-08-24 20:47:32 +02:00
|
|
|
}
|
|
|
|
|
2006-06-15 21:34:10 +02:00
|
|
|
@end /* SOGoAppointmentFolder */
|