/* SOGoCalendarProxy.m - this file is part of SOGo * * Copyright (C) 2009 Inverse inc. * * Author: Wolfgang Sourdeau * * 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 #import #import #import #import #import #import #import #import #import "SOGoAppointmentFolders.h" #import "SOGoCalendarProxy.h" @implementation SOGoCalendarProxy - (id) init { if ((self = [super init])) { hasWriteAccess = NO; } return self; } - (void) setWriteAccess: (BOOL) newHasWriteAccess { hasWriteAccess = newHasWriteAccess; } - (NSArray *) davResourceType { NSString *proxyType; NSMutableArray *rType; rType = [NSMutableArray arrayWithArray: [super davResourceType]]; [rType addObject: @"principal"]; if (hasWriteAccess) proxyType = @"calendar-proxy-write"; else proxyType = @"calendar-proxy-read"; [rType addObject: [NSArray arrayWithObjects: proxyType, XMLNS_CalendarServerOrg, nil]]; return rType; } - (NSArray *) davGroupMemberSet { NSMutableArray *members; NSArray *proxySubscribers, *member; NSString *appName, *proxyUser; int count, max; appName = [[context request] applicationName]; proxySubscribers = [[container lookupName: @"Calendar" inContext: context acquire: NO] proxySubscribersWithWriteAccess: hasWriteAccess]; max = [proxySubscribers count]; members = [NSMutableArray arrayWithCapacity: max]; for (count = 0; count < max; count++) { proxyUser = [proxySubscribers objectAtIndex: count]; member = [NSArray arrayWithObjects: @"href", XMLNS_WEBDAV, @"D", [NSString stringWithFormat: @"/%@/dav/%@/", appName, proxyUser], nil]; [members addObject: member]; } return members; } - (NSString *) _parseSubscriber: (NSString *) memberSet until: (int) length { int begin, end; NSRange beginRange; end = length; if ([memberSet characterAtIndex: end - 1] == '/') end--; beginRange = [memberSet rangeOfString: @"/" options: NSBackwardsSearch range: NSMakeRange (0, end)]; begin = NSMaxRange (beginRange); return [memberSet substringWithRange: NSMakeRange (begin, end - begin)]; } - (NSArray *) _parseSubscribers: (NSString *) memberSet { NSRange endRange; NSMutableArray *subscribers; NSMutableString *mMemberSet; NSString *subscriber; subscribers = [NSMutableArray array]; mMemberSet = [NSMutableString stringWithString: memberSet]; endRange = [mMemberSet rangeOfString: @"