2007-06-19 19:58:21 +02:00
|
|
|
/* UIxPreferences.m - this file is part of SOGo
|
|
|
|
*
|
2011-03-23 21:42:01 +01:00
|
|
|
* Copyright (C) 2007-2011 Inverse inc.
|
2007-06-19 19:58:21 +02:00
|
|
|
*
|
|
|
|
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
2011-03-23 21:42:01 +01:00
|
|
|
* Francis Lachapelle <flachapelle@inverse.ca>
|
2007-06-19 19:58:21 +02:00
|
|
|
*
|
|
|
|
* 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>
|
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>
|
|
|
|
|
2011-03-23 20:18:27 +01:00
|
|
|
#import <NGCards/iCalTimeZone.h>
|
2011-03-23 21:42:01 +01:00
|
|
|
#import <NGCards/iCalTimeZonePeriod.h>
|
2011-03-23 20:18:27 +01:00
|
|
|
|
2009-11-29 05:19:32 +01:00
|
|
|
#import <SOGo/NSArray+Utilities.h>
|
|
|
|
#import <SOGo/NSDictionary+Utilities.h>
|
|
|
|
#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>
|
2011-02-03 17:12:22 +01:00
|
|
|
#import <SOGo/WOResourceManager+SOGo.h>
|
2009-11-29 05:19:32 +01:00
|
|
|
#import <Mailer/SOGoMailAccount.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;
|
2010-08-06 17:34:05 +02:00
|
|
|
#warning user should be the owner rather than the activeUser
|
2007-06-19 19:58:21 +02:00
|
|
|
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,
|
2011-02-03 17:12:22 +01:00
|
|
|
[[self resourceManager] localeForLanguageNamed: language]);
|
2009-11-29 05:19:32 +01:00
|
|
|
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
|
|
|
}
|
2010-03-25 21:17:50 +01:00
|
|
|
|
|
|
|
hasChanged = NO;
|
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];
|
2010-10-26 21:26:50 +02:00
|
|
|
[contactsCategories 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];
|
|
|
|
}
|
|
|
|
|
2010-03-25 21:17:50 +01:00
|
|
|
- (void) setHasChanged: (BOOL) newHasChanged
|
|
|
|
{
|
|
|
|
hasChanged = newHasChanged;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL) hasChanged
|
|
|
|
{
|
|
|
|
return hasChanged;
|
|
|
|
}
|
|
|
|
|
2007-06-19 19:58:21 +02:00
|
|
|
- (void) setItem: (NSString *) newItem
|
|
|
|
{
|
|
|
|
ASSIGN (item, newItem);
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) item
|
|
|
|
{
|
|
|
|
return item;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSArray *) timeZonesList
|
|
|
|
{
|
2011-03-24 15:43:52 +01:00
|
|
|
return [[iCalTimeZone knownTimeZoneNames] sortedArrayUsingSelector: @selector (localizedCaseInsensitiveCompare:)];
|
2007-06-19 19:58:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) userTimeZone
|
|
|
|
{
|
2011-03-23 21:42:01 +01:00
|
|
|
NSString *name;
|
|
|
|
iCalTimeZone *tz;
|
|
|
|
|
|
|
|
name = [userDefaults timeZoneName];
|
|
|
|
tz = [iCalTimeZone timeZoneForName: name];
|
|
|
|
|
|
|
|
if (!tz)
|
|
|
|
{
|
|
|
|
// The specified timezone is not in our Olson database.
|
|
|
|
// Look for a known timezone with the same GMT offset.
|
|
|
|
NSString *current;
|
|
|
|
NSCalendarDate *now;
|
|
|
|
NSEnumerator *zones;
|
|
|
|
BOOL found;
|
|
|
|
unsigned int offset;
|
|
|
|
|
|
|
|
found = NO;
|
|
|
|
now = [NSCalendarDate calendarDate];
|
|
|
|
offset = [[userDefaults timeZone] secondsFromGMTForDate: now];
|
|
|
|
zones = [[iCalTimeZone knownTimeZoneNames] objectEnumerator];
|
|
|
|
|
|
|
|
while ((current = [zones nextObject]))
|
|
|
|
{
|
|
|
|
tz = [iCalTimeZone timeZoneForName: current];
|
|
|
|
if ([[tz periodForDate: now] secondsOffsetFromGMT] == offset)
|
|
|
|
{
|
|
|
|
found = YES;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (found)
|
|
|
|
{
|
|
|
|
[self warnWithFormat: @"User %@ has an unknown timezone (%@) -- replaced by %@", [user login], name, current];
|
|
|
|
name = current;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
[self errorWithFormat: @"User %@ has an unknown timezone (%@)", [user login], name];
|
|
|
|
}
|
|
|
|
|
|
|
|
return name;
|
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
|
|
|
}
|
|
|
|
|
2011-06-01 23:10:25 +02:00
|
|
|
- (void) setSortByThreads: (BOOL) sortByThreads
|
|
|
|
{
|
|
|
|
[userDefaults setMailSortByThreads: sortByThreads];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL) sortByThreads
|
|
|
|
{
|
|
|
|
return [userDefaults mailSortByThreads];
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
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
|
|
|
|
{
|
2010-08-06 17:34:05 +02:00
|
|
|
#warning sieve caps should be deduced from the server
|
2010-03-02 20:57:30 +01:00
|
|
|
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];
|
|
|
|
}
|
|
|
|
|
2010-11-02 14:16:05 +01:00
|
|
|
return [capabilities jsonRepresentation];
|
2010-03-02 20:57:30 +01:00
|
|
|
}
|
|
|
|
|
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
|
|
|
|
{
|
2010-10-26 21:26:50 +02:00
|
|
|
sieveFilters = [newValue objectFromJSONString];
|
|
|
|
if (sieveFilters)
|
2010-03-02 20:57:30 +01:00
|
|
|
{
|
2010-10-26 21:26:50 +02:00
|
|
|
if ([sieveFilters isKindOfClass: [NSArray class]])
|
|
|
|
[sieveFilters retain];
|
|
|
|
else
|
|
|
|
sieveFilters = nil;
|
2010-03-02 20:57:30 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) sieveFiltersValue
|
|
|
|
{
|
2010-11-02 14:16:05 +01:00
|
|
|
return [sieveFilters jsonRepresentation];
|
2010-03-02 20:57:30 +01:00
|
|
|
}
|
|
|
|
|
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
|
|
|
|
{
|
2011-05-27 22:53:16 +02:00
|
|
|
NSArray *addresses;
|
|
|
|
|
|
|
|
addresses = [[forwardAddress componentsSeparatedByString: @","]
|
|
|
|
trimmedComponents];
|
|
|
|
[forwardOptions setObject: addresses
|
2009-10-09 22:30:42 +02:00
|
|
|
forKey: @"forwardAddress"];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) forwardAddress
|
|
|
|
{
|
2011-05-27 22:53:16 +02:00
|
|
|
id addresses;
|
|
|
|
|
|
|
|
addresses = [forwardOptions objectForKey: @"forwardAddress"];
|
|
|
|
|
|
|
|
return ([addresses respondsToSelector: @selector(componentsJoinedByString:)]
|
|
|
|
? [(NSArray *)addresses componentsJoinedByString: @", "]
|
|
|
|
: (NSString *)addresses);
|
2009-10-09 22:30:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (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;
|
2010-03-25 21:17:50 +01:00
|
|
|
NSString *method;
|
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;
|
2010-08-06 17:34:05 +02:00
|
|
|
SOGoMailAccounts *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];
|
2010-08-06 17:34:05 +02:00
|
|
|
|
2009-10-09 23:01:54 +02:00
|
|
|
folder = [[self clientObject] mailAccountsFolder: @"Mail"
|
2009-11-29 05:19:32 +01:00
|
|
|
inContext: context];
|
2010-08-06 17:34:05 +02:00
|
|
|
account = [folder lookupName: @"0" inContext: context acquire: NO];
|
2009-10-09 23:01:54 +02:00
|
|
|
[account updateFilters];
|
|
|
|
|
2010-03-25 21:17:50 +01:00
|
|
|
if (hasChanged)
|
|
|
|
method = @"window.location.reload()";
|
|
|
|
else
|
|
|
|
method = nil;
|
|
|
|
|
|
|
|
results = [self jsCloseWithRefreshMethod: method];
|
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
|
|
|
}
|
|
|
|
|
2010-06-30 20:37:12 +02:00
|
|
|
- (NSString *) localeCode
|
|
|
|
{
|
|
|
|
// WARNING : NSLocaleCode is not defined in <Foundation/NSUserDefaults.h>
|
|
|
|
return [locale objectForKey: @"NSLocaleCode"];
|
|
|
|
}
|
|
|
|
|
2010-10-26 21:26:50 +02:00
|
|
|
- (NSArray *) _languageCalendarCategories
|
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
|
|
|
|
2010-10-26 21:26:50 +02:00
|
|
|
categoryLabels = [[self labelForKey: @"calendar_category_labels"]
|
2009-12-01 17:53:15 +01:00
|
|
|
componentsSeparatedByString: @","];
|
|
|
|
|
|
|
|
return [categoryLabels trimmedComponents];
|
|
|
|
}
|
|
|
|
|
2010-10-26 21:26:50 +02:00
|
|
|
- (NSArray *) calendarCategoryList
|
2009-12-01 17:53:15 +01:00
|
|
|
{
|
|
|
|
if (!calendarCategories)
|
2009-07-16 17:57:31 +02:00
|
|
|
{
|
2009-12-01 17:53:15 +01:00
|
|
|
ASSIGN (calendarCategories, [userDefaults calendarCategories]);
|
|
|
|
if (!calendarCategories)
|
2010-10-26 21:26:50 +02:00
|
|
|
ASSIGN (calendarCategories, [self _languageCalendarCategories]);
|
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
|
|
|
}
|
|
|
|
|
2010-10-26 21:26:50 +02:00
|
|
|
- (NSString *) calendarCategoriesValue
|
2009-07-16 17:57:31 +02:00
|
|
|
{
|
|
|
|
return @"";
|
|
|
|
}
|
|
|
|
|
2010-10-26 21:26:50 +02:00
|
|
|
- (void) setCalendarCategoriesValue: (NSString *) value
|
2009-07-16 17:57:31 +02:00
|
|
|
{
|
2009-12-01 17:53:15 +01:00
|
|
|
NSDictionary *newColors;
|
|
|
|
|
2010-10-26 21:26:50 +02:00
|
|
|
newColors = [value objectFromJSONString];
|
|
|
|
if (newColors && [newColors isKindOfClass: [NSDictionary class]])
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-10-26 21:26:50 +02:00
|
|
|
- (NSArray *) _languageContactsCategories
|
|
|
|
{
|
|
|
|
NSArray *categoryLabels;
|
|
|
|
|
|
|
|
categoryLabels = [[self labelForKey: @"contacts_category_labels"]
|
|
|
|
componentsSeparatedByString: @","];
|
|
|
|
if (!categoryLabels)
|
|
|
|
categoryLabels = [NSArray array];
|
|
|
|
|
|
|
|
return [categoryLabels trimmedComponents];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSArray *) contactsCategoryList
|
|
|
|
{
|
|
|
|
if (!contactsCategories)
|
|
|
|
{
|
|
|
|
ASSIGN (contactsCategories, [userDefaults contactsCategories]);
|
|
|
|
if (!contactsCategories)
|
|
|
|
ASSIGN (contactsCategories, [self _languageContactsCategories]);
|
|
|
|
}
|
|
|
|
|
|
|
|
return [contactsCategories
|
|
|
|
sortedArrayUsingSelector: @selector (localizedCaseInsensitiveCompare:)];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) contactsCategoriesValue
|
|
|
|
{
|
|
|
|
return @"";
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setContactsCategoriesValue: (NSString *) value
|
|
|
|
{
|
|
|
|
NSArray *newCategories;
|
|
|
|
|
|
|
|
newCategories = [value objectFromJSONString];
|
|
|
|
if (newCategories && [newCategories isKindOfClass: [NSArray class]])
|
|
|
|
[userDefaults setContactsCategories: newCategories];
|
|
|
|
}
|
|
|
|
|
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];
|
|
|
|
}
|
|
|
|
|
2010-08-06 17:34:05 +02:00
|
|
|
- (BOOL) mailAuxiliaryUserAccountsEnabled
|
|
|
|
{
|
|
|
|
return [[user domainDefaults] mailAuxiliaryUserAccountsEnabled];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) _extractMainSignature: (NSDictionary *) account
|
|
|
|
{
|
|
|
|
/* We perform some validation here as we have no guaranty on the input
|
|
|
|
validity. */
|
|
|
|
NSString *signature;
|
|
|
|
NSArray *identities;
|
|
|
|
NSDictionary *identity;
|
|
|
|
|
|
|
|
if ([account isKindOfClass: [NSDictionary class]])
|
|
|
|
{
|
|
|
|
identities = [account objectForKey: @"identities"];
|
|
|
|
if ([identities isKindOfClass: [NSArray class]])
|
|
|
|
{
|
|
|
|
signature = nil;
|
|
|
|
|
|
|
|
if ([identities count] > 0)
|
|
|
|
{
|
|
|
|
identity = [identities objectAtIndex: 0];
|
|
|
|
if ([identity isKindOfClass: [NSDictionary class]])
|
|
|
|
{
|
|
|
|
signature = [identity objectForKey: @"signature"];
|
|
|
|
if (!signature)
|
|
|
|
signature = @"";
|
|
|
|
[userDefaults setMailSignature: signature];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-09-01 22:27:45 +02:00
|
|
|
- (BOOL) _validateReceiptAction: (NSString *) action
|
|
|
|
{
|
|
|
|
return ([action isKindOfClass: [NSString class]]
|
|
|
|
&& ([action isEqualToString: @"ignore"]
|
|
|
|
|| [action isEqualToString: @"send"]
|
|
|
|
|| [action isEqualToString: @"ask"]));
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) _extractMainReceiptsPreferences: (NSDictionary *) account
|
|
|
|
{
|
|
|
|
/* We perform some validation here as we have no guaranty on the input
|
|
|
|
validity. */
|
|
|
|
NSDictionary *receipts;
|
|
|
|
NSString *action;
|
|
|
|
|
|
|
|
if ([account isKindOfClass: [NSDictionary class]])
|
|
|
|
{
|
|
|
|
receipts = [account objectForKey: @"receipts"];
|
|
|
|
if ([receipts isKindOfClass: [NSDictionary class]])
|
|
|
|
{
|
|
|
|
action = [receipts objectForKey: @"receiptAction"];
|
|
|
|
[userDefaults
|
|
|
|
setAllowUserReceipt: [action isEqualToString: @"allow"]];
|
|
|
|
|
|
|
|
action = [receipts objectForKey: @"receiptNonRecipientAction"];
|
|
|
|
if ([self _validateReceiptAction: action])
|
|
|
|
[userDefaults setUserReceiptNonRecipientAction: action];
|
|
|
|
|
|
|
|
action = [receipts objectForKey: @"receiptOutsideDomainAction"];
|
|
|
|
if ([self _validateReceiptAction: action])
|
|
|
|
[userDefaults setUserReceiptOutsideDomainAction: action];
|
|
|
|
|
|
|
|
action = [receipts objectForKey: @"receiptAnyAction"];
|
|
|
|
if ([self _validateReceiptAction: action])
|
|
|
|
[userDefaults setUserReceiptAnyAction: action];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-08-06 17:34:05 +02:00
|
|
|
- (BOOL) _validateAccountIdentities: (NSArray *) identities
|
|
|
|
{
|
|
|
|
static NSString *identityKeys[] = { @"fullName", @"email", nil };
|
|
|
|
static NSArray *knownKeys = nil;
|
|
|
|
NSString **key, *value;
|
|
|
|
NSDictionary *identity;
|
|
|
|
NSMutableDictionary *clone;
|
|
|
|
BOOL valid;
|
|
|
|
int count, max;
|
|
|
|
|
|
|
|
if (!knownKeys)
|
|
|
|
{
|
|
|
|
knownKeys = [NSArray arrayWithObjects: @"fullName", @"email",
|
|
|
|
@"signature", nil];
|
|
|
|
[knownKeys retain];
|
|
|
|
}
|
|
|
|
|
|
|
|
valid = [identities isKindOfClass: [NSArray class]];
|
|
|
|
if (valid)
|
|
|
|
{
|
|
|
|
max = [identities count];
|
|
|
|
valid = (max > 0);
|
|
|
|
for (count = 0; valid && count < max; count++)
|
|
|
|
{
|
|
|
|
identity = [identities objectAtIndex: count];
|
|
|
|
clone = [identity mutableCopy];
|
|
|
|
[clone removeObjectsForKeys: knownKeys];
|
|
|
|
valid = ([clone count] == 0);
|
|
|
|
[clone autorelease];
|
|
|
|
if (valid)
|
|
|
|
{
|
|
|
|
key = identityKeys;
|
|
|
|
while (valid && *key)
|
|
|
|
{
|
|
|
|
value = [identity objectForKey: *key];
|
|
|
|
if ([value isKindOfClass: [NSString class]]
|
|
|
|
&& [value length] > 0)
|
|
|
|
key++;
|
|
|
|
else
|
|
|
|
valid = NO;
|
|
|
|
}
|
|
|
|
if (valid)
|
|
|
|
{
|
|
|
|
value = [identity objectForKey: @"signature"];
|
|
|
|
valid = (!value || [value isKindOfClass: [NSString class]]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return valid;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL) _validateAccount: (NSDictionary *) account
|
|
|
|
{
|
|
|
|
static NSString *accountKeys[] = { @"name", @"serverName", @"userName",
|
2010-08-06 22:26:47 +02:00
|
|
|
nil };
|
2010-08-06 17:34:05 +02:00
|
|
|
static NSArray *knownKeys = nil;
|
|
|
|
NSMutableDictionary *clone;
|
|
|
|
NSString **key, *value;
|
|
|
|
BOOL valid;
|
|
|
|
|
|
|
|
if (!knownKeys)
|
|
|
|
{
|
2010-09-01 22:27:45 +02:00
|
|
|
knownKeys = [NSArray arrayWithObjects: @"name", @"serverName", @"port",
|
2010-08-06 17:34:05 +02:00
|
|
|
@"userName", @"password", @"encryption",
|
2010-09-01 22:27:45 +02:00
|
|
|
@"identities", @"mailboxes",
|
|
|
|
@"receipts",
|
|
|
|
nil];
|
2010-08-06 17:34:05 +02:00
|
|
|
[knownKeys retain];
|
|
|
|
}
|
|
|
|
|
|
|
|
valid = [account isKindOfClass: [NSDictionary class]];
|
|
|
|
if (valid)
|
|
|
|
{
|
|
|
|
clone = [account mutableCopy];
|
|
|
|
[clone removeObjectsForKeys: knownKeys];
|
|
|
|
valid = ([clone count] == 0);
|
|
|
|
[clone autorelease];
|
|
|
|
|
|
|
|
key = accountKeys;
|
|
|
|
while (valid && *key)
|
|
|
|
{
|
|
|
|
value = [account objectForKey: *key];
|
|
|
|
if ([value isKindOfClass: [NSString class]]
|
|
|
|
&& [value length] > 0)
|
|
|
|
key++;
|
|
|
|
else
|
|
|
|
valid = NO;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (valid)
|
|
|
|
{
|
|
|
|
value = [account objectForKey: @"security"];
|
|
|
|
if (value)
|
|
|
|
valid = ([value isKindOfClass: [NSString class]]
|
|
|
|
&& ([value isEqualToString: @"none"]
|
|
|
|
|| [value isEqualToString: @"ssl"]
|
|
|
|
|| [value isEqualToString: @"tls"]));
|
|
|
|
|
|
|
|
valid &= [self _validateAccountIdentities: [account objectForKey: @"identities"]];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return valid;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) _extractAuxiliaryAccounts: (NSArray *) accounts
|
|
|
|
{
|
2010-08-06 22:26:47 +02:00
|
|
|
int count, max, oldMax;
|
|
|
|
NSArray *oldAccounts;
|
2010-08-06 17:34:05 +02:00
|
|
|
NSMutableArray *auxAccounts;
|
2010-08-06 22:26:47 +02:00
|
|
|
NSDictionary *oldAccount;
|
|
|
|
NSMutableDictionary *account;
|
|
|
|
NSString *password;
|
|
|
|
|
|
|
|
oldAccounts = [user mailAccounts];
|
|
|
|
oldMax = [oldAccounts count];
|
2010-08-06 17:34:05 +02:00
|
|
|
|
|
|
|
max = [accounts count];
|
|
|
|
auxAccounts = [NSMutableArray arrayWithCapacity: max];
|
|
|
|
|
|
|
|
for (count = 1; count < max; count++)
|
|
|
|
{
|
|
|
|
account = [accounts objectAtIndex: count];
|
|
|
|
if ([self _validateAccount: account])
|
2010-08-06 22:26:47 +02:00
|
|
|
{
|
|
|
|
password = [account objectForKey: @"password"];
|
|
|
|
if (!password)
|
|
|
|
{
|
|
|
|
if (count < oldMax)
|
|
|
|
{
|
|
|
|
oldAccount = [oldAccounts objectAtIndex: count];
|
|
|
|
password = [oldAccount objectForKey: @"password"];
|
|
|
|
}
|
|
|
|
if (!password)
|
|
|
|
password = @"";
|
|
|
|
[account setObject: password forKey: @"password"];
|
|
|
|
}
|
|
|
|
[auxAccounts addObject: account];
|
|
|
|
}
|
2010-08-06 17:34:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
[userDefaults setAuxiliaryMailAccounts: auxAccounts];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setMailAccounts: (NSString *) newMailAccounts
|
|
|
|
{
|
|
|
|
NSArray *accounts;
|
|
|
|
int max;
|
|
|
|
|
2010-10-26 21:26:50 +02:00
|
|
|
accounts = [newMailAccounts objectFromJSONString];
|
2010-08-06 17:34:05 +02:00
|
|
|
if (accounts && [accounts isKindOfClass: [NSArray class]])
|
|
|
|
{
|
|
|
|
max = [accounts count];
|
|
|
|
if (max > 0)
|
|
|
|
{
|
|
|
|
[self _extractMainSignature: [accounts objectAtIndex: 0]];
|
2010-09-01 22:27:45 +02:00
|
|
|
[self _extractMainReceiptsPreferences: [accounts objectAtIndex: 0]];
|
2010-08-06 17:34:05 +02:00
|
|
|
|
2010-08-06 22:26:47 +02:00
|
|
|
if ([self mailAuxiliaryUserAccountsEnabled])
|
2010-08-06 17:34:05 +02:00
|
|
|
[self _extractAuxiliaryAccounts: accounts];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) mailAccounts
|
|
|
|
{
|
|
|
|
NSArray *accounts;
|
2010-08-06 22:26:47 +02:00
|
|
|
NSMutableDictionary *account;
|
|
|
|
int count, max;
|
2010-08-06 17:34:05 +02:00
|
|
|
|
|
|
|
accounts = [user mailAccounts];
|
2010-08-06 22:26:47 +02:00
|
|
|
max = [accounts count];
|
|
|
|
for (count = 0; count < max; count++)
|
|
|
|
{
|
|
|
|
account = [accounts objectAtIndex: count];
|
|
|
|
[account removeObjectForKey: @"password"];
|
|
|
|
}
|
2010-08-06 17:34:05 +02:00
|
|
|
|
|
|
|
return [accounts jsonRepresentation];
|
|
|
|
}
|
|
|
|
|
2007-06-19 19:58:21 +02:00
|
|
|
@end
|