2008-04-22 01:03:48 +02:00
|
|
|
/* UIxCalendarProperties.m - this file is part of SOGo
|
|
|
|
*
|
2009-09-23 16:16:50 +02:00
|
|
|
* Copyright (C) 2008-2009 Inverse inc.
|
2008-04-22 01:03:48 +02:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2009-08-18 03:03:05 +02:00
|
|
|
#import <Foundation/NSDictionary.h>
|
|
|
|
#import <Foundation/NSEnumerator.h>
|
2010-06-05 06:46:12 +02:00
|
|
|
#import <Foundation/NSURL.h>
|
2009-08-18 03:03:05 +02:00
|
|
|
|
2009-08-20 22:06:43 +02:00
|
|
|
#import <NGObjWeb/WORequest.h>
|
|
|
|
|
2009-11-29 05:19:32 +01:00
|
|
|
#import <SOGo/SOGoUser.h>
|
|
|
|
#import <SOGo/SOGoUserSettings.h>
|
|
|
|
#import <Appointments/SOGoAppointmentFolder.h>
|
2010-04-19 23:30:25 +02:00
|
|
|
#import <Appointments/SOGoWebAppointmentFolder.h>
|
2008-04-22 01:03:48 +02:00
|
|
|
|
|
|
|
#import "UIxCalendarProperties.h"
|
|
|
|
|
|
|
|
@implementation UIxCalendarProperties
|
|
|
|
|
|
|
|
- (id) init
|
|
|
|
{
|
|
|
|
if ((self = [super init]))
|
|
|
|
{
|
|
|
|
calendar = [self clientObject];
|
2010-06-05 06:46:12 +02:00
|
|
|
baseCalDAVURL = nil;
|
2009-07-21 20:45:25 +02:00
|
|
|
reloadTasks = NO;
|
2008-04-22 01:03:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2010-06-05 06:46:12 +02:00
|
|
|
- (void) dealloc
|
|
|
|
{
|
|
|
|
[baseCalDAVURL release];
|
|
|
|
[super dealloc];
|
|
|
|
}
|
|
|
|
|
2008-04-22 01:03:48 +02:00
|
|
|
- (NSString *) calendarID
|
|
|
|
{
|
|
|
|
return [calendar folderReference];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) calendarName
|
|
|
|
{
|
|
|
|
return [calendar displayName];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setCalendarName: (NSString *) newName
|
|
|
|
{
|
2010-03-10 22:53:26 +01:00
|
|
|
[calendar renameTo: newName];
|
2008-04-22 01:03:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) calendarColor
|
|
|
|
{
|
|
|
|
return [calendar calendarColor];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setCalendarColor: (NSString *) newColor
|
|
|
|
{
|
|
|
|
[calendar setCalendarColor: newColor];
|
|
|
|
}
|
|
|
|
|
2010-05-06 21:30:14 +02:00
|
|
|
- (BOOL) includeInFreeBusy
|
|
|
|
{
|
|
|
|
return [calendar includeInFreeBusy];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setIncludeInFreeBusy: (BOOL) newInclude
|
|
|
|
{
|
|
|
|
[calendar setIncludeInFreeBusy: newInclude];
|
|
|
|
}
|
|
|
|
|
2009-08-18 03:03:05 +02:00
|
|
|
- (BOOL) synchronizeCalendar
|
|
|
|
{
|
|
|
|
return [self mustSynchronize] || [calendar synchronizeCalendar];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setSynchronizeCalendar: (BOOL) new
|
|
|
|
{
|
|
|
|
[calendar setSynchronizeCalendar: new];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) originalCalendarSyncTag
|
|
|
|
{
|
|
|
|
return [calendar syncTag];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) allCalendarSyncTags
|
|
|
|
{
|
2009-11-29 05:19:32 +01:00
|
|
|
SOGoUserSettings *settings;
|
2009-08-18 03:03:05 +02:00
|
|
|
NSMutableDictionary *calendarSettings;
|
|
|
|
NSMutableDictionary *syncTags;
|
|
|
|
NSEnumerator *keysList;
|
|
|
|
NSMutableArray *tags;
|
|
|
|
NSString *key, *result;
|
|
|
|
|
|
|
|
settings = [[context activeUser] userSettings];
|
|
|
|
calendarSettings = [settings objectForKey: @"Calendar"];
|
2009-09-07 19:47:30 +02:00
|
|
|
tags = nil;
|
|
|
|
|
2009-08-18 03:03:05 +02:00
|
|
|
if (calendarSettings)
|
|
|
|
{
|
|
|
|
syncTags = [calendarSettings objectForKey: @"FolderSyncTags"];
|
|
|
|
if (syncTags)
|
|
|
|
{
|
|
|
|
tags = [NSMutableArray arrayWithCapacity: [syncTags count]];
|
|
|
|
keysList = [syncTags keyEnumerator];
|
|
|
|
while ((key = (NSString*)[keysList nextObject])) {
|
|
|
|
if (![key isEqualToString: [calendar folderReference]])
|
|
|
|
[tags addObject: [syncTags objectForKey: key]];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!tags)
|
|
|
|
result = @"";
|
|
|
|
else
|
|
|
|
result = [tags componentsJoinedByString: @","];
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL) mustSynchronize
|
|
|
|
{
|
|
|
|
return [[calendar nameInContainer] isEqualToString: @"personal"];
|
|
|
|
}
|
|
|
|
|
2008-06-20 16:52:24 +02:00
|
|
|
- (NSString *) calendarSyncTag
|
|
|
|
{
|
|
|
|
return [calendar syncTag];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setCalendarSyncTag: (NSString *) newTag
|
|
|
|
{
|
|
|
|
[calendar setSyncTag: newTag];
|
|
|
|
}
|
|
|
|
|
2009-07-21 20:06:55 +02:00
|
|
|
- (BOOL) showCalendarAlarms
|
|
|
|
{
|
|
|
|
return [calendar showCalendarAlarms];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setShowCalendarAlarms: (BOOL) new
|
|
|
|
{
|
2009-07-21 20:45:25 +02:00
|
|
|
if (new != [calendar showCalendarAlarms])
|
|
|
|
reloadTasks = YES;
|
2009-07-21 20:06:55 +02:00
|
|
|
[calendar setShowCalendarAlarms: new];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL) showCalendarTasks
|
|
|
|
{
|
|
|
|
return [calendar showCalendarTasks];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setShowCalendarTasks: (BOOL) new
|
|
|
|
{
|
2009-07-21 20:45:25 +02:00
|
|
|
if (new != [calendar showCalendarTasks])
|
|
|
|
reloadTasks = YES;
|
2009-07-21 20:06:55 +02:00
|
|
|
[calendar setShowCalendarTasks: new];
|
|
|
|
}
|
|
|
|
|
2010-05-06 21:30:14 +02:00
|
|
|
- (BOOL) userIsOwner
|
|
|
|
{
|
|
|
|
NSString *userLogin;
|
|
|
|
|
|
|
|
userLogin = [[context activeUser] login];
|
|
|
|
|
|
|
|
return ([userLogin isEqualToString: [calendar ownerInContext: context]]);
|
|
|
|
}
|
|
|
|
|
2009-09-21 16:10:16 +02:00
|
|
|
- (BOOL) isWebCalendar
|
|
|
|
{
|
2010-04-19 23:30:25 +02:00
|
|
|
return ([calendar isKindOfClass: [SOGoWebAppointmentFolder class]]);
|
|
|
|
}
|
|
|
|
|
2010-06-11 20:43:46 +02:00
|
|
|
- (NSString *) webCalendarURL
|
|
|
|
{
|
|
|
|
return [calendar folderPropertyValueInCategory: @"WebCalendars"];
|
|
|
|
}
|
|
|
|
|
2010-04-19 23:30:25 +02:00
|
|
|
- (void) setReloadOnLogin: (BOOL) newReloadOnLogin
|
|
|
|
{
|
|
|
|
if ([calendar respondsToSelector: @selector (setReloadOnLogin:)])
|
|
|
|
[(SOGoWebAppointmentFolder *) calendar
|
|
|
|
setReloadOnLogin: newReloadOnLogin];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL) reloadOnLogin
|
|
|
|
{
|
|
|
|
BOOL rc;
|
|
|
|
|
|
|
|
if ([calendar respondsToSelector: @selector (reloadOnLogin)])
|
|
|
|
rc = [(SOGoWebAppointmentFolder *) calendar reloadOnLogin];
|
|
|
|
else
|
|
|
|
rc = NO;
|
|
|
|
|
|
|
|
return rc;
|
2009-09-21 16:10:16 +02:00
|
|
|
}
|
|
|
|
|
2008-04-22 01:03:48 +02:00
|
|
|
- (BOOL) shouldTakeValuesFromRequest: (WORequest *) request
|
|
|
|
inContext: (WOContext*) context
|
|
|
|
{
|
2009-07-21 20:06:55 +02:00
|
|
|
NSString *method;
|
|
|
|
|
|
|
|
method = [[request uri] lastPathComponent];
|
|
|
|
|
|
|
|
return [method isEqualToString: @"saveProperties"];
|
2008-04-22 01:03:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (id <WOActionResults>) savePropertiesAction
|
|
|
|
{
|
2010-04-19 23:30:25 +02:00
|
|
|
NSString *action;
|
2009-07-21 20:45:25 +02:00
|
|
|
|
|
|
|
if (reloadTasks)
|
|
|
|
action = @"refreshTasks()";
|
2010-04-19 23:30:25 +02:00
|
|
|
else
|
|
|
|
action = nil;
|
2009-07-21 20:45:25 +02:00
|
|
|
return [self jsCloseWithRefreshMethod: action];
|
2008-04-22 01:03:48 +02:00
|
|
|
}
|
|
|
|
|
2010-06-05 06:46:12 +02:00
|
|
|
- (NSString *) _baseCalDAVURL
|
|
|
|
{
|
|
|
|
NSString *davURL;
|
|
|
|
|
|
|
|
if (!baseCalDAVURL)
|
|
|
|
{
|
|
|
|
davURL = [[calendar realDavURL] absoluteString];
|
|
|
|
if ([davURL hasSuffix: @"/"])
|
|
|
|
baseCalDAVURL = [davURL substringToIndex: [davURL length] - 1];
|
|
|
|
else
|
|
|
|
baseCalDAVURL = davURL;
|
|
|
|
[baseCalDAVURL retain];
|
|
|
|
}
|
|
|
|
|
|
|
|
return baseCalDAVURL;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) calDavURL
|
|
|
|
{
|
|
|
|
return [NSString stringWithFormat: @"%@/", [self _baseCalDAVURL]];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) webDavICSURL
|
|
|
|
{
|
|
|
|
return [NSString stringWithFormat: @"%@.ics", [self _baseCalDAVURL]];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) webDavXMLURL
|
|
|
|
{
|
|
|
|
return [NSString stringWithFormat: @"%@.xml", [self _baseCalDAVURL]];
|
|
|
|
}
|
|
|
|
|
2008-04-22 01:03:48 +02:00
|
|
|
@end
|