2007-06-19 19:58:21 +02:00
|
|
|
/* UIxPreferences.m - this file is part of SOGo
|
|
|
|
*
|
2015-02-11 20:30:40 +01:00
|
|
|
* Copyright (C) 2007-2015 Inverse inc.
|
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>
|
2014-07-07 23:42:43 +02:00
|
|
|
#import <Foundation/NSDictionary.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
|
|
|
|
2015-09-15 21:59:31 +02:00
|
|
|
#import <NGObjWeb/SoObjects.h>
|
2007-06-19 19:58:21 +02:00
|
|
|
#import <NGObjWeb/WOContext.h>
|
|
|
|
#import <NGObjWeb/WORequest.h>
|
|
|
|
|
2014-02-17 21:42:55 +01:00
|
|
|
#import <NGImap4/NGSieveClient.h>
|
2013-11-11 16:49:58 +01:00
|
|
|
#import <NGImap4/NSString+Imap4.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>
|
2014-07-04 15:51:41 +02:00
|
|
|
#import <SOGo/SOGoUserSettings.h>
|
2009-11-29 05:19:32 +01:00
|
|
|
#import <SOGo/SOGoDomainDefaults.h>
|
2014-01-27 21:09:22 +01:00
|
|
|
#import <SOGo/SOGoSieveManager.h>
|
2009-11-29 05:19:32 +01:00
|
|
|
#import <SOGo/SOGoSystemDefaults.h>
|
|
|
|
#import <SOGo/SOGoUserFolder.h>
|
2014-04-09 12:33:02 +02:00
|
|
|
#import <SOGo/SOGoParentFolder.h>
|
2011-02-03 17:12:22 +01:00
|
|
|
#import <SOGo/WOResourceManager+SOGo.h>
|
2014-03-10 19:45:10 +01:00
|
|
|
#import <SOGo/SOGoBuild.h>
|
2009-11-29 05:19:32 +01:00
|
|
|
#import <Mailer/SOGoMailAccount.h>
|
2012-10-22 16:09:13 +02:00
|
|
|
#import <Mailer/SOGoMailAccounts.h>
|
2013-11-11 16:49:58 +01:00
|
|
|
#import <Mailer/SOGoMailLabel.h>
|
2007-06-19 19:58:21 +02:00
|
|
|
|
2014-03-24 18:41:57 +01:00
|
|
|
#import <Contacts/SOGoContactGCSFolder.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 */
|
|
|
|
|
2013-11-20 23:42:11 +01:00
|
|
|
static NSArray *reminderItems = nil;
|
|
|
|
static NSArray *reminderValues = nil;
|
|
|
|
|
2007-06-19 19:58:21 +02:00
|
|
|
@implementation UIxPreferences
|
|
|
|
|
2013-11-20 23:42:11 +01:00
|
|
|
+ (void) initialize
|
|
|
|
{
|
|
|
|
if (!reminderItems && !reminderValues)
|
|
|
|
{
|
|
|
|
reminderItems = [NSArray arrayWithObjects:
|
2014-06-30 16:35:55 +02:00
|
|
|
@"5_MINUTES_BEFORE",
|
2013-11-20 23:42:11 +01:00
|
|
|
@"10_MINUTES_BEFORE",
|
|
|
|
@"15_MINUTES_BEFORE",
|
|
|
|
@"30_MINUTES_BEFORE",
|
|
|
|
@"45_MINUTES_BEFORE",
|
|
|
|
@"-",
|
|
|
|
@"1_HOUR_BEFORE",
|
|
|
|
@"2_HOURS_BEFORE",
|
|
|
|
@"5_HOURS_BEFORE",
|
|
|
|
@"15_HOURS_BEFORE",
|
|
|
|
@"-",
|
|
|
|
@"1_DAY_BEFORE",
|
|
|
|
@"2_DAYS_BEFORE",
|
|
|
|
@"1_WEEK_BEFORE",
|
|
|
|
nil];
|
|
|
|
reminderValues = [NSArray arrayWithObjects:
|
2014-06-30 16:35:55 +02:00
|
|
|
@"-PT5M",
|
2013-11-20 23:42:11 +01:00
|
|
|
@"-PT10M",
|
|
|
|
@"-PT15M",
|
|
|
|
@"-PT30M",
|
|
|
|
@"-PT45M",
|
|
|
|
@"",
|
|
|
|
@"-PT1H",
|
|
|
|
@"-PT2H",
|
|
|
|
@"-PT5H",
|
|
|
|
@"-PT15H",
|
|
|
|
@"",
|
|
|
|
@"-P1D",
|
|
|
|
@"-P2D",
|
|
|
|
@"-P1W",
|
|
|
|
nil];
|
|
|
|
|
|
|
|
[reminderItems retain];
|
|
|
|
[reminderValues retain];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-06-19 19:58:21 +02:00
|
|
|
- (id) init
|
|
|
|
{
|
2009-11-29 05:19:32 +01:00
|
|
|
SOGoDomainDefaults *dd;
|
2014-05-01 20:07:25 +02:00
|
|
|
|
2007-06-19 19:58:21 +02:00
|
|
|
if ((self = [super init]))
|
|
|
|
{
|
|
|
|
item = nil;
|
2014-03-27 20:27:48 +01:00
|
|
|
addressBooksIDWithDisplayName = nil;
|
2014-04-04 21:04:37 +02:00
|
|
|
client = 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 (today, [NSCalendarDate date]);
|
2009-11-29 05:19:32 +01:00
|
|
|
|
2009-12-01 17:53:15 +01:00
|
|
|
calendarCategories = nil;
|
|
|
|
calendarCategoriesColors = nil;
|
|
|
|
category = nil;
|
|
|
|
|
2013-11-11 16:49:58 +01:00
|
|
|
label = nil;
|
|
|
|
mailLabels = nil;
|
2014-05-01 20:07:25 +02:00
|
|
|
|
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
|
|
|
|
2012-04-20 15:37:46 +02:00
|
|
|
mailCustomFromEnabled = [dd mailCustomFromEnabled];
|
|
|
|
|
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];
|
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];
|
|
|
|
[category release];
|
2013-11-11 16:49:58 +01:00
|
|
|
[label release];
|
|
|
|
[mailLabels 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];
|
2014-03-28 15:28:33 +01:00
|
|
|
[addressBooksIDWithDisplayName release];
|
2014-03-10 15:33:27 +01:00
|
|
|
[client 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;
|
2014-05-01 20:07:25 +02:00
|
|
|
|
2011-03-23 21:42:01 +01:00
|
|
|
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]];
|
2014-05-01 20:07:25 +02:00
|
|
|
|
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;
|
2014-05-01 20:07:25 +02:00
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2011-09-23 21:25:56 +02:00
|
|
|
- (NSArray *) defaultCalendarList
|
|
|
|
{
|
|
|
|
NSMutableArray *options;
|
|
|
|
|
|
|
|
options = [NSArray arrayWithObjects: @"selected", @"personal", @"first", nil];
|
|
|
|
|
|
|
|
return options;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) itemCalendarText
|
|
|
|
{
|
|
|
|
return [self labelForKey: [NSString stringWithFormat: @"%@Calendar", item]];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) userDefaultCalendar
|
|
|
|
{
|
|
|
|
return [userDefaults defaultCalendar];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setUserDefaultCalendar: (NSString *) newValue
|
|
|
|
{
|
|
|
|
[userDefaults setDefaultCalendar: newValue];
|
|
|
|
}
|
|
|
|
|
2012-02-20 23:25:49 +01:00
|
|
|
- (NSArray *) calendarClassificationsList
|
|
|
|
{
|
|
|
|
static NSArray *classifications = nil;
|
|
|
|
|
|
|
|
if (!classifications)
|
|
|
|
classifications = [[NSArray alloc] initWithObjects:
|
|
|
|
@"PUBLIC",
|
|
|
|
@"CONFIDENTIAL",
|
|
|
|
@"PRIVATE",
|
|
|
|
nil];
|
|
|
|
|
|
|
|
return classifications;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) itemClassificationText
|
|
|
|
{
|
|
|
|
return [self labelForKey: [NSString stringWithFormat: @"%@_item",
|
|
|
|
item]];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setEventsDefaultClassification: (NSString *) newValue
|
|
|
|
{
|
|
|
|
[userDefaults setCalendarEventsDefaultClassification: newValue];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) eventsDefaultClassification
|
|
|
|
{
|
|
|
|
return [userDefaults calendarEventsDefaultClassification];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setTasksDefaultClassification: (NSString *) newValue
|
|
|
|
{
|
|
|
|
[userDefaults setCalendarTasksDefaultClassification: newValue];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) tasksDefaultClassification
|
|
|
|
{
|
|
|
|
return [userDefaults calendarTasksDefaultClassification];
|
|
|
|
}
|
|
|
|
|
2013-11-20 23:42:11 +01:00
|
|
|
- (NSArray *) reminderList
|
|
|
|
{
|
|
|
|
return reminderItems;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) itemReminderText
|
|
|
|
{
|
|
|
|
NSString *text;
|
|
|
|
|
|
|
|
if ([item isEqualToString: @"-"])
|
|
|
|
text = item;
|
|
|
|
else
|
|
|
|
text = [self labelForKey: [NSString stringWithFormat: @"reminder_%@", item]];
|
|
|
|
|
|
|
|
return text;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setReminder: (NSString *) theReminder
|
|
|
|
{
|
|
|
|
NSString *value;
|
2014-03-24 12:42:57 +01:00
|
|
|
NSUInteger index;
|
2013-11-20 23:42:11 +01:00
|
|
|
|
|
|
|
index = NSNotFound;
|
|
|
|
value = @"NONE";
|
2014-05-01 20:07:25 +02:00
|
|
|
|
2013-11-20 23:42:11 +01:00
|
|
|
if (theReminder && [theReminder caseInsensitiveCompare: @"-"] != NSOrderedSame)
|
|
|
|
index = [reminderItems indexOfObject: theReminder];
|
|
|
|
|
|
|
|
if (index != NSNotFound)
|
|
|
|
value = [reminderValues objectAtIndex: index];
|
|
|
|
|
|
|
|
[userDefaults setCalendarDefaultReminder: value];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) reminder
|
|
|
|
{
|
|
|
|
NSString *value;
|
2014-03-10 19:47:01 +01:00
|
|
|
NSUInteger index;
|
2013-11-20 23:42:11 +01:00
|
|
|
|
|
|
|
value = [userDefaults calendarDefaultReminder];
|
2014-03-05 19:42:38 +01:00
|
|
|
if (value != nil)
|
|
|
|
{
|
|
|
|
index = [reminderValues indexOfObject: value];
|
2013-11-20 23:42:11 +01:00
|
|
|
|
2014-03-05 19:42:38 +01:00
|
|
|
if (index != NSNotFound)
|
|
|
|
return [reminderItems objectAtIndex: index];
|
|
|
|
}
|
2014-05-01 20:07:25 +02:00
|
|
|
|
2013-11-20 23:42:11 +01:00
|
|
|
return @"NONE";
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2011-09-27 17:43:46 +02:00
|
|
|
- (void) setBusyOffHours: (BOOL) busyOffHours
|
|
|
|
{
|
|
|
|
[userDefaults setBusyOffHours: busyOffHours];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL) busyOffHours
|
|
|
|
{
|
|
|
|
return [userDefaults busyOffHours];
|
|
|
|
}
|
|
|
|
|
2015-04-08 20:20:33 +02:00
|
|
|
- (NSString *) whiteList
|
2014-07-07 16:00:16 +02:00
|
|
|
{
|
|
|
|
SOGoUserSettings *us;
|
2014-07-07 23:42:43 +02:00
|
|
|
NSMutableDictionary *moduleSettings;
|
2015-04-08 20:20:33 +02:00
|
|
|
id whiteList;
|
2015-09-15 21:59:31 +02:00
|
|
|
|
2014-07-07 16:00:16 +02:00
|
|
|
us = [user userSettings];
|
2014-07-07 23:42:43 +02:00
|
|
|
moduleSettings = [us objectForKey: @"Calendar"];
|
2015-04-08 20:20:33 +02:00
|
|
|
whiteList = [moduleSettings objectForKey: @"PreventInvitationsWhitelist"];
|
|
|
|
|
|
|
|
if (whiteList && [whiteList isKindOfClass: [NSDictionary class]])
|
|
|
|
{
|
|
|
|
whiteList = [whiteList jsonRepresentation];
|
|
|
|
}
|
2015-09-15 21:59:31 +02:00
|
|
|
|
2014-07-07 23:42:43 +02:00
|
|
|
return whiteList;
|
2014-07-07 16:00:16 +02:00
|
|
|
}
|
|
|
|
|
2014-09-09 16:28:59 +02:00
|
|
|
- (void) setWhiteList: (NSString *) whiteListString
|
2014-07-07 16:00:16 +02:00
|
|
|
{
|
2014-07-07 23:42:43 +02:00
|
|
|
NSMutableDictionary *moduleSettings;
|
2015-04-17 15:41:39 +02:00
|
|
|
SOGoUserSettings *us;
|
|
|
|
id o;
|
2015-09-15 21:59:31 +02:00
|
|
|
|
2014-07-07 16:00:16 +02:00
|
|
|
us = [user userSettings];
|
2014-07-07 23:42:43 +02:00
|
|
|
moduleSettings = [us objectForKey: @"Calendar"];
|
2015-04-17 15:41:39 +02:00
|
|
|
|
|
|
|
if (!(o = [whiteListString objectFromJSONString]))
|
|
|
|
o = [NSDictionary dictionary];
|
2015-09-15 21:59:31 +02:00
|
|
|
|
2015-04-17 15:41:39 +02:00
|
|
|
[moduleSettings setObject: o forKey: @"PreventInvitationsWhitelist"];
|
2014-07-07 16:00:16 +02:00
|
|
|
[us synchronize];
|
|
|
|
}
|
|
|
|
|
2014-07-04 15:51:41 +02:00
|
|
|
- (void) setPreventInvitations: (BOOL) preventInvitations
|
|
|
|
{
|
|
|
|
SOGoUserSettings *us;
|
2014-07-07 23:42:43 +02:00
|
|
|
NSMutableDictionary *moduleSettings;
|
2014-07-04 15:51:41 +02:00
|
|
|
us = [user userSettings];
|
2014-07-07 23:42:43 +02:00
|
|
|
moduleSettings = [us objectForKey: @"Calendar"];
|
|
|
|
[moduleSettings setObject: [NSNumber numberWithBool: preventInvitations] forKey: @"PreventInvitations"];
|
2014-07-04 15:51:41 +02:00
|
|
|
[us synchronize];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL) preventInvitations
|
|
|
|
{
|
|
|
|
SOGoUserSettings *us;
|
2014-07-07 23:42:43 +02:00
|
|
|
NSMutableDictionary *moduleSettings;
|
2014-07-04 15:51:41 +02:00
|
|
|
us = [user userSettings];
|
2014-07-07 23:42:43 +02:00
|
|
|
moduleSettings = [us objectForKey: @"Calendar"];
|
|
|
|
return [[moduleSettings objectForKey: @"PreventInvitations"] boolValue];
|
2014-07-04 15:51:41 +02:00
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2007-08-22 17:18:01 +02:00
|
|
|
/* Mailer */
|
2014-03-24 18:41:57 +01:00
|
|
|
- (void) setAddOutgoingAddresses: (BOOL) addOutgoingAddresses
|
|
|
|
{
|
|
|
|
[userDefaults setMailAddOutgoingAddresses: addOutgoingAddresses];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL) addOutgoingAddresses
|
|
|
|
{
|
|
|
|
return [userDefaults mailAddOutgoingAddresses];
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2016-01-07 15:17:46 +01:00
|
|
|
- (void) setSynchronizeOnlyDefaultMailFolders: (BOOL) synchronizeOnlyDefaultMailFolders
|
|
|
|
{
|
|
|
|
[userDefaults setSynchronizeOnlyDefaultMailFolders: synchronizeOnlyDefaultMailFolders];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL) synchronizeOnlyDefaultMailFolders
|
|
|
|
{
|
|
|
|
return [userDefaults synchronizeOnlyDefaultMailFolders];
|
|
|
|
}
|
|
|
|
|
2011-06-01 23:10:25 +02:00
|
|
|
- (void) setSortByThreads: (BOOL) sortByThreads
|
|
|
|
{
|
|
|
|
[userDefaults setMailSortByThreads: sortByThreads];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL) sortByThreads
|
|
|
|
{
|
|
|
|
return [userDefaults mailSortByThreads];
|
|
|
|
}
|
|
|
|
|
2014-03-24 18:41:57 +01:00
|
|
|
- (NSArray *) addressBookList
|
|
|
|
{
|
|
|
|
/* We want all the SourceIDS */
|
2014-04-09 12:33:02 +02:00
|
|
|
NSMutableArray *folders, *availableAddressBooksID, *availableAddressBooksName;
|
|
|
|
SOGoParentFolder *contactFolders;
|
2015-09-15 21:59:31 +02:00
|
|
|
|
2014-03-25 19:53:42 +01:00
|
|
|
int i, count;
|
2014-03-27 20:27:48 +01:00
|
|
|
BOOL collectedAlreadyExist;
|
2015-09-15 21:59:31 +02:00
|
|
|
|
2014-03-24 18:41:57 +01:00
|
|
|
contactFolders = [[[context activeUser] homeFolderInContext: context]
|
2014-06-30 16:35:55 +02:00
|
|
|
lookupName: @"Contacts"
|
|
|
|
inContext: context
|
|
|
|
acquire: NO];
|
2014-03-24 18:41:57 +01:00
|
|
|
folders = [NSMutableArray arrayWithArray: [contactFolders subFolders]];
|
|
|
|
count = [folders count]-1;
|
2015-09-15 21:59:31 +02:00
|
|
|
|
2014-03-24 18:41:57 +01:00
|
|
|
// Inside this loop we remove all the public or shared addressbooks
|
2014-04-09 12:33:02 +02:00
|
|
|
for (; count >= 0; count--)
|
2014-06-30 16:35:55 +02:00
|
|
|
{
|
|
|
|
if (![[folders objectAtIndex: count] isKindOfClass: [SOGoContactGCSFolder class]])
|
|
|
|
[folders removeObjectAtIndex: count];
|
|
|
|
}
|
2015-09-15 21:59:31 +02:00
|
|
|
|
2014-03-24 18:41:57 +01:00
|
|
|
// Parse the objects in order to have only the displayName of the addressbooks to be displayed on the preferences interface
|
2014-03-27 20:27:48 +01:00
|
|
|
availableAddressBooksID = [NSMutableArray arrayWithCapacity: [folders count]];
|
|
|
|
availableAddressBooksName = [NSMutableArray arrayWithCapacity: [folders count]];
|
2014-03-24 18:41:57 +01:00
|
|
|
count = [folders count]-1;
|
2014-04-09 12:33:02 +02:00
|
|
|
collectedAlreadyExist = NO;
|
2015-09-15 21:59:31 +02:00
|
|
|
|
2014-06-30 16:35:55 +02:00
|
|
|
for (i = 0; i <= count ; i++)
|
|
|
|
{
|
|
|
|
[availableAddressBooksID addObject:[[folders objectAtIndex:i] realNameInContainer]];
|
|
|
|
[availableAddressBooksName addObject:[[folders objectAtIndex:i] displayName]];
|
2015-09-15 21:59:31 +02:00
|
|
|
|
2014-06-30 16:35:55 +02:00
|
|
|
if ([[availableAddressBooksID objectAtIndex:i] isEqualToString: @"collected"])
|
|
|
|
collectedAlreadyExist = YES;
|
|
|
|
}
|
2014-03-27 20:27:48 +01:00
|
|
|
// Create the dictionary for the next function : itemAddressBookText.
|
|
|
|
if (!addressBooksIDWithDisplayName)
|
2014-06-30 16:35:55 +02:00
|
|
|
{
|
|
|
|
addressBooksIDWithDisplayName = [[NSMutableDictionary alloc] initWithObjects:availableAddressBooksName
|
|
|
|
forKeys:availableAddressBooksID];
|
|
|
|
}
|
2014-06-26 22:08:47 +02:00
|
|
|
if (!collectedAlreadyExist)
|
2014-06-30 16:35:55 +02:00
|
|
|
{
|
|
|
|
[availableAddressBooksID addObject: @"collected"];
|
|
|
|
[addressBooksIDWithDisplayName setObject: [self labelForKey: @"Collected Address Book"] forKey: @"collected"];
|
|
|
|
}
|
2015-09-15 21:59:31 +02:00
|
|
|
|
2014-03-27 20:27:48 +01:00
|
|
|
return availableAddressBooksID;
|
2014-03-24 18:41:57 +01:00
|
|
|
}
|
2014-06-30 16:35:55 +02:00
|
|
|
|
2014-03-24 18:41:57 +01:00
|
|
|
- (NSString *) itemAddressBookText
|
|
|
|
{
|
2014-03-27 20:27:48 +01:00
|
|
|
return [addressBooksIDWithDisplayName objectForKey: item];
|
2014-03-24 18:41:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) userAddressBook
|
|
|
|
{
|
|
|
|
return [userDefaults selectedAddressBook];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setUserAddressBook: (NSString *) newSelectedAddressBook
|
|
|
|
{
|
|
|
|
[userDefaults setSelectedAddressBook: newSelectedAddressBook];
|
|
|
|
}
|
|
|
|
|
2014-08-29 19:16:30 +02:00
|
|
|
- (NSArray *) refreshViewList
|
2007-10-26 17:35:51 +02:00
|
|
|
{
|
2009-11-29 05:19:32 +01:00
|
|
|
NSArray *intervalsList;
|
2014-08-29 19:16:30 +02:00
|
|
|
NSMutableArray *refreshViewList;
|
2009-11-29 05:19:32 +01:00
|
|
|
NSString *value;
|
|
|
|
int count, max, interval;
|
2009-07-31 19:52:49 +02:00
|
|
|
|
2014-08-29 19:16:30 +02:00
|
|
|
intervalsList = [[user domainDefaults] refreshViewIntervals];
|
|
|
|
refreshViewList = [NSMutableArray arrayWithObjects: @"manually", nil];
|
2009-11-29 05:19:32 +01:00
|
|
|
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";
|
2015-09-15 21:59:31 +02:00
|
|
|
else if (interval == 2 || interval == 5 || interval == 10
|
2009-11-29 05:19:32 +01:00
|
|
|
|| 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)
|
2014-08-29 19:16:30 +02:00
|
|
|
[refreshViewList addObject: value];
|
2009-07-31 19:52:49 +02:00
|
|
|
}
|
|
|
|
|
2014-08-29 19:16:30 +02:00
|
|
|
return refreshViewList;
|
2007-10-26 17:35:51 +02:00
|
|
|
}
|
|
|
|
|
2014-08-29 19:16:30 +02:00
|
|
|
- (NSString *) itemRefreshViewCheckText
|
2007-10-26 17:35:51 +02:00
|
|
|
{
|
2014-08-29 19:16:30 +02:00
|
|
|
return [self labelForKey: [NSString stringWithFormat: @"refreshview_%@", item]];
|
2007-10-26 17:35:51 +02:00
|
|
|
}
|
|
|
|
|
2014-08-29 19:16:30 +02:00
|
|
|
- (NSString *) userRefreshViewCheck
|
2007-10-26 17:35:51 +02:00
|
|
|
{
|
2014-08-29 19:16:30 +02:00
|
|
|
return [userDefaults refreshViewCheck];
|
2007-10-26 17:35:51 +02:00
|
|
|
}
|
|
|
|
|
2014-08-29 19:16:30 +02:00
|
|
|
- (void) setUserRefreshViewCheck: (NSString *) newRefreshViewCheck
|
2007-10-26 17:35:51 +02:00
|
|
|
{
|
2014-08-29 19:16:30 +02:00
|
|
|
[userDefaults setRefreshViewCheck: newRefreshViewCheck];
|
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
|
|
|
}
|
|
|
|
|
2012-10-26 19:39:28 +02:00
|
|
|
/* Display remote inline images */
|
|
|
|
- (NSArray *) displayRemoteInlineImages
|
|
|
|
{
|
|
|
|
return [NSArray arrayWithObjects: @"never", @"always", nil];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) itemDisplayRemoteInlineImagesText
|
|
|
|
{
|
|
|
|
return [self labelForKey: [NSString stringWithFormat:
|
|
|
|
@"displayremoteinlineimages_%@", item]];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) userDisplayRemoteInlineImages
|
|
|
|
{
|
|
|
|
return [userDefaults mailDisplayRemoteInlineImages];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setUserDisplayRemoteInlineImages: (NSString *) newType
|
|
|
|
{
|
|
|
|
[userDefaults setMailDisplayRemoteInlineImages: newType];
|
|
|
|
}
|
|
|
|
|
2014-12-11 19:31:32 +01:00
|
|
|
- (void) setAutoSave: (NSString *) theValue
|
|
|
|
{
|
|
|
|
[userDefaults setMailAutoSave: theValue];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) autoSave
|
|
|
|
{
|
|
|
|
return [userDefaults mailAutoSave];
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
{
|
|
|
|
static NSArray *capabilities = nil;
|
|
|
|
|
|
|
|
if (!capabilities)
|
|
|
|
{
|
2014-04-04 21:04:37 +02:00
|
|
|
if ([self sieveClient])
|
|
|
|
capabilities = [[self sieveClient] capabilities];
|
2014-01-27 21:09:22 +01:00
|
|
|
else
|
|
|
|
capabilities = [NSArray array];
|
2014-06-30 16:35:55 +02:00
|
|
|
[capabilities retain];
|
2010-03-02 20:57:30 +01:00
|
|
|
}
|
|
|
|
|
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;
|
2014-05-01 20:07:25 +02:00
|
|
|
|
2009-10-15 00:11:13 +02:00
|
|
|
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)
|
2014-04-10 14:44:44 +02:00
|
|
|
ignore = YES; // defaults to YES
|
2009-10-09 22:30:42 +02:00
|
|
|
else
|
|
|
|
ignore = [obj boolValue];
|
|
|
|
|
|
|
|
return ignore;
|
|
|
|
}
|
|
|
|
|
2015-02-09 22:12:59 +01:00
|
|
|
//
|
|
|
|
// See http://sogo.nu/bugs/view.php?id=2332 for details
|
|
|
|
//
|
|
|
|
- (void) setAlwaysSend: (BOOL) ignoreLists
|
|
|
|
{
|
|
|
|
[vacationOptions setObject: [NSNumber numberWithBool: ignoreLists]
|
|
|
|
forKey: @"alwaysSend"];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL) alwaysSend
|
|
|
|
{
|
|
|
|
NSNumber *obj;
|
|
|
|
BOOL ignore;
|
|
|
|
|
|
|
|
obj = [vacationOptions objectForKey: @"alwaysSend"];
|
|
|
|
|
|
|
|
if (obj == nil)
|
|
|
|
ignore = NO; // defaults to NO
|
|
|
|
else
|
|
|
|
ignore = [obj boolValue];
|
|
|
|
|
|
|
|
return ignore;
|
|
|
|
}
|
|
|
|
|
2011-11-21 15:09:26 +01:00
|
|
|
- (BOOL) enableVacationEndDate
|
|
|
|
{
|
|
|
|
return [[vacationOptions objectForKey: @"endDateEnabled"] boolValue];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL) disableVacationEndDate
|
|
|
|
{
|
|
|
|
return ![self enableVacationEndDate];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setEnableVacationEndDate: (BOOL) enableVacationEndDate
|
|
|
|
{
|
|
|
|
[vacationOptions setObject: [NSNumber numberWithBool: enableVacationEndDate]
|
|
|
|
forKey: @"endDateEnabled"];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setVacationEndDate: (NSCalendarDate *) endDate
|
|
|
|
{
|
|
|
|
NSNumber *time;
|
2014-05-01 20:07:25 +02:00
|
|
|
|
2011-11-21 15:09:26 +01:00
|
|
|
time = [NSNumber numberWithInt: [endDate timeIntervalSince1970]];
|
|
|
|
|
|
|
|
[vacationOptions setObject: time forKey: @"endDate"];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSCalendarDate *) vacationEndDate
|
|
|
|
{
|
|
|
|
int time;
|
|
|
|
|
|
|
|
time = [[vacationOptions objectForKey: @"endDate"] intValue];
|
|
|
|
|
2011-12-23 17:12:14 +01:00
|
|
|
if (time > 0)
|
|
|
|
return [NSCalendarDate dateWithTimeIntervalSince1970: time];
|
|
|
|
else
|
|
|
|
return [NSCalendarDate calendarDate];
|
2011-11-21 15:09:26 +01:00
|
|
|
}
|
|
|
|
|
2009-10-09 22:30:42 +02:00
|
|
|
/* 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];
|
|
|
|
}
|
|
|
|
|
2015-02-11 20:30:40 +01:00
|
|
|
- (NSString *) forwardConstraints
|
|
|
|
{
|
|
|
|
SOGoDomainDefaults *dd;
|
2015-09-15 21:59:31 +02:00
|
|
|
|
2015-02-11 20:30:40 +01:00
|
|
|
dd = [[context activeUser] domainDefaults];
|
|
|
|
|
|
|
|
return [NSString stringWithFormat: @"%d", [dd forwardConstraints]];
|
|
|
|
}
|
|
|
|
|
2009-10-09 22:30:42 +02:00
|
|
|
/* 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
|
|
|
}
|
|
|
|
|
2014-03-10 19:45:10 +01:00
|
|
|
- (NSString *) sogoVersion
|
|
|
|
{
|
2014-04-03 23:09:00 +02:00
|
|
|
// The variable SOGoVersion comes from the import: SOGo/Build.h
|
2014-04-04 14:39:13 +02:00
|
|
|
return [NSString stringWithString: SOGoVersion];
|
2014-03-10 19:45:10 +01:00
|
|
|
}
|
|
|
|
|
2014-04-04 21:04:37 +02:00
|
|
|
- (id) sieveClient
|
|
|
|
{
|
2014-03-10 15:33:27 +01:00
|
|
|
SOGoMailAccount *account;
|
|
|
|
SOGoMailAccounts *folder;
|
|
|
|
SOGoSieveManager *manager;
|
2014-05-01 20:07:25 +02:00
|
|
|
|
2014-04-09 16:48:47 +02:00
|
|
|
if (!client)
|
2014-06-30 16:35:55 +02:00
|
|
|
{
|
|
|
|
folder = [[self clientObject] mailAccountsFolder: @"Mail" inContext: context];
|
|
|
|
account = [folder lookupName: @"0" inContext: context acquire: NO];
|
|
|
|
manager = [SOGoSieveManager sieveManagerForUser: [context activeUser]];
|
|
|
|
client = [[manager clientForAccount: account] retain];
|
|
|
|
}
|
2014-05-01 20:07:25 +02:00
|
|
|
|
2014-04-04 21:04:37 +02:00
|
|
|
return client;
|
2014-03-10 15:33:27 +01:00
|
|
|
}
|
|
|
|
|
2014-04-04 21:04:37 +02:00
|
|
|
- (BOOL) isSieveServerAvailable
|
|
|
|
{
|
2014-04-09 17:09:13 +02:00
|
|
|
return (([(NGSieveClient *)[self sieveClient] isConnected])
|
2014-04-10 14:44:44 +02:00
|
|
|
? YES
|
|
|
|
: NO);
|
2014-03-10 15:33:27 +01:00
|
|
|
}
|
|
|
|
|
2007-06-19 19:58:21 +02:00
|
|
|
- (id <WOActionResults>) defaultAction
|
|
|
|
{
|
|
|
|
id <WOActionResults> results;
|
2009-12-07 17:16:01 +01:00
|
|
|
SOGoDomainDefaults *dd;
|
2014-02-28 22:39:27 +01:00
|
|
|
SOGoMailAccount *account;
|
|
|
|
SOGoMailAccounts *folder;
|
|
|
|
WORequest *request;
|
2014-05-01 20:07:25 +02:00
|
|
|
|
2014-02-28 22:39:27 +01:00
|
|
|
request = [context request];
|
2014-04-04 21:04:37 +02:00
|
|
|
if ([[request method] isEqualToString: @"POST"])
|
|
|
|
{
|
2014-04-09 17:09:13 +02:00
|
|
|
dd = [[context activeUser] domainDefaults];
|
|
|
|
if ([dd sieveScriptsEnabled])
|
|
|
|
[userDefaults setSieveFilters: sieveFilters];
|
|
|
|
if ([dd vacationEnabled])
|
|
|
|
[userDefaults setVacationOptions: vacationOptions];
|
|
|
|
if ([dd forwardEnabled])
|
|
|
|
[userDefaults setForwardOptions: forwardOptions];
|
2014-05-01 20:07:25 +02:00
|
|
|
|
|
|
|
if (!([dd sieveScriptsEnabled] || [dd vacationEnabled] || [dd forwardEnabled]) || [self isSieveServerAvailable])
|
2014-04-09 17:09:13 +02:00
|
|
|
{
|
|
|
|
[userDefaults synchronize];
|
|
|
|
folder = [[self clientObject] mailAccountsFolder: @"Mail"
|
|
|
|
inContext: context];
|
|
|
|
account = [folder lookupName: @"0" inContext: context acquire: NO];
|
2014-05-01 20:07:25 +02:00
|
|
|
|
2014-04-09 17:09:13 +02:00
|
|
|
if ([account updateFilters])
|
2014-06-05 18:14:34 +02:00
|
|
|
// If Sieve is not enabled, the SOGoSieveManager will immediatly return a positive answer
|
|
|
|
// See [SOGoSieveManager updateFiltersForAccount:withUsername:andPassword:]
|
2015-11-05 18:29:26 +01:00
|
|
|
results = (id <WOActionResults>)[self responseWithStatus: 200
|
2014-04-09 17:09:13 +02:00
|
|
|
andJSONRepresentation: [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithBool:hasChanged], @"hasChanged", nil]];
|
2014-05-01 20:07:25 +02:00
|
|
|
|
2014-04-09 17:09:13 +02:00
|
|
|
else
|
2015-11-05 18:29:26 +01:00
|
|
|
results = (id <WOActionResults>)[self responseWithStatus: 502
|
2014-04-09 17:09:13 +02:00
|
|
|
andJSONRepresentation: [NSDictionary dictionaryWithObjectsAndKeys: @"Connection error", @"textStatus", nil]];
|
|
|
|
}
|
2014-06-30 16:35:55 +02:00
|
|
|
else
|
2015-11-05 18:29:26 +01:00
|
|
|
results = (id <WOActionResults>)[self responseWithStatus: 503
|
2014-06-30 16:35:55 +02:00
|
|
|
andJSONRepresentation: [NSDictionary dictionaryWithObjectsAndKeys: @"Service temporarily unavailable", @"textStatus", nil]];
|
2014-04-09 17:09:13 +02:00
|
|
|
}
|
2014-04-04 21:04:37 +02:00
|
|
|
else
|
2014-02-28 22:39:27 +01:00
|
|
|
results = self;
|
2014-04-09 17:09:13 +02:00
|
|
|
|
2007-06-19 19:58:21 +02:00
|
|
|
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
|
|
|
|
2013-11-11 16:49:58 +01:00
|
|
|
- (SOGoMailLabel *) label
|
|
|
|
{
|
|
|
|
return label;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setLabel: (SOGoMailLabel *) newLabel
|
|
|
|
{
|
|
|
|
ASSIGN(label, newLabel);
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSArray *) mailLabelList
|
|
|
|
{
|
|
|
|
if (!mailLabels)
|
|
|
|
{
|
|
|
|
NSDictionary *v;
|
2014-05-01 20:07:25 +02:00
|
|
|
|
2014-02-15 03:31:32 +01:00
|
|
|
v = [[[context activeUser] userDefaults] mailLabelsColors];
|
2013-11-11 16:49:58 +01:00
|
|
|
ASSIGN(mailLabels, [SOGoMailLabel labelsFromDefaults: v component: self]);
|
|
|
|
}
|
2014-05-01 20:07:25 +02:00
|
|
|
|
2013-11-11 16:49:58 +01:00
|
|
|
return mailLabels;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) mailLabelsValue
|
|
|
|
{
|
|
|
|
return @"";
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setMailLabelsValue: (NSString *) value
|
|
|
|
{
|
|
|
|
NSMutableDictionary *sanitizedLabels;
|
|
|
|
NSDictionary *newLabels;
|
|
|
|
NSArray *allKeys;
|
|
|
|
NSString *name;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
newLabels = [value objectFromJSONString];
|
|
|
|
if (newLabels && [newLabels isKindOfClass: [NSDictionary class]])
|
|
|
|
{
|
|
|
|
// We encode correctly our keys
|
|
|
|
sanitizedLabels = [NSMutableDictionary dictionary];
|
|
|
|
allKeys = [newLabels allKeys];
|
|
|
|
|
|
|
|
for (i = 0; i < [allKeys count]; i++)
|
|
|
|
{
|
|
|
|
name = [allKeys objectAtIndex: i];
|
|
|
|
|
|
|
|
if (![name is7bitSafe])
|
|
|
|
name = [name stringByEncodingImap4FolderName];
|
|
|
|
|
|
|
|
name = [name lowercaseString];
|
|
|
|
|
|
|
|
[sanitizedLabels setObject: [newLabels objectForKey: [allKeys objectAtIndex: i]]
|
|
|
|
forKey: name];
|
|
|
|
}
|
|
|
|
|
|
|
|
[userDefaults setMailLabelsColors: sanitizedLabels];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-12-01 17:53:15 +01:00
|
|
|
- (void) setCategory: (NSString *) newCategory
|
|
|
|
{
|
|
|
|
ASSIGN (category, newCategory);
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) category
|
|
|
|
{
|
|
|
|
return category;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) categoryColor
|
|
|
|
{
|
2015-09-15 21:59:31 +02:00
|
|
|
NSDictionary *defaultCalendarCategoriesColors;
|
2009-12-01 17:53:15 +01:00
|
|
|
NSString *categoryColor;
|
2009-07-16 17:57:31 +02:00
|
|
|
|
2009-12-01 17:53:15 +01:00
|
|
|
if (!calendarCategoriesColors)
|
2015-09-15 21:59:31 +02:00
|
|
|
{
|
|
|
|
NSArray *defaultCalendarCategories, *localizedCalendarCategories;
|
|
|
|
NSMutableDictionary *localizedCalendarCategoriesColors;
|
|
|
|
NSString *localizedCategory, *defaultCategory;
|
|
|
|
NSUInteger count, max;
|
|
|
|
|
|
|
|
defaultCalendarCategories = [userDefaults calendarCategories];
|
|
|
|
if (defaultCalendarCategories)
|
|
|
|
{
|
|
|
|
// User has custom calendar categories
|
|
|
|
ASSIGN (calendarCategoriesColors, [userDefaults calendarCategoriesColors]);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Build categories colors dictionary with localized keys
|
|
|
|
defaultCalendarCategories = [[[self pageResourceManager] stringForKey: @"calendar_category_labels"
|
|
|
|
inTableNamed: nil
|
|
|
|
withDefaultValue: nil
|
|
|
|
languages: [NSArray arrayWithObject: @"English"]]
|
|
|
|
componentsSeparatedByString: @","];
|
|
|
|
defaultCalendarCategoriesColors = [userDefaults calendarCategoriesColors];
|
|
|
|
max = [defaultCalendarCategories count];
|
|
|
|
localizedCalendarCategories = [self _languageCalendarCategories];
|
|
|
|
localizedCalendarCategoriesColors = [NSMutableDictionary dictionaryWithCapacity: max];
|
|
|
|
|
|
|
|
for (count = 0; count < max; count++)
|
|
|
|
{
|
|
|
|
localizedCategory = [localizedCalendarCategories objectAtIndex: count];
|
|
|
|
defaultCategory = [defaultCalendarCategories objectAtIndex: count];
|
|
|
|
[localizedCalendarCategoriesColors setObject: [defaultCalendarCategoriesColors objectForKey: defaultCategory]
|
|
|
|
forKey: localizedCategory];
|
|
|
|
}
|
|
|
|
|
|
|
|
ASSIGN (calendarCategoriesColors, localizedCalendarCategoriesColors);
|
|
|
|
}
|
|
|
|
}
|
2009-12-01 17:53:15 +01:00
|
|
|
|
|
|
|
categoryColor = [calendarCategoriesColors objectForKey: category];
|
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];
|
2014-05-01 20:07:25 +02:00
|
|
|
|
2010-10-26 21:26:50 +02:00
|
|
|
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
|
|
|
|
{
|
2016-01-05 19:56:40 +01:00
|
|
|
return [NSString stringWithFormat: @"(%@) %@", item, [self labelForKey: item]];
|
2009-10-01 23:41:54 +02:00
|
|
|
}
|
|
|
|
|
2010-08-06 17:34:05 +02:00
|
|
|
- (BOOL) mailAuxiliaryUserAccountsEnabled
|
|
|
|
{
|
|
|
|
return [[user domainDefaults] mailAuxiliaryUserAccountsEnabled];
|
|
|
|
}
|
|
|
|
|
2012-04-20 15:27:21 +02:00
|
|
|
- (void) _extractMainIdentity: (NSDictionary *) identity
|
2010-08-06 17:34:05 +02:00
|
|
|
{
|
|
|
|
/* We perform some validation here as we have no guaranty on the input
|
|
|
|
validity. */
|
2012-04-20 15:27:21 +02:00
|
|
|
NSString *value;
|
2010-08-06 17:34:05 +02:00
|
|
|
|
2012-04-20 15:27:21 +02:00
|
|
|
if ([identity isKindOfClass: [NSDictionary class]])
|
2010-08-06 17:34:05 +02:00
|
|
|
{
|
2012-04-20 15:27:21 +02:00
|
|
|
value = [identity objectForKey: @"signature"];
|
|
|
|
if (!value)
|
|
|
|
value = @"";
|
|
|
|
[userDefaults setMailSignature: value];
|
2012-04-20 15:37:46 +02:00
|
|
|
|
|
|
|
if (mailCustomFromEnabled)
|
|
|
|
{
|
|
|
|
value = [[identity objectForKey: @"email"]
|
|
|
|
stringByTrimmingSpaces];
|
|
|
|
|
|
|
|
/* We make sure that the "custom" value is different from the values
|
|
|
|
returned by the user directory service. */
|
|
|
|
if ([value length] == 0
|
|
|
|
|| [[user allEmails] containsObject: value])
|
2012-04-25 23:32:18 +02:00
|
|
|
value = nil;
|
|
|
|
[userDefaults setMailCustomEmail: value];
|
|
|
|
|
|
|
|
value = [[identity objectForKey: @"fullName"]
|
|
|
|
stringByTrimmingSpaces];
|
|
|
|
if ([value length] == 0
|
|
|
|
|| [[user cn] isEqualToString: value])
|
|
|
|
value = nil;
|
|
|
|
[userDefaults setMailCustomFullName: value];
|
2012-04-20 15:37:46 +02:00
|
|
|
}
|
|
|
|
|
2012-04-20 15:27:21 +02:00
|
|
|
value = [[identity objectForKey: @"replyTo"]
|
|
|
|
stringByTrimmingSpaces];
|
|
|
|
[userDefaults setMailReplyTo: value];
|
2010-08-06 17:34:05 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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"]));
|
|
|
|
}
|
|
|
|
|
2012-04-20 15:27:21 +02:00
|
|
|
- (void) _extractMainReceiptsPreferences: (NSDictionary *) receipts
|
2010-09-01 22:27:45 +02:00
|
|
|
{
|
|
|
|
/* We perform some validation here as we have no guaranty on the input
|
|
|
|
validity. */
|
|
|
|
NSString *action;
|
|
|
|
|
2012-04-20 15:27:21 +02:00
|
|
|
if ([receipts isKindOfClass: [NSDictionary class]])
|
2010-09-01 22:27:45 +02:00
|
|
|
{
|
2012-04-20 15:27:21 +02:00
|
|
|
action = [receipts objectForKey: @"receiptAction"];
|
|
|
|
[userDefaults
|
|
|
|
setAllowUserReceipt: [action isEqualToString: @"allow"]];
|
2014-05-01 20:07:25 +02:00
|
|
|
|
2012-04-20 15:27:21 +02:00
|
|
|
action = [receipts objectForKey: @"receiptNonRecipientAction"];
|
|
|
|
if ([self _validateReceiptAction: action])
|
|
|
|
[userDefaults setUserReceiptNonRecipientAction: action];
|
2010-09-01 22:27:45 +02:00
|
|
|
|
2012-04-20 15:27:21 +02:00
|
|
|
action = [receipts objectForKey: @"receiptOutsideDomainAction"];
|
|
|
|
if ([self _validateReceiptAction: action])
|
|
|
|
[userDefaults setUserReceiptOutsideDomainAction: action];
|
2014-05-01 20:07:25 +02:00
|
|
|
|
2012-04-20 15:27:21 +02:00
|
|
|
action = [receipts objectForKey: @"receiptAnyAction"];
|
|
|
|
if ([self _validateReceiptAction: action])
|
|
|
|
[userDefaults setUserReceiptAnyAction: action];
|
|
|
|
}
|
|
|
|
}
|
2010-09-01 22:27:45 +02:00
|
|
|
|
2012-04-20 15:27:21 +02:00
|
|
|
- (void) _extractMainCustomFrom: (NSDictionary *) account
|
|
|
|
{
|
|
|
|
}
|
2010-09-01 22:27:45 +02:00
|
|
|
|
2012-04-20 15:27:21 +02:00
|
|
|
- (void) _extractMainReplyTo: (NSDictionary *) account
|
|
|
|
{
|
2010-09-01 22:27:45 +02:00
|
|
|
}
|
|
|
|
|
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",
|
2012-04-20 15:27:21 +02:00
|
|
|
@"signature", @"replyTo", nil];
|
2010-08-06 17:34:05 +02:00
|
|
|
[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",
|
2012-04-20 15:27:21 +02:00
|
|
|
@"userName", @"password", @"encryption", @"replyTo",
|
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;
|
|
|
|
}
|
|
|
|
|
2012-04-20 15:27:21 +02:00
|
|
|
- (void) _extractMainAccountSettings: (NSDictionary *) account
|
|
|
|
{
|
|
|
|
NSArray *identities;
|
|
|
|
|
|
|
|
if ([account isKindOfClass: [NSDictionary class]])
|
|
|
|
{
|
|
|
|
identities = [account objectForKey: @"identities"];
|
|
|
|
if ([identities isKindOfClass: [NSArray class]]
|
|
|
|
&& [identities count] > 0)
|
|
|
|
[self _extractMainIdentity: [identities objectAtIndex: 0]];
|
|
|
|
[self _extractMainReceiptsPreferences: [account objectForKey: @"receipts"]];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-08-06 17:34:05 +02:00
|
|
|
- (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)
|
|
|
|
{
|
2012-04-20 15:27:21 +02:00
|
|
|
[self _extractMainAccountSettings: [accounts objectAtIndex: 0]];
|
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];
|
|
|
|
}
|
|
|
|
|
2012-04-20 15:37:46 +02:00
|
|
|
- (NSString *) mailCustomFromEnabled
|
|
|
|
{
|
|
|
|
return (mailCustomFromEnabled ? @"true" : @"false");
|
|
|
|
}
|
|
|
|
|
2007-06-19 19:58:21 +02:00
|
|
|
@end
|