2007-06-19 19:58:21 +02:00
|
|
|
/* UIxPreferences.m - this file is part of SOGo
|
|
|
|
*
|
2009-04-01 15:49:24 +02:00
|
|
|
* Copyright (C) 2007-2009 Inverse inc.
|
2007-06-19 19:58:21 +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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#import <Foundation/NSCalendarDate.h>
|
2010-03-02 20:57:30 +01:00
|
|
|
#import <Foundation/NSPropertyList.h>
|
|
|
|
#import <Foundation/NSScanner.h>
|
2007-06-19 19:58:21 +02:00
|
|
|
#import <Foundation/NSString.h>
|
|
|
|
#import <Foundation/NSTimeZone.h>
|
2009-11-29 05:19:32 +01:00
|
|
|
#import <Foundation/NSUserDefaults.h> /* for locale strings */
|
2009-10-09 22:30:42 +02:00
|
|
|
#import <Foundation/NSValue.h>
|
2007-06-19 19:58:21 +02:00
|
|
|
|
|
|
|
#import <NGObjWeb/WOContext.h>
|
|
|
|
#import <NGObjWeb/WORequest.h>
|
|
|
|
|
2009-10-14 14:01:59 +02:00
|
|
|
#import <NGExtensions/NSObject+Logs.h>
|
|
|
|
|
2009-11-29 05:19:32 +01:00
|
|
|
#import <SOGo/NSArray+Utilities.h>
|
2009-12-01 17:53:15 +01:00
|
|
|
#import <SOGo/NSDictionary+BSJSONAdditions.h>
|
2009-11-29 05:19:32 +01:00
|
|
|
#import <SOGo/NSDictionary+Utilities.h>
|
2010-03-02 20:57:30 +01:00
|
|
|
#import <SOGo/NSScanner+BSJSONAdditions.h>
|
2009-11-29 05:19:32 +01:00
|
|
|
#import <SOGo/NSString+Utilities.h>
|
|
|
|
#import <SOGo/SOGoUser.h>
|
|
|
|
#import <SOGo/SOGoUserDefaults.h>
|
|
|
|
#import <SOGo/SOGoDomainDefaults.h>
|
|
|
|
#import <SOGo/SOGoSystemDefaults.h>
|
|
|
|
#import <SOGo/SOGoUserFolder.h>
|
|
|
|
#import <Mailer/SOGoMailAccount.h>
|
2009-04-01 15:49:24 +02:00
|
|
|
#import "../../Main/SOGo.h"
|
2007-06-19 19:58:21 +02:00
|
|
|
|
|
|
|
#import "UIxPreferences.h"
|
|
|
|
|
|
|
|
#warning this class is not finished
|
|
|
|
/* remaining:
|
|
|
|
default event length
|
|
|
|
default snooze length
|
|
|
|
refresh calendar every X minutes
|
|
|
|
workweek = from -> to
|
|
|
|
identities */
|
|
|
|
|
|
|
|
@implementation UIxPreferences
|
|
|
|
|
|
|
|
- (id) init
|
|
|
|
{
|
2008-12-23 01:12:14 +01:00
|
|
|
//NSDictionary *locale;
|
2009-11-29 05:19:32 +01:00
|
|
|
SOGoDomainDefaults *dd;
|
2008-12-23 01:12:14 +01:00
|
|
|
NSString *language;
|
2007-06-19 19:58:21 +02:00
|
|
|
|
|
|
|
if ((self = [super init]))
|
|
|
|
{
|
|
|
|
item = nil;
|
|
|
|
ASSIGN (user, [context activeUser]);
|
|
|
|
ASSIGN (userDefaults, [user userDefaults]);
|
|
|
|
ASSIGN (today, [NSCalendarDate date]);
|
2008-12-23 01:12:14 +01:00
|
|
|
//locale = [context valueForKey: @"locale"];
|
2009-11-29 05:19:32 +01:00
|
|
|
language = [userDefaults language];
|
|
|
|
|
2009-12-01 17:53:15 +01:00
|
|
|
calendarCategories = nil;
|
|
|
|
calendarCategoriesColors = nil;
|
|
|
|
defaultCategoryColor = nil;
|
|
|
|
category = nil;
|
|
|
|
|
2009-11-29 05:19:32 +01:00
|
|
|
ASSIGN (locale,
|
|
|
|
[[WOApplication application] localeForLanguageNamed: language]);
|
|
|
|
ASSIGN (daysOfWeek, [locale objectForKey: NSWeekDayNameArray]);
|
2009-10-09 22:30:42 +02:00
|
|
|
|
2009-11-29 05:19:32 +01:00
|
|
|
dd = [user domainDefaults];
|
2010-03-02 20:57:30 +01:00
|
|
|
if ([dd sieveScriptsEnabled])
|
|
|
|
{
|
|
|
|
sieveFilters = [[userDefaults sieveFilters] copy];
|
|
|
|
if (!sieveFilters)
|
|
|
|
sieveFilters = [NSArray new];
|
|
|
|
}
|
|
|
|
|
2009-11-29 05:19:32 +01:00
|
|
|
if ([dd vacationEnabled])
|
2009-10-09 22:30:42 +02:00
|
|
|
{
|
2009-12-01 15:29:56 +01:00
|
|
|
vacationOptions = [[userDefaults vacationOptions] mutableCopy];
|
2009-10-09 22:30:42 +02:00
|
|
|
if (!vacationOptions)
|
2009-12-07 17:16:01 +01:00
|
|
|
vacationOptions = [NSMutableDictionary new];
|
2009-10-09 22:30:42 +02:00
|
|
|
}
|
2009-11-26 17:59:29 +01:00
|
|
|
|
2009-11-29 05:19:32 +01:00
|
|
|
if ([dd forwardEnabled])
|
2009-10-09 22:30:42 +02:00
|
|
|
{
|
2009-12-01 15:29:56 +01:00
|
|
|
forwardOptions = [[userDefaults forwardOptions] mutableCopy];
|
2009-10-09 22:30:42 +02:00
|
|
|
if (!forwardOptions)
|
2009-12-07 17:16:01 +01:00
|
|
|
forwardOptions = [NSMutableDictionary new];
|
2009-10-09 22:30:42 +02:00
|
|
|
}
|
2007-06-19 19:58:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) dealloc
|
|
|
|
{
|
|
|
|
[today release];
|
|
|
|
[item release];
|
|
|
|
[user release];
|
|
|
|
[userDefaults release];
|
2010-03-02 20:57:30 +01:00
|
|
|
[sieveFilters release];
|
2009-11-26 17:59:29 +01:00
|
|
|
[vacationOptions release];
|
2009-12-01 17:53:15 +01:00
|
|
|
[calendarCategories release];
|
|
|
|
[calendarCategoriesColors release];
|
|
|
|
[defaultCategoryColor release];
|
|
|
|
[category release];
|
2009-11-26 17:59:29 +01:00
|
|
|
[forwardOptions release];
|
2007-06-19 19:58:21 +02:00
|
|
|
[daysOfWeek release];
|
2008-12-23 01:12:14 +01:00
|
|
|
[locale release];
|
2007-06-19 19:58:21 +02:00
|
|
|
[super dealloc];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setItem: (NSString *) newItem
|
|
|
|
{
|
|
|
|
ASSIGN (item, newItem);
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) item
|
|
|
|
{
|
|
|
|
return item;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSArray *) timeZonesList
|
|
|
|
{
|
2007-09-15 00:01:02 +02:00
|
|
|
return [[NSTimeZone knownTimeZoneNames]
|
2009-10-05 17:30:25 +02:00
|
|
|
sortedArrayUsingSelector: @selector (localizedCaseInsensitiveCompare:)];
|
2007-06-19 19:58:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) userTimeZone
|
|
|
|
{
|
2009-11-29 05:19:32 +01:00
|
|
|
return [userDefaults timeZoneName];
|
2007-06-19 19:58:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setUserTimeZone: (NSString *) newUserTimeZone
|
|
|
|
{
|
2009-11-29 05:19:32 +01:00
|
|
|
[userDefaults setTimeZoneName: newUserTimeZone];
|
2007-06-19 19:58:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSArray *) shortDateFormatsList
|
|
|
|
{
|
|
|
|
NSMutableArray *shortDateFormatsList = nil;
|
|
|
|
NSString *key, *currentFormat;
|
|
|
|
unsigned int nbr;
|
|
|
|
BOOL done;
|
|
|
|
|
2009-10-08 18:24:31 +02:00
|
|
|
shortDateFormatsList = [NSMutableArray arrayWithObject: @"default"];
|
2007-06-19 19:58:21 +02:00
|
|
|
|
|
|
|
nbr = 0;
|
|
|
|
done = NO;
|
|
|
|
while (!done)
|
|
|
|
{
|
|
|
|
key = [NSString stringWithFormat: @"shortDateFmt_%d", nbr];
|
|
|
|
currentFormat = [self labelForKey: key];
|
|
|
|
if ([currentFormat length] > 0)
|
2009-10-05 17:30:25 +02:00
|
|
|
{
|
|
|
|
[shortDateFormatsList addObject: currentFormat];
|
|
|
|
nbr++;
|
|
|
|
}
|
2007-06-19 19:58:21 +02:00
|
|
|
else
|
2009-10-05 17:30:25 +02:00
|
|
|
done = YES;
|
2007-06-19 19:58:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return shortDateFormatsList;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) itemShortDateFormatText
|
|
|
|
{
|
2009-10-08 18:24:31 +02:00
|
|
|
NSString *todayText, *shortDateFormatText;
|
|
|
|
|
|
|
|
if ([item isEqualToString: @"default"])
|
|
|
|
{
|
|
|
|
todayText = [today descriptionWithCalendarFormat: [locale objectForKey: NSShortDateFormatString]
|
|
|
|
locale: locale];
|
|
|
|
shortDateFormatText = [NSString stringWithFormat: @"%@ (%@)",
|
|
|
|
[self labelForKey: item],
|
|
|
|
todayText];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
shortDateFormatText = [today descriptionWithCalendarFormat: item
|
|
|
|
locale: locale];
|
|
|
|
|
|
|
|
return shortDateFormatText;
|
2007-06-19 19:58:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) userShortDateFormat
|
|
|
|
{
|
2009-11-29 05:19:32 +01:00
|
|
|
return [userDefaults shortDateFormat];
|
2007-06-19 19:58:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setUserShortDateFormat: (NSString *) newFormat
|
|
|
|
{
|
2009-12-11 15:57:57 +01:00
|
|
|
if ([newFormat isEqualToString: @"default"])
|
|
|
|
[userDefaults unsetShortDateFormat];
|
|
|
|
else
|
|
|
|
[userDefaults setShortDateFormat: newFormat];
|
2007-06-19 19:58:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSArray *) longDateFormatsList
|
|
|
|
{
|
|
|
|
NSMutableArray *longDateFormatsList = nil;
|
|
|
|
NSString *key, *currentFormat;
|
|
|
|
unsigned int nbr;
|
|
|
|
BOOL done;
|
|
|
|
|
2009-10-08 18:24:31 +02:00
|
|
|
longDateFormatsList = [NSMutableArray arrayWithObject: @"default"];
|
2007-06-19 19:58:21 +02:00
|
|
|
|
|
|
|
nbr = 0;
|
|
|
|
done = NO;
|
|
|
|
while (!done)
|
|
|
|
{
|
|
|
|
key = [NSString stringWithFormat: @"longDateFmt_%d", nbr];
|
|
|
|
currentFormat = [self labelForKey: key];
|
|
|
|
if ([currentFormat length] > 0)
|
2009-10-05 17:30:25 +02:00
|
|
|
{
|
|
|
|
[longDateFormatsList addObject: currentFormat];
|
|
|
|
nbr++;
|
|
|
|
}
|
2007-06-19 19:58:21 +02:00
|
|
|
else
|
2009-10-05 17:30:25 +02:00
|
|
|
done = YES;
|
2007-06-19 19:58:21 +02:00
|
|
|
}
|
|
|
|
|
2009-10-08 18:24:31 +02:00
|
|
|
if (![longDateFormatsList containsObject: [self userLongDateFormat]])
|
|
|
|
[longDateFormatsList addObject: [self userLongDateFormat]];
|
|
|
|
|
2007-06-19 19:58:21 +02:00
|
|
|
return longDateFormatsList;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) itemLongDateFormatText
|
|
|
|
{
|
2009-10-08 18:24:31 +02:00
|
|
|
NSString *todayText, *longDateFormatText;
|
|
|
|
|
|
|
|
if ([item isEqualToString: @"default"])
|
|
|
|
{
|
|
|
|
todayText = [today descriptionWithCalendarFormat: [locale objectForKey: NSDateFormatString]
|
|
|
|
locale: locale];
|
|
|
|
longDateFormatText = [NSString stringWithFormat: @"%@ (%@)",
|
|
|
|
[self labelForKey: item],
|
|
|
|
todayText];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
longDateFormatText = [today descriptionWithCalendarFormat: item
|
|
|
|
locale: locale];
|
2009-10-09 00:04:36 +02:00
|
|
|
|
|
|
|
return longDateFormatText;
|
2007-06-19 19:58:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) userLongDateFormat
|
|
|
|
{
|
2009-10-08 18:24:31 +02:00
|
|
|
NSString *longDateFormat;
|
|
|
|
|
2009-11-29 05:19:32 +01:00
|
|
|
longDateFormat = [userDefaults longDateFormat];
|
2009-10-08 18:24:31 +02:00
|
|
|
if (!longDateFormat)
|
|
|
|
longDateFormat = @"default";
|
|
|
|
|
|
|
|
return longDateFormat;
|
2007-06-19 19:58:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setUserLongDateFormat: (NSString *) newFormat
|
|
|
|
{
|
2009-10-08 18:24:31 +02:00
|
|
|
if ([newFormat isEqualToString: @"default"])
|
2009-11-29 05:19:32 +01:00
|
|
|
[userDefaults unsetLongDateFormat];
|
2009-10-08 18:24:31 +02:00
|
|
|
else
|
2009-11-29 05:19:32 +01:00
|
|
|
[userDefaults setLongDateFormat: newFormat];
|
2007-06-19 19:58:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSArray *) timeFormatsList
|
|
|
|
{
|
|
|
|
NSMutableArray *timeFormatsList = nil;
|
|
|
|
NSString *key, *currentFormat;
|
|
|
|
unsigned int nbr;
|
|
|
|
BOOL done;
|
|
|
|
|
2009-10-08 18:24:31 +02:00
|
|
|
timeFormatsList = [NSMutableArray arrayWithObject: @"default"];
|
2007-06-19 19:58:21 +02:00
|
|
|
|
|
|
|
nbr = 0;
|
|
|
|
done = NO;
|
|
|
|
while (!done)
|
|
|
|
{
|
|
|
|
key = [NSString stringWithFormat: @"timeFmt_%d", nbr];
|
|
|
|
currentFormat = [self labelForKey: key];
|
|
|
|
if ([currentFormat length] > 0)
|
2009-10-05 17:30:25 +02:00
|
|
|
{
|
|
|
|
[timeFormatsList addObject: currentFormat];
|
|
|
|
nbr++;
|
|
|
|
}
|
2007-06-19 19:58:21 +02:00
|
|
|
else
|
2009-10-05 17:30:25 +02:00
|
|
|
done = YES;
|
2007-06-19 19:58:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return timeFormatsList;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) itemTimeFormatText
|
|
|
|
{
|
2009-10-08 18:24:31 +02:00
|
|
|
NSString *todayText, *timeFormatText;
|
2010-01-20 15:53:49 +01:00
|
|
|
SOGoDomainDefaults *dd;
|
2009-10-08 18:24:31 +02:00
|
|
|
|
|
|
|
if ([item isEqualToString: @"default"])
|
|
|
|
{
|
2010-01-20 15:53:49 +01:00
|
|
|
dd = [user domainDefaults];
|
|
|
|
todayText = [today descriptionWithCalendarFormat: [dd timeFormat]
|
2009-10-08 18:24:31 +02:00
|
|
|
locale: locale];
|
|
|
|
timeFormatText = [NSString stringWithFormat: @"%@ (%@)",
|
|
|
|
[self labelForKey: item],
|
|
|
|
todayText];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
timeFormatText = [today descriptionWithCalendarFormat: item
|
|
|
|
locale: locale];
|
|
|
|
|
|
|
|
return timeFormatText;
|
2007-06-19 19:58:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) userTimeFormat
|
|
|
|
{
|
2009-11-29 05:19:32 +01:00
|
|
|
return [userDefaults timeFormat];
|
2007-06-19 19:58:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setUserTimeFormat: (NSString *) newFormat
|
|
|
|
{
|
2009-10-08 18:24:31 +02:00
|
|
|
if ([newFormat isEqualToString: @"default"])
|
2009-11-29 05:19:32 +01:00
|
|
|
[userDefaults unsetTimeFormat];
|
2009-10-08 18:24:31 +02:00
|
|
|
else
|
2009-11-29 05:19:32 +01:00
|
|
|
[userDefaults setTimeFormat: newFormat];
|
2007-06-19 19:58:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSArray *) daysList
|
|
|
|
{
|
|
|
|
NSMutableArray *daysList;
|
|
|
|
unsigned int currentDay;
|
|
|
|
|
2009-10-14 14:01:59 +02:00
|
|
|
daysList = [NSMutableArray array];
|
2007-06-19 19:58:21 +02:00
|
|
|
for (currentDay = 0; currentDay < 7; currentDay++)
|
|
|
|
[daysList addObject: [NSString stringWithFormat: @"%d", currentDay]];
|
|
|
|
|
|
|
|
return daysList;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) itemWeekStartDay
|
|
|
|
{
|
|
|
|
return [daysOfWeek objectAtIndex: [item intValue]];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) userWeekStartDay
|
|
|
|
{
|
2009-11-29 05:19:32 +01:00
|
|
|
return [NSString stringWithFormat: @"%d", [userDefaults firstDayOfWeek]];
|
2007-06-19 19:58:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setUserWeekStartDay: (NSString *) newDay
|
|
|
|
{
|
2009-11-29 05:19:32 +01:00
|
|
|
[userDefaults setFirstDayOfWeek: [newDay intValue]];
|
2007-06-19 19:58:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSArray *) hoursList
|
|
|
|
{
|
2009-11-29 05:19:32 +01:00
|
|
|
static NSMutableArray *hours = nil;
|
2007-06-19 19:58:21 +02:00
|
|
|
unsigned int currentHour;
|
|
|
|
|
|
|
|
if (!hours)
|
|
|
|
{
|
|
|
|
hours = [[NSMutableArray alloc] initWithCapacity: 24];
|
|
|
|
for (currentHour = 0; currentHour < 24; currentHour++)
|
2009-10-05 17:30:25 +02:00
|
|
|
[hours addObject: [NSString stringWithFormat: @"%.2d:00",
|
|
|
|
currentHour]];
|
2007-06-19 19:58:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return hours;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) userDayStartTime
|
|
|
|
{
|
2009-11-29 05:19:32 +01:00
|
|
|
return [NSString stringWithFormat: @"%02d:00",
|
|
|
|
[userDefaults dayStartHour]];
|
2007-06-19 19:58:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setUserDayStartTime: (NSString *) newTime
|
|
|
|
{
|
2009-11-29 05:19:32 +01:00
|
|
|
[userDefaults setDayStartTime: newTime];
|
2007-06-19 19:58:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) userDayEndTime
|
|
|
|
{
|
2009-11-29 05:19:32 +01:00
|
|
|
return [NSString stringWithFormat: @"%02d:00",
|
|
|
|
[userDefaults dayEndHour]];
|
2007-06-19 19:58:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setUserDayEndTime: (NSString *) newTime
|
|
|
|
{
|
2009-11-29 05:19:32 +01:00
|
|
|
[userDefaults setDayEndTime: newTime];
|
2007-06-19 19:58:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSArray *) firstWeekList
|
|
|
|
{
|
2009-10-06 20:12:07 +02:00
|
|
|
return [NSArray arrayWithObjects:
|
2009-10-05 17:30:25 +02:00
|
|
|
SOGoWeekStartJanuary1,
|
|
|
|
SOGoWeekStartFirst4DayWeek,
|
|
|
|
SOGoWeekStartFirstFullWeek,
|
|
|
|
nil];
|
2007-06-19 19:58:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) itemFirstWeekText
|
|
|
|
{
|
|
|
|
return [self labelForKey: [NSString stringWithFormat: @"firstWeekOfYear_%@",
|
2009-10-05 17:30:25 +02:00
|
|
|
item]];
|
2007-06-19 19:58:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) userFirstWeek
|
|
|
|
{
|
2009-11-29 05:19:32 +01:00
|
|
|
return [userDefaults firstWeekOfYear];
|
2007-06-19 19:58:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setUserFirstWeek: (NSString *) newFirstWeek
|
|
|
|
{
|
2009-11-29 05:19:32 +01:00
|
|
|
[userDefaults setFirstWeekOfYear: newFirstWeek];
|
2007-06-19 19:58:21 +02:00
|
|
|
}
|
|
|
|
|
2009-11-29 05:19:32 +01:00
|
|
|
- (BOOL) reminderEnabled
|
2007-06-19 19:58:21 +02:00
|
|
|
{
|
2009-11-29 05:19:32 +01:00
|
|
|
return [userDefaults reminderEnabled];
|
2007-06-19 19:58:21 +02:00
|
|
|
}
|
|
|
|
|
2009-11-29 05:19:32 +01:00
|
|
|
- (void) setReminderEnabled: (BOOL) newValue
|
2007-06-19 19:58:21 +02:00
|
|
|
{
|
2009-11-29 05:19:32 +01:00
|
|
|
[userDefaults setReminderEnabled: newValue];
|
2007-06-19 19:58:21 +02:00
|
|
|
}
|
|
|
|
|
2009-11-29 05:19:32 +01:00
|
|
|
- (BOOL) remindWithASound
|
2007-06-19 19:58:21 +02:00
|
|
|
{
|
2009-11-29 05:19:32 +01:00
|
|
|
return [userDefaults remindWithASound];
|
2007-06-19 19:58:21 +02:00
|
|
|
}
|
|
|
|
|
2009-11-29 05:19:32 +01:00
|
|
|
- (void) setRemindWithASound: (BOOL) newValue
|
2007-06-19 19:58:21 +02:00
|
|
|
{
|
2009-11-29 05:19:32 +01:00
|
|
|
[userDefaults setRemindWithASound: newValue];
|
2007-06-19 19:58:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSArray *) reminderTimesList
|
|
|
|
{
|
2009-11-29 05:19:32 +01:00
|
|
|
static NSArray *reminderTimesList = nil;
|
|
|
|
|
|
|
|
if (!reminderTimesList)
|
|
|
|
{
|
|
|
|
reminderTimesList = [NSArray arrayWithObjects: @"0000", @"0005",
|
|
|
|
@"0010", @"0015", @"0030", @"0100",
|
|
|
|
@"0200", @"0400", @"0800", @"1200",
|
|
|
|
@"2400", @"4800", nil];
|
|
|
|
[reminderTimesList retain];
|
|
|
|
}
|
|
|
|
|
|
|
|
return reminderTimesList;
|
2007-06-19 19:58:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) itemReminderTimeText
|
|
|
|
{
|
|
|
|
return [self labelForKey:
|
2009-10-05 17:30:25 +02:00
|
|
|
[NSString stringWithFormat: @"reminderTime_%@", item]];
|
2007-06-19 19:58:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) userReminderTime
|
|
|
|
{
|
2009-11-29 05:19:32 +01:00
|
|
|
return [userDefaults reminderTime];
|
2007-06-19 19:58:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setReminderTime: (NSString *) newTime
|
|
|
|
{
|
2009-11-29 05:19:32 +01:00
|
|
|
[userDefaults setReminderTime: newTime];
|
2007-06-19 19:58:21 +02:00
|
|
|
}
|
|
|
|
|
2007-08-22 17:18:01 +02:00
|
|
|
/* Mailer */
|
2009-05-15 22:26:25 +02:00
|
|
|
- (void) setShowSubscribedFoldersOnly: (BOOL) showSubscribedFoldersOnly
|
|
|
|
{
|
2009-11-29 05:19:32 +01:00
|
|
|
[userDefaults setMailShowSubscribedFoldersOnly: showSubscribedFoldersOnly];
|
2009-05-15 22:26:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL) showSubscribedFoldersOnly
|
|
|
|
{
|
2009-11-29 05:19:32 +01:00
|
|
|
return [userDefaults mailShowSubscribedFoldersOnly];
|
2009-05-15 22:26:25 +02:00
|
|
|
}
|
|
|
|
|
2007-10-26 17:35:51 +02:00
|
|
|
- (NSArray *) messageCheckList
|
|
|
|
{
|
2009-11-29 05:19:32 +01:00
|
|
|
NSArray *intervalsList;
|
|
|
|
NSMutableArray *messageCheckList;
|
|
|
|
NSString *value;
|
|
|
|
int count, max, interval;
|
2009-07-31 19:52:49 +02:00
|
|
|
|
2009-11-29 05:19:32 +01:00
|
|
|
intervalsList = [[user domainDefaults] mailPollingIntervals];
|
|
|
|
messageCheckList = [NSMutableArray arrayWithObjects: @"manually", nil];
|
|
|
|
max = [intervalsList count];
|
|
|
|
for (count = 0; count < max; count++)
|
2009-07-31 19:52:49 +02:00
|
|
|
{
|
2009-11-29 05:19:32 +01:00
|
|
|
interval = [[intervalsList objectAtIndex: count] intValue];
|
|
|
|
value = nil;
|
|
|
|
if (interval == 1)
|
|
|
|
value = @"every_minute";
|
|
|
|
else if (interval == 60)
|
|
|
|
value = @"once_per_hour";
|
|
|
|
else if (interval == 2 || interval == 5 || interval == 10
|
|
|
|
|| interval == 20 || interval == 30)
|
|
|
|
value = [NSString stringWithFormat: @"every_%d_minutes", interval];
|
|
|
|
else
|
2009-07-31 19:52:49 +02:00
|
|
|
{
|
2009-11-29 05:19:32 +01:00
|
|
|
[self warnWithFormat: @"interval '%d' not handled", interval];
|
|
|
|
value = nil;
|
2009-07-31 19:52:49 +02:00
|
|
|
}
|
2009-11-29 05:19:32 +01:00
|
|
|
if (value)
|
|
|
|
[messageCheckList addObject: value];
|
2009-07-31 19:52:49 +02:00
|
|
|
}
|
|
|
|
|
2009-11-29 05:19:32 +01:00
|
|
|
return messageCheckList;
|
2007-10-26 17:35:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) itemMessageCheckText
|
|
|
|
{
|
|
|
|
return [self labelForKey:
|
2009-10-05 17:30:25 +02:00
|
|
|
[NSString stringWithFormat: @"messagecheck_%@", item]];
|
2007-10-26 17:35:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) userMessageCheck
|
|
|
|
{
|
2009-11-29 05:19:32 +01:00
|
|
|
return [userDefaults mailMessageCheck];
|
2007-10-26 17:35:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setUserMessageCheck: (NSString *) newMessageCheck
|
|
|
|
{
|
2009-11-29 05:19:32 +01:00
|
|
|
[userDefaults setMailMessageCheck: newMessageCheck];
|
2007-10-26 17:35:51 +02:00
|
|
|
}
|
|
|
|
|
2007-08-22 17:18:01 +02:00
|
|
|
- (NSArray *) messageForwardingList
|
|
|
|
{
|
|
|
|
return [NSArray arrayWithObjects: @"inline", @"attached", nil];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) itemMessageForwardingText
|
|
|
|
{
|
|
|
|
return [self labelForKey:
|
2009-10-05 17:30:25 +02:00
|
|
|
[NSString stringWithFormat: @"messageforward_%@", item]];
|
2007-08-22 17:18:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) userMessageForwarding
|
|
|
|
{
|
2009-11-29 05:19:32 +01:00
|
|
|
return [userDefaults mailMessageForwarding];
|
2007-08-22 17:18:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setUserMessageForwarding: (NSString *) newMessageForwarding
|
|
|
|
{
|
2009-11-29 05:19:32 +01:00
|
|
|
[userDefaults setMailMessageForwarding: newMessageForwarding];
|
2007-08-22 17:18:01 +02:00
|
|
|
}
|
|
|
|
|
2009-11-29 05:19:32 +01:00
|
|
|
/*
|
2009-10-05 17:30:25 +02:00
|
|
|
// <label><var:string label:value="Default identity:"/>
|
|
|
|
// <var:popup list="identitiesList" item="item"
|
|
|
|
// string="itemIdentityText" selection="defaultIdentity"/></label>
|
2007-11-06 18:13:15 +01:00
|
|
|
- (NSArray *) identitiesList
|
|
|
|
{
|
2007-11-19 23:44:12 +01:00
|
|
|
NSDictionary *primaryAccount;
|
|
|
|
|
|
|
|
#warning we manage only one account per user at this time...
|
|
|
|
primaryAccount = [[user mailAccounts] objectAtIndex: 0];
|
|
|
|
|
|
|
|
return [primaryAccount objectForKey: @"identities"];
|
2007-11-06 18:13:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) itemIdentityText
|
|
|
|
{
|
2007-11-26 21:41:59 +01:00
|
|
|
return [(NSDictionary *) item keysWithFormat: @"%{fullName} <%{email}>"];
|
2009-11-29 05:19:32 +01:00
|
|
|
} */
|
2007-11-06 18:13:15 +01:00
|
|
|
|
2007-11-19 23:44:12 +01:00
|
|
|
- (NSString *) signature
|
|
|
|
{
|
2009-11-29 05:19:32 +01:00
|
|
|
return [userDefaults mailSignature];
|
2007-11-19 23:44:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setSignature: (NSString *) newSignature
|
|
|
|
{
|
2009-11-29 05:19:32 +01:00
|
|
|
[userDefaults setMailSignature: newSignature];
|
2007-11-19 23:44:12 +01:00
|
|
|
}
|
|
|
|
|
2008-09-28 21:49:17 +02:00
|
|
|
- (NSArray *) replyPlacementList
|
|
|
|
{
|
|
|
|
return [NSArray arrayWithObjects: @"above", @"below", nil];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) itemReplyPlacementText
|
|
|
|
{
|
|
|
|
return [self labelForKey:
|
2009-10-05 17:30:25 +02:00
|
|
|
[NSString stringWithFormat: @"replyplacement_%@", item]];
|
2008-09-28 21:49:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) userReplyPlacement
|
|
|
|
{
|
2009-11-29 05:19:32 +01:00
|
|
|
return [userDefaults mailReplyPlacement];
|
2008-09-28 21:49:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setUserReplyPlacement: (NSString *) newReplyPlacement
|
|
|
|
{
|
2009-11-29 05:19:32 +01:00
|
|
|
[userDefaults setMailReplyPlacement: newReplyPlacement];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) itemSignaturePlacementText
|
|
|
|
{
|
|
|
|
return [self labelForKey:
|
|
|
|
[NSString stringWithFormat: @"signatureplacement_%@", item]];
|
2008-09-28 21:49:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSArray *) signaturePlacementList
|
|
|
|
{
|
|
|
|
return [NSArray arrayWithObjects: @"above", @"below", nil];
|
|
|
|
}
|
|
|
|
|
2009-11-29 05:19:32 +01:00
|
|
|
- (void) setUserSignaturePlacement: (NSString *) newSignaturePlacement
|
2008-09-28 21:49:17 +02:00
|
|
|
{
|
2009-11-29 05:19:32 +01:00
|
|
|
[userDefaults setMailSignaturePlacement: newSignaturePlacement];
|
2008-09-28 21:49:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) userSignaturePlacement
|
|
|
|
{
|
2009-11-29 05:19:32 +01:00
|
|
|
return [userDefaults mailSignaturePlacement];
|
2008-09-28 21:49:17 +02:00
|
|
|
}
|
|
|
|
|
2009-06-23 19:53:18 +02:00
|
|
|
- (NSArray *) composeMessagesType
|
|
|
|
{
|
|
|
|
return [NSArray arrayWithObjects: @"text", @"html", nil];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) itemComposeMessagesText
|
|
|
|
{
|
2009-11-29 05:19:32 +01:00
|
|
|
return [self labelForKey: [NSString stringWithFormat:
|
|
|
|
@"composemessagestype_%@", item]];
|
2009-06-23 19:53:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) userComposeMessagesType
|
|
|
|
{
|
2009-11-29 05:19:32 +01:00
|
|
|
return [userDefaults mailComposeMessageType];
|
2009-06-23 19:53:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setUserComposeMessagesType: (NSString *) newType
|
|
|
|
{
|
2009-11-29 05:19:32 +01:00
|
|
|
[userDefaults setMailComposeMessageType: newType];
|
2008-09-28 21:49:17 +02:00
|
|
|
}
|
|
|
|
|
2009-10-09 22:30:42 +02:00
|
|
|
/* mail autoreply (vacation) */
|
|
|
|
|
2010-03-02 20:57:30 +01:00
|
|
|
- (BOOL) isSieveScriptsEnabled
|
|
|
|
{
|
|
|
|
return [[user domainDefaults] sieveScriptsEnabled];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) sieveCapabilities
|
|
|
|
{
|
|
|
|
#warning this should be deduced from the server
|
|
|
|
static NSArray *capabilities = nil;
|
|
|
|
|
|
|
|
if (!capabilities)
|
|
|
|
{
|
|
|
|
capabilities = [NSArray arrayWithObjects: @"fileinto", @"reject",
|
|
|
|
@"envelope", @"vacation", @"imapflags",
|
|
|
|
@"notify", @"subaddress", @"relational",
|
|
|
|
@"comparator-i;ascii-numeric", @"regex", nil];
|
|
|
|
[capabilities retain];
|
|
|
|
}
|
|
|
|
|
|
|
|
return [[NSDictionary dictionary]
|
|
|
|
jsonStringForArray: capabilities
|
|
|
|
withIndentLevel: 0];
|
|
|
|
}
|
|
|
|
|
2009-10-09 22:30:42 +02:00
|
|
|
- (BOOL) isVacationEnabled
|
|
|
|
{
|
2009-11-29 05:19:32 +01:00
|
|
|
return [[user domainDefaults] vacationEnabled];
|
2009-10-09 22:30:42 +02:00
|
|
|
}
|
|
|
|
|
2010-03-02 20:57:30 +01:00
|
|
|
- (void) setSieveFiltersValue: (NSString *) newValue
|
|
|
|
{
|
|
|
|
NSScanner *jsonScanner;
|
|
|
|
|
|
|
|
if ([newValue hasPrefix: @"["])
|
|
|
|
{
|
|
|
|
jsonScanner = [NSScanner scannerWithString: newValue];
|
|
|
|
[jsonScanner scanJSONArray: &sieveFilters];
|
|
|
|
[sieveFilters retain];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) sieveFiltersValue
|
|
|
|
{
|
|
|
|
return [[NSDictionary dictionary]
|
|
|
|
jsonStringForArray: sieveFilters
|
|
|
|
withIndentLevel: 0];
|
|
|
|
}
|
|
|
|
|
2009-10-09 22:30:42 +02:00
|
|
|
- (void) setEnableVacation: (BOOL) enableVacation
|
|
|
|
{
|
|
|
|
[vacationOptions setObject: [NSNumber numberWithBool: enableVacation]
|
2009-11-29 05:19:32 +01:00
|
|
|
forKey: @"enabled"];
|
2009-10-09 22:30:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL) enableVacation
|
|
|
|
{
|
|
|
|
return [[vacationOptions objectForKey: @"enabled"] boolValue];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setAutoReplyText: (NSString *) theText
|
|
|
|
{
|
2009-11-29 05:19:32 +01:00
|
|
|
[vacationOptions setObject: theText forKey: @"autoReplyText"];
|
2009-10-09 22:30:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) autoReplyText
|
|
|
|
{
|
|
|
|
return [vacationOptions objectForKey: @"autoReplyText"];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setAutoReplyEmailAddresses: (NSString *) theAddresses
|
|
|
|
{
|
|
|
|
NSArray *addresses;
|
|
|
|
|
2009-11-29 05:19:32 +01:00
|
|
|
addresses = [[theAddresses componentsSeparatedByString: @","]
|
|
|
|
trimmedComponents];
|
2009-10-09 22:30:42 +02:00
|
|
|
[vacationOptions setObject: addresses
|
|
|
|
forKey: @"autoReplyEmailAddresses"];
|
|
|
|
}
|
|
|
|
|
2009-10-15 00:11:13 +02:00
|
|
|
- (NSString *) defaultEmailAddresses
|
2009-10-09 22:30:42 +02:00
|
|
|
{
|
|
|
|
NSArray *addressesList;
|
2009-10-15 00:11:13 +02:00
|
|
|
NSMutableArray *uniqueAddressesList;
|
2009-10-09 22:30:42 +02:00
|
|
|
NSString *address;
|
|
|
|
unsigned int i;
|
|
|
|
|
2009-10-15 00:11:13 +02:00
|
|
|
uniqueAddressesList = [NSMutableArray array];
|
|
|
|
addressesList = [NSMutableArray arrayWithArray: [user allEmails]];
|
2009-11-29 05:19:32 +01:00
|
|
|
for (i = 0; i < [addressesList count]; i++)
|
2009-10-09 22:30:42 +02:00
|
|
|
{
|
2009-10-15 00:11:13 +02:00
|
|
|
address = [addressesList objectAtIndex: i];
|
|
|
|
if (![uniqueAddressesList containsObject: address])
|
|
|
|
[uniqueAddressesList addObject: address];
|
2009-10-09 22:30:42 +02:00
|
|
|
}
|
|
|
|
|
2009-10-15 00:11:13 +02:00
|
|
|
return [uniqueAddressesList componentsJoinedByString: @", "];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) autoReplyEmailAddresses
|
|
|
|
{
|
|
|
|
NSArray *addressesList;
|
|
|
|
|
|
|
|
addressesList = [vacationOptions objectForKey: @"autoReplyEmailAddresses"];
|
|
|
|
|
2009-11-29 05:19:32 +01:00
|
|
|
return (addressesList
|
|
|
|
? [addressesList componentsJoinedByString: @", "]
|
|
|
|
: [self defaultEmailAddresses]);
|
2009-10-09 22:30:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSArray *) daysBetweenResponsesList
|
|
|
|
{
|
2009-11-29 05:19:32 +01:00
|
|
|
static NSArray *daysBetweenResponses = nil;
|
2009-10-09 22:30:42 +02:00
|
|
|
|
|
|
|
if (!daysBetweenResponses)
|
|
|
|
{
|
2009-11-29 05:19:32 +01:00
|
|
|
daysBetweenResponses = [NSArray arrayWithObjects: @"1", @"2", @"3",
|
|
|
|
@"5", @"7", @"14", @"21", @"30", nil];
|
2009-10-09 22:30:42 +02:00
|
|
|
[daysBetweenResponses retain];
|
|
|
|
}
|
|
|
|
|
|
|
|
return daysBetweenResponses;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setDaysBetweenResponses: (NSNumber *) theDays
|
|
|
|
{
|
|
|
|
[vacationOptions setObject: theDays
|
|
|
|
forKey: @"daysBetweenResponse"];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) daysBetweenResponses
|
|
|
|
{
|
|
|
|
NSString *days;
|
|
|
|
|
|
|
|
days = [vacationOptions objectForKey: @"daysBetweenResponse"];
|
|
|
|
if (!days)
|
|
|
|
days = @"7"; // defaults to 7 days
|
|
|
|
|
|
|
|
return days;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setIgnoreLists: (BOOL) ignoreLists
|
|
|
|
{
|
|
|
|
[vacationOptions setObject: [NSNumber numberWithBool: ignoreLists]
|
|
|
|
forKey: @"ignoreLists"];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL) ignoreLists
|
|
|
|
{
|
|
|
|
NSNumber *obj;
|
|
|
|
BOOL ignore;
|
|
|
|
|
|
|
|
obj = [vacationOptions objectForKey: @"ignoreLists"];
|
|
|
|
|
|
|
|
if (obj == nil)
|
|
|
|
ignore = YES; // defaults to true
|
|
|
|
else
|
|
|
|
ignore = [obj boolValue];
|
|
|
|
|
|
|
|
return ignore;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* mail forward */
|
|
|
|
|
|
|
|
- (BOOL) isForwardEnabled
|
|
|
|
{
|
2009-11-29 05:19:32 +01:00
|
|
|
return [[user domainDefaults] forwardEnabled];
|
2009-10-09 22:30:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setEnableForward: (BOOL) enableForward
|
|
|
|
{
|
|
|
|
[forwardOptions setObject: [NSNumber numberWithBool: enableForward]
|
|
|
|
forKey: @"enabled"];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL) enableForward
|
|
|
|
{
|
|
|
|
return [[forwardOptions objectForKey: @"enabled"] boolValue];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setForwardAddress: (NSString *) forwardAddress
|
|
|
|
{
|
|
|
|
[forwardOptions setObject: forwardAddress
|
|
|
|
forKey: @"forwardAddress"];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) forwardAddress
|
|
|
|
{
|
|
|
|
return [forwardOptions objectForKey: @"forwardAddress"];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setForwardKeepCopy: (BOOL) keepCopy
|
|
|
|
{
|
|
|
|
[forwardOptions setObject: [NSNumber numberWithBool: keepCopy]
|
|
|
|
forKey: @"keepCopy"];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL) forwardKeepCopy
|
|
|
|
{
|
|
|
|
return [[forwardOptions objectForKey: @"keepCopy"] boolValue];
|
|
|
|
}
|
|
|
|
|
|
|
|
/* main */
|
|
|
|
|
2009-08-19 19:19:32 +02:00
|
|
|
- (NSArray *) availableModules
|
|
|
|
{
|
2009-11-29 05:19:32 +01:00
|
|
|
NSMutableArray *availableModules, *modules;
|
|
|
|
NSString *module;
|
|
|
|
int count, max;
|
2009-08-19 19:19:32 +02:00
|
|
|
|
|
|
|
modules = [NSMutableArray arrayWithObjects: @"Calendar", @"Mail", nil];
|
2009-11-29 05:19:32 +01:00
|
|
|
availableModules = [NSMutableArray arrayWithObjects: @"Last", @"Contacts",
|
|
|
|
nil];
|
|
|
|
max = [modules count];
|
|
|
|
for (count = 0; count < max; count++)
|
|
|
|
{
|
|
|
|
module = [modules objectAtIndex: count];
|
|
|
|
if ([user canAccessModule: module])
|
|
|
|
[availableModules addObject: module];
|
|
|
|
}
|
2009-08-19 19:19:32 +02:00
|
|
|
|
2009-11-29 05:19:32 +01:00
|
|
|
return availableModules;
|
2009-08-19 19:19:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) itemModuleText
|
|
|
|
{
|
|
|
|
return [self labelForKey: item];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) userDefaultModule
|
|
|
|
{
|
2009-11-29 05:19:32 +01:00
|
|
|
NSString *userDefaultModule;
|
|
|
|
|
|
|
|
if ([userDefaults rememberLastModule])
|
|
|
|
userDefaultModule = @"Last";
|
|
|
|
else
|
|
|
|
userDefaultModule = [userDefaults loginModule];
|
2009-08-19 19:19:32 +02:00
|
|
|
|
2009-11-29 05:19:32 +01:00
|
|
|
return userDefaultModule;
|
2009-08-19 19:19:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setUserDefaultModule: (NSString *) newValue
|
|
|
|
{
|
2009-11-29 05:19:32 +01:00
|
|
|
if ([newValue isEqualToString: @"Last"])
|
|
|
|
[userDefaults setRememberLastModule: YES];
|
|
|
|
else
|
|
|
|
{
|
|
|
|
[userDefaults setRememberLastModule: NO];
|
|
|
|
[userDefaults setLoginModule: newValue];
|
|
|
|
}
|
2009-08-19 19:19:32 +02:00
|
|
|
}
|
|
|
|
|
2007-06-19 19:58:21 +02:00
|
|
|
- (id <WOActionResults>) defaultAction
|
|
|
|
{
|
|
|
|
id <WOActionResults> results;
|
|
|
|
WORequest *request;
|
2009-12-07 17:16:01 +01:00
|
|
|
SOGoDomainDefaults *dd;
|
2007-06-19 19:58:21 +02:00
|
|
|
|
|
|
|
request = [context request];
|
|
|
|
if ([[request method] isEqualToString: @"POST"])
|
|
|
|
{
|
2009-10-09 23:01:54 +02:00
|
|
|
SOGoMailAccount *account;
|
|
|
|
id mailAccounts;
|
|
|
|
id folder;
|
2009-12-07 17:16:01 +01:00
|
|
|
|
|
|
|
dd = [[context activeUser] domainDefaults];
|
2010-03-02 20:57:30 +01:00
|
|
|
if ([dd sieveScriptsEnabled])
|
|
|
|
[userDefaults setSieveFilters: sieveFilters];
|
2009-12-07 17:16:01 +01:00
|
|
|
if ([dd vacationEnabled])
|
|
|
|
[userDefaults setVacationOptions: vacationOptions];
|
|
|
|
if ([dd forwardEnabled])
|
|
|
|
[userDefaults setForwardOptions: forwardOptions];
|
|
|
|
|
2007-06-19 19:58:21 +02:00
|
|
|
[userDefaults synchronize];
|
2009-10-09 23:01:54 +02:00
|
|
|
|
|
|
|
mailAccounts = [[[context activeUser] mailAccounts] objectAtIndex: 0];
|
|
|
|
folder = [[self clientObject] mailAccountsFolder: @"Mail"
|
2009-11-29 05:19:32 +01:00
|
|
|
inContext: context];
|
2009-10-09 23:01:54 +02:00
|
|
|
account = [folder lookupName: [[mailAccounts objectForKey: @"name"] asCSSIdentifier]
|
2009-11-29 05:19:32 +01:00
|
|
|
inContext: context
|
|
|
|
acquire: NO];
|
2009-10-09 23:01:54 +02:00
|
|
|
[account updateFilters];
|
|
|
|
|
2010-03-08 17:40:18 +01:00
|
|
|
results = [self jsCloseWithRefreshMethod: nil];
|
2007-06-19 19:58:21 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
results = self;
|
|
|
|
|
|
|
|
return results;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL) shouldTakeValuesFromRequest: (WORequest *) request
|
|
|
|
inContext: (WOContext*) context
|
|
|
|
{
|
|
|
|
return [[request method] isEqualToString: @"POST"];
|
|
|
|
}
|
|
|
|
|
2007-11-26 21:41:59 +01:00
|
|
|
- (BOOL) userHasCalendarAccess
|
|
|
|
{
|
|
|
|
return [user canAccessModule: @"Calendar"];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL) userHasMailAccess
|
|
|
|
{
|
|
|
|
return [user canAccessModule: @"Mail"];
|
|
|
|
}
|
|
|
|
|
2008-08-21 04:36:04 +02:00
|
|
|
- (BOOL) shouldDisplayAdditionalPreferences
|
|
|
|
{
|
2009-11-29 05:19:32 +01:00
|
|
|
return [[SOGoSystemDefaults sharedSystemDefaults]
|
|
|
|
uixAdditionalPreferences];
|
2008-08-21 04:36:04 +02:00
|
|
|
}
|
|
|
|
|
2007-07-22 22:17:34 +02:00
|
|
|
- (BOOL) shouldDisplayPasswordChange
|
|
|
|
{
|
2009-11-29 05:19:32 +01:00
|
|
|
return [[SOGoSystemDefaults sharedSystemDefaults]
|
|
|
|
userCanChangePassword];
|
2007-07-22 22:17:34 +02:00
|
|
|
}
|
|
|
|
|
2009-12-01 17:53:15 +01:00
|
|
|
- (NSArray *) languageCategories
|
2009-07-16 17:57:31 +02:00
|
|
|
{
|
2009-12-01 17:53:15 +01:00
|
|
|
NSArray *categoryLabels;
|
2009-07-16 17:57:31 +02:00
|
|
|
|
2009-12-01 17:53:15 +01:00
|
|
|
categoryLabels = [[self labelForKey: @"category_labels"]
|
|
|
|
componentsSeparatedByString: @","];
|
|
|
|
|
|
|
|
return [categoryLabels trimmedComponents];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSArray *) categoryList
|
|
|
|
{
|
|
|
|
if (!calendarCategories)
|
2009-07-16 17:57:31 +02:00
|
|
|
{
|
2009-12-01 17:53:15 +01:00
|
|
|
ASSIGN (calendarCategories, [userDefaults calendarCategories]);
|
|
|
|
if (!calendarCategories)
|
|
|
|
ASSIGN (calendarCategories, [self languageCategories]);
|
2009-07-16 17:57:31 +02:00
|
|
|
}
|
|
|
|
|
2009-12-01 17:53:15 +01:00
|
|
|
return [calendarCategories
|
|
|
|
sortedArrayUsingSelector: @selector (localizedCaseInsensitiveCompare:)];
|
|
|
|
}
|
2009-07-16 17:57:31 +02:00
|
|
|
|
2009-12-01 17:53:15 +01:00
|
|
|
- (void) setCategory: (NSString *) newCategory
|
|
|
|
{
|
|
|
|
ASSIGN (category, newCategory);
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) category
|
|
|
|
{
|
|
|
|
return category;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) categoryColor
|
|
|
|
{
|
|
|
|
SOGoDomainDefaults *dd;
|
|
|
|
NSString *categoryColor;
|
2009-07-16 17:57:31 +02:00
|
|
|
|
2009-12-01 17:53:15 +01:00
|
|
|
if (!calendarCategoriesColors)
|
|
|
|
ASSIGN (calendarCategoriesColors, [userDefaults calendarCategoriesColors]);
|
|
|
|
|
|
|
|
categoryColor = [calendarCategoriesColors objectForKey: category];
|
|
|
|
if (!categoryColor)
|
|
|
|
{
|
|
|
|
if (!defaultCategoryColor)
|
|
|
|
{
|
|
|
|
dd = [[context activeUser] domainDefaults];
|
|
|
|
ASSIGN (defaultCategoryColor, [dd calendarDefaultCategoryColor]);
|
|
|
|
}
|
|
|
|
categoryColor = defaultCategoryColor;
|
2009-07-16 17:57:31 +02:00
|
|
|
}
|
|
|
|
|
2009-12-01 17:53:15 +01:00
|
|
|
return categoryColor;
|
2009-07-16 17:57:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) categoriesValue
|
|
|
|
{
|
|
|
|
return @"";
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setCategoriesValue: (NSString *) value
|
|
|
|
{
|
2009-12-01 17:53:15 +01:00
|
|
|
NSDictionary *newColors;
|
|
|
|
|
|
|
|
newColors = [NSMutableDictionary dictionaryWithJSONString: value];
|
|
|
|
if (newColors)
|
2009-07-16 17:57:31 +02:00
|
|
|
{
|
2009-12-01 17:53:15 +01:00
|
|
|
[userDefaults setCalendarCategories: [newColors allKeys]];
|
|
|
|
[userDefaults setCalendarCategoriesColors: newColors];
|
2009-07-16 17:57:31 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-10-01 23:41:54 +02:00
|
|
|
- (NSArray *) languages
|
|
|
|
{
|
2009-11-29 05:19:32 +01:00
|
|
|
return [[SOGoSystemDefaults sharedSystemDefaults]
|
|
|
|
supportedLanguages];
|
2009-10-01 23:41:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) language
|
|
|
|
{
|
2009-11-29 05:19:32 +01:00
|
|
|
return [userDefaults language];
|
2009-10-01 23:41:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setLanguage: (NSString *) newLanguage
|
|
|
|
{
|
|
|
|
if ([[self languages] containsObject: newLanguage])
|
2009-11-29 05:19:32 +01:00
|
|
|
[userDefaults setLanguage: newLanguage];
|
2009-10-01 23:41:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) languageText
|
|
|
|
{
|
|
|
|
return [self labelForKey: item];
|
|
|
|
}
|
|
|
|
|
2007-06-19 19:58:21 +02:00
|
|
|
@end
|