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>
|
|
|
|
|
2009-08-20 22:06:43 +02:00
|
|
|
#import <NGObjWeb/WORequest.h>
|
|
|
|
|
2008-04-22 01:03:48 +02:00
|
|
|
#import <SoObjects/SOGo/SOGoUser.h>
|
|
|
|
#import <SoObjects/Appointments/SOGoAppointmentFolder.h>
|
|
|
|
|
|
|
|
#import "UIxCalendarProperties.h"
|
|
|
|
|
|
|
|
@implementation UIxCalendarProperties
|
|
|
|
|
|
|
|
- (id) init
|
|
|
|
{
|
|
|
|
if ((self = [super init]))
|
|
|
|
{
|
|
|
|
calendar = [self clientObject];
|
2009-07-21 20:45:25 +02:00
|
|
|
reloadTasks = NO;
|
2008-04-22 01:03:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) calendarID
|
|
|
|
{
|
|
|
|
return [calendar folderReference];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) calendarName
|
|
|
|
{
|
|
|
|
return [calendar displayName];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setCalendarName: (NSString *) newName
|
|
|
|
{
|
|
|
|
NSString *login;
|
|
|
|
|
|
|
|
login = [[context activeUser] login];
|
|
|
|
|
|
|
|
if ([login isEqualToString: [calendar ownerInContext: context]])
|
|
|
|
[calendar renameTo: newName];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) calendarNameIsDisabled
|
|
|
|
{
|
|
|
|
NSString *login;
|
|
|
|
|
|
|
|
login = [[context activeUser] login];
|
|
|
|
|
|
|
|
return ([login isEqualToString: [calendar ownerInContext: context]]
|
|
|
|
? @"false" : @"true");
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) calendarColor
|
|
|
|
{
|
|
|
|
return [calendar calendarColor];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setCalendarColor: (NSString *) newColor
|
|
|
|
{
|
|
|
|
[calendar setCalendarColor: newColor];
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
{
|
|
|
|
NSUserDefaults *settings;
|
|
|
|
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];
|
|
|
|
}
|
|
|
|
|
2009-09-21 16:10:16 +02:00
|
|
|
- (NSString *) webCalendarURL
|
|
|
|
{
|
|
|
|
NSUserDefaults *settings;
|
|
|
|
NSMutableDictionary *calendarSettings;
|
|
|
|
NSMutableDictionary *webCalendars;
|
|
|
|
NSString *rc;
|
|
|
|
|
|
|
|
settings = [[context activeUser] userSettings];
|
|
|
|
calendarSettings = [settings objectForKey: @"Calendar"];
|
2009-09-23 16:16:50 +02:00
|
|
|
rc = nil;
|
2009-09-21 16:10:16 +02:00
|
|
|
|
|
|
|
if (calendarSettings)
|
|
|
|
{
|
|
|
|
webCalendars = [calendarSettings objectForKey: @"WebCalendars"];
|
|
|
|
if (webCalendars)
|
|
|
|
rc = [webCalendars objectForKey: [calendar nameInContainer]];
|
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL) isWebCalendar
|
|
|
|
{
|
|
|
|
return ([self webCalendarURL] != nil);
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
{
|
2009-07-21 20:45:25 +02:00
|
|
|
NSString *action = nil;
|
|
|
|
|
|
|
|
if (reloadTasks)
|
|
|
|
action = @"refreshTasks()";
|
|
|
|
return [self jsCloseWithRefreshMethod: action];
|
2008-04-22 01:03:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@end
|