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
|
|
|
|
|
|
|
#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>
|
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"
|
|
|
|
|
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];
|
|
|
|
}
|
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
// - (void) setHasChanged: (BOOL) newHasChanged
|
|
|
|
// {
|
|
|
|
// hasChanged = newHasChanged;
|
|
|
|
// }
|
2010-03-25 21:17:50 +01:00
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
// - (BOOL) hasChanged
|
|
|
|
// {
|
|
|
|
// return hasChanged;
|
|
|
|
// }
|
2010-03-25 21:17:50 +01:00
|
|
|
|
2007-06-19 19:58:21 +02:00
|
|
|
- (void) setItem: (NSString *) newItem
|
|
|
|
{
|
|
|
|
ASSIGN (item, newItem);
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) item
|
|
|
|
{
|
|
|
|
return item;
|
|
|
|
}
|
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
//
|
|
|
|
// Used by wox template
|
|
|
|
//
|
2007-06-19 19:58:21 +02:00
|
|
|
- (NSArray *) timeZonesList
|
|
|
|
{
|
2011-03-24 15:43:52 +01:00
|
|
|
return [[iCalTimeZone knownTimeZoneNames] sortedArrayUsingSelector: @selector (localizedCaseInsensitiveCompare:)];
|
2007-06-19 19:58:21 +02:00
|
|
|
}
|
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
// - (NSString *) userTimeZone
|
|
|
|
// {
|
|
|
|
// 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;
|
|
|
|
// }
|
|
|
|
|
|
|
|
// - (void) setUserTimeZone: (NSString *) newUserTimeZone
|
|
|
|
// {
|
|
|
|
// [userDefaults setTimeZoneName: newUserTimeZone];
|
|
|
|
// }
|
2007-06-19 19:58:21 +02:00
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
//
|
|
|
|
// Used by wox template
|
|
|
|
//
|
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;
|
|
|
|
}
|
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
//
|
|
|
|
// Used by wox template
|
|
|
|
//
|
2007-06-19 19:58:21 +02:00
|
|
|
- (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
|
|
|
}
|
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
// - (NSString *) userShortDateFormat
|
|
|
|
// {
|
|
|
|
// return [userDefaults shortDateFormat];
|
|
|
|
// }
|
2007-06-19 19:58:21 +02:00
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
// - (void) setUserShortDateFormat: (NSString *) newFormat
|
|
|
|
// {
|
|
|
|
// if ([newFormat isEqualToString: @"default"])
|
|
|
|
// [userDefaults unsetShortDateFormat];
|
|
|
|
// else
|
|
|
|
// [userDefaults setShortDateFormat: newFormat];
|
|
|
|
// }
|
|
|
|
|
|
|
|
//
|
|
|
|
// Used internally
|
|
|
|
//
|
|
|
|
- (NSString *) _userLongDateFormat
|
2007-06-19 19:58:21 +02:00
|
|
|
{
|
2015-03-22 13:00:21 +01:00
|
|
|
NSString *longDateFormat;
|
|
|
|
|
|
|
|
longDateFormat = [userDefaults longDateFormat];
|
|
|
|
if (!longDateFormat)
|
|
|
|
longDateFormat = @"default";
|
|
|
|
|
|
|
|
return longDateFormat;
|
2007-06-19 19:58:21 +02:00
|
|
|
}
|
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
//
|
|
|
|
// Used by wox template
|
|
|
|
//
|
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
|
|
|
}
|
|
|
|
|
2015-03-22 13:00:21 +01: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;
|
|
|
|
}
|
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
//
|
|
|
|
// Used by wox template
|
|
|
|
//
|
2007-06-19 19:58:21 +02:00
|
|
|
- (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
|
|
|
}
|
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
// - (void) setUserLongDateFormat: (NSString *) newFormat
|
|
|
|
// {
|
|
|
|
// if ([newFormat isEqualToString: @"default"])
|
|
|
|
// [userDefaults unsetLongDateFormat];
|
|
|
|
// else
|
|
|
|
// [userDefaults setLongDateFormat: newFormat];
|
|
|
|
// }
|
2007-06-19 19:58:21 +02:00
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
//
|
|
|
|
// Used by wox template
|
|
|
|
//
|
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;
|
|
|
|
}
|
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
//
|
|
|
|
// Used by wox template
|
|
|
|
//
|
2007-06-19 19:58:21 +02:00
|
|
|
- (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
|
|
|
}
|
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
// - (NSString *) userTimeFormat
|
|
|
|
// {
|
|
|
|
// return [userDefaults timeFormat];
|
|
|
|
// }
|
2007-06-19 19:58:21 +02:00
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
// - (void) setUserTimeFormat: (NSString *) newFormat
|
|
|
|
// {
|
|
|
|
// if ([newFormat isEqualToString: @"default"])
|
|
|
|
// [userDefaults unsetTimeFormat];
|
|
|
|
// else
|
|
|
|
// [userDefaults setTimeFormat: newFormat];
|
|
|
|
// }
|
2007-06-19 19:58:21 +02:00
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
//
|
|
|
|
// Used by wox template
|
|
|
|
//
|
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;
|
|
|
|
}
|
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
//
|
|
|
|
// Used by wox template
|
|
|
|
//
|
2007-06-19 19:58:21 +02:00
|
|
|
- (NSString *) itemWeekStartDay
|
|
|
|
{
|
|
|
|
return [daysOfWeek objectAtIndex: [item intValue]];
|
|
|
|
}
|
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
// - (NSString *) userWeekStartDay
|
|
|
|
// {
|
|
|
|
// return [NSString stringWithFormat: @"%d", [userDefaults firstDayOfWeek]];
|
|
|
|
// }
|
2007-06-19 19:58:21 +02:00
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
// - (void) setUserWeekStartDay: (NSString *) newDay
|
|
|
|
// {
|
|
|
|
// [userDefaults setFirstDayOfWeek: [newDay intValue]];
|
|
|
|
// }
|
2007-06-19 19:58:21 +02:00
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
//
|
|
|
|
// Used by wox template
|
|
|
|
//
|
2011-09-23 21:25:56 +02:00
|
|
|
- (NSArray *) defaultCalendarList
|
|
|
|
{
|
|
|
|
NSMutableArray *options;
|
|
|
|
|
|
|
|
options = [NSArray arrayWithObjects: @"selected", @"personal", @"first", nil];
|
|
|
|
|
|
|
|
return options;
|
|
|
|
}
|
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
//
|
|
|
|
// Used by wox template
|
|
|
|
//
|
2011-09-23 21:25:56 +02:00
|
|
|
- (NSString *) itemCalendarText
|
|
|
|
{
|
|
|
|
return [self labelForKey: [NSString stringWithFormat: @"%@Calendar", item]];
|
|
|
|
}
|
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
// - (NSString *) userDefaultCalendar
|
|
|
|
// {
|
|
|
|
// return [userDefaults defaultCalendar];
|
|
|
|
// }
|
2011-09-23 21:25:56 +02:00
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
// - (void) setUserDefaultCalendar: (NSString *) newValue
|
|
|
|
// {
|
|
|
|
// [userDefaults setDefaultCalendar: newValue];
|
|
|
|
// }
|
2011-09-23 21:25:56 +02:00
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
//
|
|
|
|
// Used by wox template
|
|
|
|
//
|
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;
|
|
|
|
}
|
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
//
|
|
|
|
// Used by wox template
|
|
|
|
//
|
2012-02-20 23:25:49 +01:00
|
|
|
- (NSString *) itemClassificationText
|
|
|
|
{
|
|
|
|
return [self labelForKey: [NSString stringWithFormat: @"%@_item",
|
|
|
|
item]];
|
|
|
|
}
|
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
// - (void) setEventsDefaultClassification: (NSString *) newValue
|
|
|
|
// {
|
|
|
|
// [userDefaults setCalendarEventsDefaultClassification: newValue];
|
|
|
|
// }
|
2012-02-20 23:25:49 +01:00
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
// - (NSString *) eventsDefaultClassification
|
|
|
|
// {
|
|
|
|
// return [userDefaults calendarEventsDefaultClassification];
|
|
|
|
// }
|
2012-02-20 23:25:49 +01:00
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
// - (void) setTasksDefaultClassification: (NSString *) newValue
|
|
|
|
// {
|
|
|
|
// [userDefaults setCalendarTasksDefaultClassification: newValue];
|
|
|
|
// }
|
2012-02-20 23:25:49 +01:00
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
// - (NSString *) tasksDefaultClassification
|
|
|
|
// {
|
|
|
|
// return [userDefaults calendarTasksDefaultClassification];
|
|
|
|
// }
|
2012-02-20 23:25:49 +01:00
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
//
|
|
|
|
// Used by wox template
|
|
|
|
//
|
2013-11-20 23:42:11 +01:00
|
|
|
- (NSArray *) reminderList
|
|
|
|
{
|
|
|
|
return reminderItems;
|
|
|
|
}
|
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
//
|
|
|
|
// Used by wox template
|
|
|
|
//
|
2013-11-20 23:42:11 +01:00
|
|
|
- (NSString *) itemReminderText
|
|
|
|
{
|
|
|
|
NSString *text;
|
|
|
|
|
|
|
|
if ([item isEqualToString: @"-"])
|
|
|
|
text = item;
|
|
|
|
else
|
|
|
|
text = [self labelForKey: [NSString stringWithFormat: @"reminder_%@", item]];
|
|
|
|
|
|
|
|
return text;
|
|
|
|
}
|
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
// - (void) setReminder: (NSString *) theReminder
|
|
|
|
// {
|
|
|
|
// NSString *value;
|
|
|
|
// NSUInteger index;
|
2013-11-20 23:42:11 +01:00
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
// index = NSNotFound;
|
|
|
|
// value = @"NONE";
|
2014-05-01 20:07:25 +02:00
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
// if (theReminder && [theReminder caseInsensitiveCompare: @"-"] != NSOrderedSame)
|
|
|
|
// index = [reminderItems indexOfObject: theReminder];
|
2013-11-20 23:42:11 +01:00
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
// if (index != NSNotFound)
|
|
|
|
// value = [reminderValues objectAtIndex: index];
|
2013-11-20 23:42:11 +01:00
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
// [userDefaults setCalendarDefaultReminder: value];
|
|
|
|
// }
|
2013-11-20 23:42:11 +01:00
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
// - (NSString *) reminder
|
|
|
|
// {
|
|
|
|
// NSString *value;
|
|
|
|
// NSUInteger index;
|
2013-11-20 23:42:11 +01:00
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
// value = [userDefaults calendarDefaultReminder];
|
|
|
|
// if (value != nil)
|
|
|
|
// {
|
|
|
|
// index = [reminderValues indexOfObject: value];
|
2013-11-20 23:42:11 +01:00
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
// if (index != NSNotFound)
|
|
|
|
// return [reminderItems objectAtIndex: index];
|
|
|
|
// }
|
2014-05-01 20:07:25 +02:00
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
// return @"NONE";
|
|
|
|
// }
|
2013-11-20 23:42:11 +01:00
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
//
|
|
|
|
// Used by wox template
|
|
|
|
//
|
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;
|
|
|
|
}
|
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
// - (NSString *) userDayStartTime
|
|
|
|
// {
|
|
|
|
// return [NSString stringWithFormat: @"%02d:00",
|
|
|
|
// [userDefaults dayStartHour]];
|
|
|
|
// }
|
|
|
|
|
|
|
|
// - (void) setUserDayStartTime: (NSString *) newTime
|
|
|
|
// {
|
|
|
|
// [userDefaults setDayStartTime: newTime];
|
|
|
|
// }
|
|
|
|
|
|
|
|
// - (NSString *) userDayEndTime
|
|
|
|
// {
|
|
|
|
// return [NSString stringWithFormat: @"%02d:00",
|
|
|
|
// [userDefaults dayEndHour]];
|
|
|
|
// }
|
|
|
|
|
|
|
|
// - (void) setUserDayEndTime: (NSString *) newTime
|
|
|
|
// {
|
|
|
|
// [userDefaults setDayEndTime: newTime];
|
|
|
|
// }
|
|
|
|
|
|
|
|
// - (void) setBusyOffHours: (BOOL) busyOffHours
|
|
|
|
// {
|
|
|
|
// [userDefaults setBusyOffHours: busyOffHours];
|
|
|
|
// }
|
|
|
|
|
|
|
|
// - (BOOL) busyOffHours
|
|
|
|
// {
|
|
|
|
// return [userDefaults busyOffHours];
|
|
|
|
// }
|
|
|
|
|
|
|
|
// - (NSArray *) whiteList
|
|
|
|
// {
|
|
|
|
// SOGoUserSettings *us;
|
|
|
|
// NSMutableDictionary *moduleSettings;
|
|
|
|
// NSArray *whiteList;
|
2014-07-07 16:00:16 +02:00
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
// us = [user userSettings];
|
|
|
|
// moduleSettings = [us objectForKey: @"Calendar"];
|
|
|
|
// whiteList = [moduleSettings objectForKey:@"PreventInvitationsWhitelist"];
|
|
|
|
// return whiteList;
|
|
|
|
// }
|
|
|
|
|
|
|
|
// - (void) setWhiteList: (NSString *) whiteListString
|
|
|
|
// {
|
|
|
|
// SOGoUserSettings *us;
|
|
|
|
// NSMutableDictionary *moduleSettings;
|
2015-04-08 20:20:33 +02:00
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
// us = [user userSettings];
|
|
|
|
// moduleSettings = [us objectForKey: @"Calendar"];
|
|
|
|
// [moduleSettings setObject: whiteListString forKey: @"PreventInvitationsWhitelist"];
|
|
|
|
// [us synchronize];
|
|
|
|
// }
|
|
|
|
|
|
|
|
// - (void) setPreventInvitations: (BOOL) preventInvitations
|
|
|
|
// {
|
|
|
|
// SOGoUserSettings *us;
|
|
|
|
// NSMutableDictionary *moduleSettings;
|
|
|
|
// us = [user userSettings];
|
|
|
|
// moduleSettings = [us objectForKey: @"Calendar"];
|
|
|
|
// [moduleSettings setObject: [NSNumber numberWithBool: preventInvitations] forKey: @"PreventInvitations"];
|
|
|
|
// [us synchronize];
|
|
|
|
// }
|
|
|
|
|
|
|
|
// - (BOOL) preventInvitations
|
|
|
|
// {
|
|
|
|
// SOGoUserSettings *us;
|
|
|
|
// NSMutableDictionary *moduleSettings;
|
|
|
|
// us = [user userSettings];
|
|
|
|
// moduleSettings = [us objectForKey: @"Calendar"];
|
|
|
|
// return [[moduleSettings objectForKey: @"PreventInvitations"] boolValue];
|
|
|
|
// }
|
2014-07-04 15:51:41 +02:00
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
//
|
|
|
|
// Used by wox template
|
|
|
|
//
|
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
|
|
|
}
|
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
//
|
|
|
|
// Used by wox template
|
|
|
|
//
|
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
|
|
|
}
|
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
// - (NSString *) userFirstWeek
|
|
|
|
// {
|
|
|
|
// return [userDefaults firstWeekOfYear];
|
|
|
|
// }
|
2007-06-19 19:58:21 +02:00
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
// - (void) setUserFirstWeek: (NSString *) newFirstWeek
|
|
|
|
// {
|
|
|
|
// [userDefaults setFirstWeekOfYear: newFirstWeek];
|
|
|
|
// }
|
2007-06-19 19:58:21 +02:00
|
|
|
|
2007-08-22 17:18:01 +02:00
|
|
|
/* Mailer */
|
2015-03-22 13:00:21 +01:00
|
|
|
// - (void) setAddOutgoingAddresses: (BOOL) addOutgoingAddresses
|
|
|
|
// {
|
|
|
|
// [userDefaults setMailAddOutgoingAddresses: addOutgoingAddresses];
|
|
|
|
// }
|
|
|
|
|
|
|
|
// - (BOOL) addOutgoingAddresses
|
|
|
|
// {
|
|
|
|
// return [userDefaults mailAddOutgoingAddresses];
|
|
|
|
// }
|
|
|
|
|
|
|
|
// - (void) setShowSubscribedFoldersOnly: (BOOL) showSubscribedFoldersOnly
|
|
|
|
// {
|
|
|
|
// [userDefaults setMailShowSubscribedFoldersOnly: showSubscribedFoldersOnly];
|
|
|
|
// }
|
|
|
|
|
|
|
|
// - (BOOL) showSubscribedFoldersOnly
|
|
|
|
// {
|
|
|
|
// return [userDefaults mailShowSubscribedFoldersOnly];
|
|
|
|
// }
|
|
|
|
|
|
|
|
// - (void) setSortByThreads: (BOOL) sortByThreads
|
|
|
|
// {
|
|
|
|
// [userDefaults setMailSortByThreads: sortByThreads];
|
|
|
|
// }
|
|
|
|
|
|
|
|
// - (BOOL) sortByThreads
|
|
|
|
// {
|
|
|
|
// return [userDefaults mailSortByThreads];
|
|
|
|
// }
|
2011-06-01 23:10:25 +02:00
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
//
|
|
|
|
// Used by wox template
|
|
|
|
//
|
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;
|
2014-06-26 22:08:47 +02:00
|
|
|
|
2014-03-25 19:53:42 +01:00
|
|
|
int i, count;
|
2014-03-27 20:27:48 +01:00
|
|
|
BOOL collectedAlreadyExist;
|
2014-06-26 22:08:47 +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;
|
2014-06-26 22:08:47 +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];
|
|
|
|
}
|
2014-06-26 22:08:47 +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;
|
2014-06-26 22:08:47 +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]];
|
|
|
|
|
|
|
|
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"];
|
|
|
|
}
|
2014-06-26 22:08:47 +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
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
//
|
|
|
|
// Used by wox template
|
|
|
|
//
|
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
|
|
|
}
|
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
// - (NSString *) userAddressBook
|
|
|
|
// {
|
|
|
|
// return [userDefaults selectedAddressBook];
|
|
|
|
// }
|
2014-03-24 18:41:57 +01:00
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
// - (void) setUserAddressBook: (NSString *) newSelectedAddressBook
|
|
|
|
// {
|
|
|
|
// [userDefaults setSelectedAddressBook: newSelectedAddressBook];
|
|
|
|
// }
|
2014-03-24 18:41:57 +01:00
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
//
|
|
|
|
// Used by wox template
|
|
|
|
//
|
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";
|
|
|
|
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)
|
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
|
|
|
}
|
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
//
|
|
|
|
// Used by wox template
|
|
|
|
//
|
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
|
|
|
}
|
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
// - (NSString *) userRefreshViewCheck
|
|
|
|
// {
|
|
|
|
// return [userDefaults refreshViewCheck];
|
|
|
|
// }
|
2007-10-26 17:35:51 +02:00
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
// - (void) setUserRefreshViewCheck: (NSString *) newRefreshViewCheck
|
|
|
|
// {
|
|
|
|
// [userDefaults setRefreshViewCheck: newRefreshViewCheck];
|
|
|
|
// }
|
2007-10-26 17:35:51 +02:00
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
//
|
|
|
|
// Used by wox template
|
|
|
|
//
|
2007-08-22 17:18:01 +02:00
|
|
|
- (NSArray *) messageForwardingList
|
|
|
|
{
|
|
|
|
return [NSArray arrayWithObjects: @"inline", @"attached", nil];
|
|
|
|
}
|
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
//
|
|
|
|
// Used by wox template
|
|
|
|
//
|
2007-08-22 17:18:01 +02:00
|
|
|
- (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
|
|
|
}
|
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
// - (NSString *) userMessageForwarding
|
|
|
|
// {
|
|
|
|
// return [userDefaults mailMessageForwarding];
|
|
|
|
// }
|
2007-08-22 17:18:01 +02:00
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
// - (void) setUserMessageForwarding: (NSString *) newMessageForwarding
|
|
|
|
// {
|
|
|
|
// [userDefaults setMailMessageForwarding: newMessageForwarding];
|
|
|
|
// }
|
2007-08-22 17:18:01 +02:00
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
//
|
|
|
|
// Used by wox template
|
|
|
|
//
|
2008-09-28 21:49:17 +02:00
|
|
|
- (NSArray *) replyPlacementList
|
|
|
|
{
|
|
|
|
return [NSArray arrayWithObjects: @"above", @"below", nil];
|
|
|
|
}
|
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
//
|
|
|
|
// Used by wox template
|
|
|
|
//
|
2008-09-28 21:49:17 +02:00
|
|
|
- (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
|
|
|
}
|
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
// - (NSString *) userReplyPlacement
|
|
|
|
// {
|
|
|
|
// return [userDefaults mailReplyPlacement];
|
|
|
|
// }
|
2008-09-28 21:49:17 +02:00
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
// - (void) setUserReplyPlacement: (NSString *) newReplyPlacement
|
|
|
|
// {
|
|
|
|
// [userDefaults setMailReplyPlacement: newReplyPlacement];
|
|
|
|
// }
|
2009-11-29 05:19:32 +01:00
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
//
|
|
|
|
// Used by wox template
|
|
|
|
//
|
2009-11-29 05:19:32 +01:00
|
|
|
- (NSString *) itemSignaturePlacementText
|
|
|
|
{
|
|
|
|
return [self labelForKey:
|
|
|
|
[NSString stringWithFormat: @"signatureplacement_%@", item]];
|
2008-09-28 21:49:17 +02:00
|
|
|
}
|
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
//
|
|
|
|
// Used by wox template
|
|
|
|
//
|
2008-09-28 21:49:17 +02:00
|
|
|
- (NSArray *) signaturePlacementList
|
|
|
|
{
|
|
|
|
return [NSArray arrayWithObjects: @"above", @"below", nil];
|
|
|
|
}
|
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
// - (void) setUserSignaturePlacement: (NSString *) newSignaturePlacement
|
|
|
|
// {
|
|
|
|
// [userDefaults setMailSignaturePlacement: newSignaturePlacement];
|
|
|
|
// }
|
2008-09-28 21:49:17 +02:00
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
// - (NSString *) userSignaturePlacement
|
|
|
|
// {
|
|
|
|
// return [userDefaults mailSignaturePlacement];
|
|
|
|
// }
|
2008-09-28 21:49:17 +02:00
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
//
|
|
|
|
// Used by wox template
|
|
|
|
//
|
2009-06-23 19:53:18 +02:00
|
|
|
- (NSArray *) composeMessagesType
|
|
|
|
{
|
|
|
|
return [NSArray arrayWithObjects: @"text", @"html", nil];
|
|
|
|
}
|
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
//
|
|
|
|
// Used by wox template
|
|
|
|
//
|
2009-06-23 19:53:18 +02:00
|
|
|
- (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
|
|
|
}
|
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
// - (NSString *) userComposeMessagesType
|
|
|
|
// {
|
|
|
|
// return [userDefaults mailComposeMessageType];
|
|
|
|
// }
|
2009-06-23 19:53:18 +02:00
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
// - (void) setUserComposeMessagesType: (NSString *) newType
|
|
|
|
// {
|
|
|
|
// [userDefaults setMailComposeMessageType: newType];
|
|
|
|
// }
|
2008-09-28 21:49:17 +02:00
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
//
|
|
|
|
// Used by wox template
|
|
|
|
//
|
2012-10-26 19:39:28 +02:00
|
|
|
- (NSArray *) displayRemoteInlineImages
|
|
|
|
{
|
|
|
|
return [NSArray arrayWithObjects: @"never", @"always", nil];
|
|
|
|
}
|
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
//
|
|
|
|
// Used by wox template
|
|
|
|
//
|
2012-10-26 19:39:28 +02:00
|
|
|
- (NSString *) itemDisplayRemoteInlineImagesText
|
|
|
|
{
|
|
|
|
return [self labelForKey: [NSString stringWithFormat:
|
|
|
|
@"displayremoteinlineimages_%@", item]];
|
|
|
|
}
|
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
// - (NSString *) userDisplayRemoteInlineImages
|
|
|
|
// {
|
|
|
|
// return [userDefaults mailDisplayRemoteInlineImages];
|
|
|
|
// }
|
2012-10-26 19:39:28 +02:00
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
// - (void) setAutoSave: (NSString *) theValue
|
|
|
|
// {
|
|
|
|
// [userDefaults setMailAutoSave: theValue];
|
|
|
|
// }
|
2014-12-11 19:31:32 +01:00
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
// - (NSString *) autoSave
|
|
|
|
// {
|
|
|
|
// return [userDefaults mailAutoSave];
|
|
|
|
// }
|
2014-12-11 19:31:32 +01:00
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
// - (void) setUserDisplayRemoteInlineImages: (NSString *) newType
|
|
|
|
// {
|
|
|
|
// [userDefaults setMailDisplayRemoteInlineImages: newType];
|
|
|
|
// }
|
2009-10-09 22:30:42 +02:00
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
//
|
|
|
|
// Used by wox template
|
|
|
|
//
|
2010-03-02 20:57:30 +01:00
|
|
|
- (BOOL) isSieveScriptsEnabled
|
|
|
|
{
|
|
|
|
return [[user domainDefaults] sieveScriptsEnabled];
|
|
|
|
}
|
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
//
|
|
|
|
// Used by wox template
|
|
|
|
//
|
2010-03-02 20:57:30 +01:00
|
|
|
- (NSString *) sieveCapabilities
|
|
|
|
{
|
|
|
|
static NSArray *capabilities = nil;
|
|
|
|
|
|
|
|
if (!capabilities)
|
|
|
|
{
|
2015-03-22 13:00:21 +01: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
|
|
|
}
|
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
//
|
|
|
|
// Used by wox template
|
|
|
|
//
|
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
|
|
|
}
|
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
// - (void) setSieveFiltersValue: (NSString *) newValue
|
|
|
|
// {
|
|
|
|
// sieveFilters = [newValue objectFromJSONString];
|
|
|
|
// if (sieveFilters)
|
|
|
|
// {
|
|
|
|
// if ([sieveFilters isKindOfClass: [NSArray class]])
|
|
|
|
// [sieveFilters retain];
|
|
|
|
// else
|
|
|
|
// sieveFilters = nil;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
// - (NSString *) sieveFiltersValue
|
|
|
|
// {
|
|
|
|
// return [sieveFilters jsonRepresentation];
|
|
|
|
// }
|
|
|
|
|
|
|
|
// - (void) setEnableVacation: (BOOL) enableVacation
|
|
|
|
// {
|
|
|
|
// [vacationOptions setObject: [NSNumber numberWithBool: enableVacation]
|
|
|
|
// forKey: @"enabled"];
|
|
|
|
// }
|
|
|
|
|
|
|
|
// - (BOOL) enableVacation
|
|
|
|
// {
|
|
|
|
// return [[vacationOptions objectForKey: @"enabled"] boolValue];
|
|
|
|
// }
|
|
|
|
|
|
|
|
// - (void) setAutoReplyText: (NSString *) theText
|
|
|
|
// {
|
|
|
|
// [vacationOptions setObject: theText forKey: @"autoReplyText"];
|
|
|
|
// }
|
|
|
|
|
|
|
|
// - (NSString *) autoReplyText
|
|
|
|
// {
|
|
|
|
// return [vacationOptions objectForKey: @"autoReplyText"];
|
|
|
|
// }
|
|
|
|
|
|
|
|
// - (void) setAutoReplyEmailAddresses: (NSString *) theAddresses
|
|
|
|
// {
|
|
|
|
// NSArray *addresses;
|
|
|
|
|
|
|
|
// addresses = [[theAddresses componentsSeparatedByString: @","]
|
|
|
|
// trimmedComponents];
|
|
|
|
// [vacationOptions setObject: addresses
|
|
|
|
// forKey: @"autoReplyEmailAddresses"];
|
|
|
|
// }
|
2009-10-09 22:30:42 +02:00
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
//
|
|
|
|
// Used internally
|
|
|
|
//
|
|
|
|
- (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: @", "];
|
|
|
|
}
|
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
//
|
|
|
|
// Used by templates
|
|
|
|
//
|
2009-10-15 00:11:13 +02:00
|
|
|
- (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: @", "]
|
2015-03-22 13:00:21 +01:00
|
|
|
: [self _defaultEmailAddresses]);
|
2009-10-09 22:30:42 +02:00
|
|
|
}
|
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
//
|
|
|
|
// Used by templates
|
|
|
|
//
|
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;
|
|
|
|
}
|
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
// - (void) setDaysBetweenResponses: (NSNumber *) theDays
|
|
|
|
// {
|
|
|
|
// [vacationOptions setObject: theDays
|
|
|
|
// forKey: @"daysBetweenResponse"];
|
|
|
|
// }
|
2009-10-09 22:30:42 +02:00
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
// - (NSString *) daysBetweenResponses
|
|
|
|
// {
|
|
|
|
// NSString *days;
|
2009-10-09 22:30:42 +02:00
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
// days = [vacationOptions objectForKey: @"daysBetweenResponse"];
|
|
|
|
// if (!days)
|
|
|
|
// days = @"7"; // defaults to 7 days
|
2009-10-09 22:30:42 +02:00
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
// return days;
|
|
|
|
// }
|
2009-10-09 22:30:42 +02:00
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
// - (void) setIgnoreLists: (BOOL) ignoreLists
|
|
|
|
// {
|
|
|
|
// [vacationOptions setObject: [NSNumber numberWithBool: ignoreLists]
|
|
|
|
// forKey: @"ignoreLists"];
|
|
|
|
// }
|
2009-10-09 22:30:42 +02:00
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
// - (BOOL) ignoreLists
|
|
|
|
// {
|
|
|
|
// NSNumber *obj;
|
|
|
|
// BOOL ignore;
|
2009-10-09 22:30:42 +02:00
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
// obj = [vacationOptions objectForKey: @"ignoreLists"];
|
2009-10-09 22:30:42 +02:00
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
// if (obj == nil)
|
|
|
|
// ignore = YES; // defaults to YES
|
|
|
|
// else
|
|
|
|
// ignore = [obj boolValue];
|
2009-10-09 22:30:42 +02:00
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
// return ignore;
|
|
|
|
// }
|
2009-10-09 22:30:42 +02:00
|
|
|
|
2015-02-09 22:12:59 +01:00
|
|
|
//
|
|
|
|
// See http://sogo.nu/bugs/view.php?id=2332 for details
|
|
|
|
//
|
2015-03-22 13:00:21 +01:00
|
|
|
// - (void) setAlwaysSend: (BOOL) ignoreLists
|
|
|
|
// {
|
|
|
|
// [vacationOptions setObject: [NSNumber numberWithBool: ignoreLists]
|
|
|
|
// forKey: @"alwaysSend"];
|
|
|
|
// }
|
2015-02-09 22:12:59 +01:00
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
// - (BOOL) alwaysSend
|
|
|
|
// {
|
|
|
|
// NSNumber *obj;
|
|
|
|
// BOOL ignore;
|
2015-02-09 22:12:59 +01:00
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
// obj = [vacationOptions objectForKey: @"alwaysSend"];
|
2015-02-09 22:12:59 +01:00
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
// if (obj == nil)
|
|
|
|
// ignore = NO; // defaults to NO
|
|
|
|
// else
|
|
|
|
// ignore = [obj boolValue];
|
2015-02-09 22:12:59 +01:00
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
// return ignore;
|
|
|
|
// }
|
2015-02-09 22:12:59 +01:00
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
// - (BOOL) enableVacationEndDate
|
|
|
|
// {
|
|
|
|
// return [[vacationOptions objectForKey: @"endDateEnabled"] boolValue];
|
|
|
|
// }
|
2011-11-21 15:09:26 +01:00
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
// - (BOOL) disableVacationEndDate
|
|
|
|
// {
|
|
|
|
// return ![self enableVacationEndDate];
|
|
|
|
// }
|
2011-11-21 15:09:26 +01:00
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
// - (void) setEnableVacationEndDate: (BOOL) enableVacationEndDate
|
|
|
|
// {
|
|
|
|
// [vacationOptions setObject: [NSNumber numberWithBool: enableVacationEndDate]
|
|
|
|
// forKey: @"endDateEnabled"];
|
|
|
|
// }
|
2011-11-21 15:09:26 +01:00
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
// - (void) setVacationEndDate: (NSCalendarDate *) endDate
|
|
|
|
// {
|
|
|
|
// NSNumber *time;
|
2014-05-01 20:07:25 +02:00
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
// time = [NSNumber numberWithInt: [endDate timeIntervalSince1970]];
|
2011-11-21 15:09:26 +01:00
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
// [vacationOptions setObject: time forKey: @"endDate"];
|
|
|
|
// }
|
2011-11-21 15:09:26 +01:00
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
// - (NSCalendarDate *) vacationEndDate
|
|
|
|
// {
|
|
|
|
// int time;
|
2011-11-21 15:09:26 +01:00
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
// time = [[vacationOptions objectForKey: @"endDate"] intValue];
|
2011-11-21 15:09:26 +01:00
|
|
|
|
2015-03-22 13:00:21 +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 */
|
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
//
|
|
|
|
// Used by templates
|
|
|
|
//
|
2009-10-09 22:30:42 +02:00
|
|
|
- (BOOL) isForwardEnabled
|
|
|
|
{
|
2009-11-29 05:19:32 +01:00
|
|
|
return [[user domainDefaults] forwardEnabled];
|
2009-10-09 22:30:42 +02:00
|
|
|
}
|
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
// - (void) setEnableForward: (BOOL) enableForward
|
|
|
|
// {
|
|
|
|
// [forwardOptions setObject: [NSNumber numberWithBool: enableForward]
|
|
|
|
// forKey: @"enabled"];
|
|
|
|
// }
|
|
|
|
|
|
|
|
// - (BOOL) enableForward
|
|
|
|
// {
|
|
|
|
// return [[forwardOptions objectForKey: @"enabled"] boolValue];
|
|
|
|
// }
|
|
|
|
|
|
|
|
// - (void) setForwardAddress: (NSString *) forwardAddress
|
|
|
|
// {
|
|
|
|
// NSArray *addresses;
|
|
|
|
|
|
|
|
// addresses = [[forwardAddress componentsSeparatedByString: @","]
|
|
|
|
// trimmedComponents];
|
|
|
|
// [forwardOptions setObject: addresses
|
|
|
|
// forKey: @"forwardAddress"];
|
|
|
|
// }
|
|
|
|
|
|
|
|
// - (NSString *) forwardAddress
|
|
|
|
// {
|
|
|
|
// id addresses;
|
|
|
|
|
|
|
|
// addresses = [forwardOptions objectForKey: @"forwardAddress"];
|
|
|
|
|
|
|
|
// return ([addresses respondsToSelector: @selector(componentsJoinedByString:)]
|
|
|
|
// ? [(NSArray *)addresses componentsJoinedByString: @", "]
|
|
|
|
// : (NSString *)addresses);
|
|
|
|
// }
|
|
|
|
|
|
|
|
// - (void) setForwardKeepCopy: (BOOL) keepCopy
|
|
|
|
// {
|
|
|
|
// [forwardOptions setObject: [NSNumber numberWithBool: keepCopy]
|
|
|
|
// forKey: @"keepCopy"];
|
|
|
|
// }
|
|
|
|
|
|
|
|
// - (BOOL) forwardKeepCopy
|
|
|
|
// {
|
|
|
|
// return [[forwardOptions objectForKey: @"keepCopy"] boolValue];
|
|
|
|
// }
|
|
|
|
|
|
|
|
// - (NSString *) forwardConstraints
|
|
|
|
// {
|
|
|
|
// SOGoDomainDefaults *dd;
|
2015-02-11 20:30:40 +01:00
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
// dd = [[context activeUser] domainDefaults];
|
2015-02-11 20:30:40 +01:00
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
// return [NSString stringWithFormat: @"%d", [dd forwardConstraints]];
|
|
|
|
// }
|
2009-10-09 22:30:42 +02:00
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
//
|
|
|
|
// Used by templates
|
|
|
|
//
|
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
|
|
|
}
|
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
//
|
|
|
|
// Used by templates
|
|
|
|
//
|
2009-08-19 19:19:32 +02:00
|
|
|
- (NSString *) itemModuleText
|
|
|
|
{
|
|
|
|
return [self labelForKey: item];
|
|
|
|
}
|
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
// - (NSString *) userDefaultModule
|
|
|
|
// {
|
|
|
|
// NSString *userDefaultModule;
|
2009-11-29 05:19:32 +01:00
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
// if ([userDefaults rememberLastModule])
|
|
|
|
// userDefaultModule = @"Last";
|
|
|
|
// else
|
|
|
|
// userDefaultModule = [userDefaults loginModule];
|
2009-08-19 19:19:32 +02:00
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
// return userDefaultModule;
|
|
|
|
// }
|
2009-08-19 19:19:32 +02:00
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
// - (void) setUserDefaultModule: (NSString *) newValue
|
|
|
|
// {
|
|
|
|
// if ([newValue isEqualToString: @"Last"])
|
|
|
|
// [userDefaults setRememberLastModule: YES];
|
|
|
|
// else
|
|
|
|
// {
|
|
|
|
// [userDefaults setRememberLastModule: NO];
|
|
|
|
// [userDefaults setLoginModule: newValue];
|
|
|
|
// }
|
|
|
|
// }
|
2009-08-19 19:19:32 +02:00
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
//
|
|
|
|
// Used by templates
|
|
|
|
//
|
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
|
|
|
}
|
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
//
|
|
|
|
// Used internally
|
|
|
|
//
|
|
|
|
- (id) _sieveClient
|
2014-04-04 21:04:37 +02:00
|
|
|
{
|
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
|
|
|
}
|
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
//
|
|
|
|
// Used internally
|
|
|
|
//
|
|
|
|
- (BOOL) _isSieveServerAvailable
|
2014-04-04 21:04:37 +02:00
|
|
|
{
|
2015-03-22 13:00:21 +01:00
|
|
|
return (([(NGSieveClient *)[self _sieveClient] isConnected])
|
2014-04-10 14:44:44 +02:00
|
|
|
? YES
|
|
|
|
: NO);
|
2014-03-10 15:33:27 +01:00
|
|
|
}
|
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
// - (id <WOActionResults>) defaultAction
|
|
|
|
// {
|
|
|
|
// id <WOActionResults> results;
|
|
|
|
// SOGoDomainDefaults *dd;
|
|
|
|
// SOGoMailAccount *account;
|
|
|
|
// SOGoMailAccounts *folder;
|
|
|
|
// WORequest *request;
|
|
|
|
|
|
|
|
// request = [context request];
|
|
|
|
// if ([[request method] isEqualToString: @"POST"])
|
|
|
|
// {
|
|
|
|
// dd = [[context activeUser] domainDefaults];
|
|
|
|
// if ([dd sieveScriptsEnabled])
|
|
|
|
// [userDefaults setSieveFilters: sieveFilters];
|
|
|
|
// if ([dd vacationEnabled])
|
|
|
|
// [userDefaults setVacationOptions: vacationOptions];
|
|
|
|
// if ([dd forwardEnabled])
|
|
|
|
// [userDefaults setForwardOptions: forwardOptions];
|
|
|
|
|
|
|
|
// if (!([dd sieveScriptsEnabled] || [dd vacationEnabled] || [dd forwardEnabled]) || [self _isSieveServerAvailable])
|
|
|
|
// {
|
|
|
|
// [userDefaults synchronize];
|
|
|
|
// folder = [[self clientObject] mailAccountsFolder: @"Mail"
|
|
|
|
// inContext: context];
|
|
|
|
// account = [folder lookupName: @"0" inContext: context acquire: NO];
|
|
|
|
|
|
|
|
// if ([account updateFilters])
|
|
|
|
// // If Sieve is not enabled, the SOGoSieveManager will immediatly return a positive answer
|
|
|
|
// // See [SOGoSieveManager updateFiltersForAccount:withUsername:andPassword:]
|
|
|
|
// results = [self responseWithStatus: 200
|
|
|
|
// andJSONRepresentation: [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithBool:hasChanged], @"hasChanged", nil]];
|
|
|
|
|
|
|
|
// else
|
|
|
|
// results = [self responseWithStatus: 502
|
|
|
|
// andJSONRepresentation: [NSDictionary dictionaryWithObjectsAndKeys: @"Connection error", @"textStatus", nil]];
|
|
|
|
// }
|
|
|
|
// else
|
|
|
|
// results = [self responseWithStatus: 503
|
|
|
|
// andJSONRepresentation: [NSDictionary dictionaryWithObjectsAndKeys: @"Service temporarily unavailable", @"textStatus", nil]];
|
|
|
|
// }
|
|
|
|
// else
|
|
|
|
// results = self;
|
|
|
|
|
|
|
|
// return results;
|
|
|
|
// }
|
2007-06-19 19:58:21 +02:00
|
|
|
|
|
|
|
- (BOOL) shouldTakeValuesFromRequest: (WORequest *) request
|
|
|
|
inContext: (WOContext*) context
|
|
|
|
{
|
|
|
|
return [[request method] isEqualToString: @"POST"];
|
|
|
|
}
|
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
//
|
|
|
|
// Used wox by template
|
|
|
|
//
|
2007-11-26 21:41:59 +01:00
|
|
|
- (BOOL) userHasCalendarAccess
|
|
|
|
{
|
|
|
|
return [user canAccessModule: @"Calendar"];
|
|
|
|
}
|
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
//
|
|
|
|
// Used wox by template
|
|
|
|
//
|
2007-11-26 21:41:59 +01:00
|
|
|
- (BOOL) userHasMailAccess
|
|
|
|
{
|
|
|
|
return [user canAccessModule: @"Mail"];
|
|
|
|
}
|
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
//
|
|
|
|
// Used wox by template
|
|
|
|
//
|
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
|
|
|
}
|
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
//
|
|
|
|
// Used wox by template
|
|
|
|
//
|
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
|
|
|
}
|
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
// - (NSString *) localeCode
|
|
|
|
// {
|
|
|
|
// // WARNING : NSLocaleCode is not defined in <Foundation/NSUserDefaults.h>
|
|
|
|
// return [locale objectForKey: @"NSLocaleCode"];
|
|
|
|
// }
|
2010-06-30 20:37:12 +02:00
|
|
|
|
2015-03-24 15:44:50 +01:00
|
|
|
// - (NSArray *) _languageCalendarCategories
|
|
|
|
// {
|
|
|
|
// NSArray *categoryLabels;
|
2009-07-16 17:57:31 +02:00
|
|
|
|
2015-03-24 15:44:50 +01:00
|
|
|
// categoryLabels = [[self labelForKey: @"calendar_category_labels"]
|
|
|
|
// componentsSeparatedByString: @","];
|
2009-12-01 17:53:15 +01:00
|
|
|
|
2015-03-24 15:44:50 +01:00
|
|
|
// return [categoryLabels trimmedComponents];
|
|
|
|
// }
|
2009-12-01 17:53:15 +01:00
|
|
|
|
2015-03-24 15:44:50 +01:00
|
|
|
// - (NSArray *) calendarCategoryList
|
|
|
|
// {
|
|
|
|
// if (!calendarCategories)
|
|
|
|
// {
|
|
|
|
// ASSIGN (calendarCategories, [userDefaults calendarCategories]);
|
|
|
|
// if (!calendarCategories)
|
|
|
|
// ASSIGN (calendarCategories, [self _languageCalendarCategories]);
|
|
|
|
// }
|
2009-07-16 17:57:31 +02:00
|
|
|
|
2015-03-24 15:44:50 +01:00
|
|
|
// return [calendarCategories
|
|
|
|
// sortedArrayUsingSelector: @selector (localizedCaseInsensitiveCompare:)];
|
|
|
|
// }
|
2009-07-16 17:57:31 +02:00
|
|
|
|
2015-03-24 15:44:50 +01:00
|
|
|
// - (SOGoMailLabel *) label
|
|
|
|
// {
|
|
|
|
// return label;
|
|
|
|
// }
|
2013-11-11 16:49:58 +01:00
|
|
|
|
2015-03-24 15:44:50 +01:00
|
|
|
// - (void) setLabel: (SOGoMailLabel *) newLabel
|
|
|
|
// {
|
|
|
|
// ASSIGN(label, newLabel);
|
|
|
|
// }
|
2013-11-11 16:49:58 +01:00
|
|
|
|
2015-03-24 15:44:50 +01:00
|
|
|
// - (NSArray *) mailLabelList
|
|
|
|
// {
|
|
|
|
// if (!mailLabels)
|
|
|
|
// {
|
|
|
|
// NSDictionary *v;
|
2014-05-01 20:07:25 +02:00
|
|
|
|
2015-03-24 15:44:50 +01:00
|
|
|
// v = [[[context activeUser] userDefaults] mailLabelsColors];
|
|
|
|
// ASSIGN(mailLabels, [SOGoMailLabel labelsFromDefaults: v component: self]);
|
|
|
|
// }
|
2014-05-01 20:07:25 +02:00
|
|
|
|
2015-03-24 15:44:50 +01:00
|
|
|
// return mailLabels;
|
|
|
|
// }
|
2013-11-11 16:49:58 +01:00
|
|
|
|
2015-03-24 15:44:50 +01:00
|
|
|
// - (NSString *) mailLabelsValue
|
|
|
|
// {
|
|
|
|
// return @"";
|
|
|
|
// }
|
2013-11-11 16:49:58 +01:00
|
|
|
|
2015-03-24 15:44:50 +01:00
|
|
|
// - (void) setMailLabelsValue: (NSString *) value
|
|
|
|
// {
|
|
|
|
// NSMutableDictionary *sanitizedLabels;
|
|
|
|
// NSDictionary *newLabels;
|
|
|
|
// NSArray *allKeys;
|
|
|
|
// NSString *name;
|
|
|
|
// int i;
|
2013-11-11 16:49:58 +01:00
|
|
|
|
2015-03-24 15:44:50 +01:00
|
|
|
// newLabels = [value objectFromJSONString];
|
|
|
|
// if (newLabels && [newLabels isKindOfClass: [NSDictionary class]])
|
|
|
|
// {
|
|
|
|
// // We encode correctly our keys
|
|
|
|
// sanitizedLabels = [NSMutableDictionary dictionary];
|
|
|
|
// allKeys = [newLabels allKeys];
|
2013-11-11 16:49:58 +01:00
|
|
|
|
2015-03-24 15:44:50 +01:00
|
|
|
// for (i = 0; i < [allKeys count]; i++)
|
|
|
|
// {
|
|
|
|
// name = [allKeys objectAtIndex: i];
|
2013-11-11 16:49:58 +01:00
|
|
|
|
2015-03-24 15:44:50 +01:00
|
|
|
// if (![name is7bitSafe])
|
|
|
|
// name = [name stringByEncodingImap4FolderName];
|
2013-11-11 16:49:58 +01:00
|
|
|
|
2015-03-24 15:44:50 +01:00
|
|
|
// name = [name lowercaseString];
|
2013-11-11 16:49:58 +01:00
|
|
|
|
2015-03-24 15:44:50 +01:00
|
|
|
// [sanitizedLabels setObject: [newLabels objectForKey: [allKeys objectAtIndex: i]]
|
|
|
|
// forKey: name];
|
|
|
|
// }
|
2013-11-11 16:49:58 +01:00
|
|
|
|
2015-03-24 15:44:50 +01:00
|
|
|
// [userDefaults setMailLabelsColors: sanitizedLabels];
|
|
|
|
// }
|
|
|
|
// }
|
2013-11-11 16:49:58 +01:00
|
|
|
|
|
|
|
|
2015-03-24 15:44:50 +01:00
|
|
|
// - (void) setCategory: (NSString *) newCategory
|
|
|
|
// {
|
|
|
|
// ASSIGN (category, newCategory);
|
|
|
|
// }
|
2009-12-01 17:53:15 +01:00
|
|
|
|
2015-03-24 15:44:50 +01:00
|
|
|
// - (NSString *) category
|
|
|
|
// {
|
|
|
|
// return category;
|
|
|
|
// }
|
2009-12-01 17:53:15 +01:00
|
|
|
|
2015-03-24 15:44:50 +01:00
|
|
|
// - (NSString *) categoryColor
|
|
|
|
// {
|
|
|
|
// SOGoDomainDefaults *dd;
|
|
|
|
// NSString *categoryColor;
|
2009-07-16 17:57:31 +02:00
|
|
|
|
2015-03-24 15:44:50 +01:00
|
|
|
// if (!calendarCategoriesColors)
|
|
|
|
// ASSIGN (calendarCategoriesColors, [userDefaults calendarCategoriesColors]);
|
2009-12-01 17:53:15 +01:00
|
|
|
|
2015-03-24 15:44:50 +01:00
|
|
|
// 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
|
|
|
|
2015-03-24 15:44:50 +01:00
|
|
|
// return categoryColor;
|
|
|
|
// }
|
2009-07-16 17:57:31 +02:00
|
|
|
|
2015-03-24 15:44:50 +01:00
|
|
|
// - (NSString *) calendarCategoriesValue
|
|
|
|
// {
|
|
|
|
// return @"";
|
|
|
|
// }
|
2009-07-16 17:57:31 +02:00
|
|
|
|
2015-03-24 15:44:50 +01:00
|
|
|
// - (void) setCalendarCategoriesValue: (NSString *) value
|
|
|
|
// {
|
|
|
|
// NSDictionary *newColors;
|
2009-12-01 17:53:15 +01:00
|
|
|
|
2015-03-24 15:44:50 +01:00
|
|
|
// newColors = [value objectFromJSONString];
|
|
|
|
// if (newColors && [newColors isKindOfClass: [NSDictionary class]])
|
|
|
|
// {
|
|
|
|
// [userDefaults setCalendarCategories: [newColors allKeys]];
|
|
|
|
// [userDefaults setCalendarCategoriesColors: newColors];
|
|
|
|
// }
|
|
|
|
// }
|
2009-07-16 17:57:31 +02:00
|
|
|
|
2015-03-24 15:44:50 +01:00
|
|
|
// - (NSArray *) _languageContactsCategories
|
|
|
|
// {
|
|
|
|
// NSArray *categoryLabels;
|
2010-10-26 21:26:50 +02:00
|
|
|
|
2015-03-24 15:44:50 +01:00
|
|
|
// categoryLabels = [[self labelForKey: @"contacts_category_labels"]
|
|
|
|
// componentsSeparatedByString: @","];
|
|
|
|
// if (!categoryLabels)
|
|
|
|
// categoryLabels = [NSArray array];
|
2014-05-01 20:07:25 +02:00
|
|
|
|
2015-03-24 15:44:50 +01:00
|
|
|
// return [categoryLabels trimmedComponents];
|
|
|
|
// }
|
2010-10-26 21:26:50 +02:00
|
|
|
|
2015-03-24 15:44:50 +01:00
|
|
|
// - (NSArray *) contactsCategoryList
|
|
|
|
// {
|
|
|
|
// if (!contactsCategories)
|
|
|
|
// {
|
|
|
|
// ASSIGN (contactsCategories, [userDefaults contactsCategories]);
|
|
|
|
// if (!contactsCategories)
|
|
|
|
// ASSIGN (contactsCategories, [self _languageContactsCategories]);
|
|
|
|
// }
|
2010-10-26 21:26:50 +02:00
|
|
|
|
2015-03-24 15:44:50 +01:00
|
|
|
// return [contactsCategories
|
|
|
|
// sortedArrayUsingSelector: @selector (localizedCaseInsensitiveCompare:)];
|
|
|
|
// }
|
2010-10-26 21:26:50 +02:00
|
|
|
|
2015-03-24 15:44:50 +01:00
|
|
|
// - (NSString *) contactsCategoriesValue
|
|
|
|
// {
|
|
|
|
// return @"";
|
|
|
|
// }
|
2010-10-26 21:26:50 +02:00
|
|
|
|
2015-03-24 15:44:50 +01:00
|
|
|
// - (void) setContactsCategoriesValue: (NSString *) value
|
|
|
|
// {
|
|
|
|
// NSArray *newCategories;
|
2010-10-26 21:26:50 +02:00
|
|
|
|
2015-03-24 15:44:50 +01:00
|
|
|
// newCategories = [value objectFromJSONString];
|
|
|
|
// if (newCategories && [newCategories isKindOfClass: [NSArray class]])
|
|
|
|
// [userDefaults setContactsCategories: newCategories];
|
|
|
|
// }
|
2010-10-26 21:26:50 +02:00
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
//
|
|
|
|
// Used by wox template
|
|
|
|
//
|
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
|
|
|
}
|
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
// - (NSString *) language
|
|
|
|
// {
|
|
|
|
// return [userDefaults language];
|
|
|
|
// }
|
2009-10-01 23:41:54 +02:00
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
// - (void) setLanguage: (NSString *) newLanguage
|
|
|
|
// {
|
|
|
|
// if ([[self languages] containsObject: newLanguage])
|
|
|
|
// [userDefaults setLanguage: newLanguage];
|
|
|
|
// }
|
2009-10-01 23:41:54 +02:00
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
//
|
|
|
|
// Used by wox template
|
|
|
|
//
|
2009-10-01 23:41:54 +02:00
|
|
|
- (NSString *) languageText
|
|
|
|
{
|
|
|
|
return [self labelForKey: item];
|
|
|
|
}
|
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
//
|
|
|
|
// Used by wox template
|
|
|
|
//
|
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];
|
|
|
|
}
|
|
|
|
|
2015-03-22 13:00:21 +01:00
|
|
|
// - (void) setMailAccounts: (NSString *) newMailAccounts
|
|
|
|
// {
|
|
|
|
// NSArray *accounts;
|
|
|
|
// int max;
|
|
|
|
|
|
|
|
// accounts = [newMailAccounts objectFromJSONString];
|
|
|
|
// if (accounts && [accounts isKindOfClass: [NSArray class]])
|
|
|
|
// {
|
|
|
|
// max = [accounts count];
|
|
|
|
// if (max > 0)
|
|
|
|
// {
|
|
|
|
// [self _extractMainAccountSettings: [accounts objectAtIndex: 0]];
|
|
|
|
// if ([self mailAuxiliaryUserAccountsEnabled])
|
|
|
|
// [self _extractAuxiliaryAccounts: accounts];
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
// - (NSString *) mailAccounts
|
|
|
|
// {
|
|
|
|
// NSArray *accounts;
|
|
|
|
// NSMutableDictionary *account;
|
|
|
|
// int count, max;
|
|
|
|
|
|
|
|
// accounts = [user mailAccounts];
|
|
|
|
// max = [accounts count];
|
|
|
|
// for (count = 0; count < max; count++)
|
|
|
|
// {
|
|
|
|
// account = [accounts objectAtIndex: count];
|
|
|
|
// [account removeObjectForKey: @"password"];
|
|
|
|
// }
|
|
|
|
|
|
|
|
// return [accounts jsonRepresentation];
|
|
|
|
// }
|
2010-08-06 17:34:05 +02:00
|
|
|
|
2012-04-20 15:37:46 +02:00
|
|
|
- (NSString *) mailCustomFromEnabled
|
|
|
|
{
|
|
|
|
return (mailCustomFromEnabled ? @"true" : @"false");
|
|
|
|
}
|
|
|
|
|
2015-02-25 23:21:07 +01:00
|
|
|
- (id <WOActionResults>) saveAction
|
|
|
|
{
|
2015-03-21 20:34:18 +01:00
|
|
|
id o, v;
|
|
|
|
|
|
|
|
o = [[[context request] contentAsString] objectFromJSONString];
|
|
|
|
|
2015-03-24 15:44:50 +01:00
|
|
|
// Proceed with data sanitization of the "defaults"
|
2015-03-21 20:34:18 +01:00
|
|
|
if ((v = [o objectForKey: @"defaults"]))
|
|
|
|
{
|
2015-03-24 15:44:50 +01:00
|
|
|
NSMutableDictionary *sanitizedLabels;
|
|
|
|
NSDictionary *newLabels;
|
|
|
|
NSArray *allKeys;
|
|
|
|
NSString *name;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
// We convert our object into a mutable one
|
|
|
|
v = [[v mutableCopy] autorelease];
|
|
|
|
|
|
|
|
newLabels = [v objectForKey: @"SOGoMailLabelsColors"];
|
|
|
|
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];
|
|
|
|
}
|
|
|
|
|
|
|
|
[v setObject: sanitizedLabels forKey: @"SOGoMailLabelsColors"];
|
|
|
|
}
|
|
|
|
|
2015-03-21 20:34:18 +01:00
|
|
|
[[[user userDefaults] source] setValues: v];
|
|
|
|
[[user userDefaults] synchronize];
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((v = [o objectForKey: @"settings"]))
|
|
|
|
{
|
|
|
|
[[[user userSettings] source] setValues: v];
|
|
|
|
[[user userSettings] synchronize];
|
|
|
|
}
|
|
|
|
|
2015-02-25 23:21:07 +01:00
|
|
|
return [self responseWithStatus: 200];
|
|
|
|
}
|
|
|
|
|
2007-06-19 19:58:21 +02:00
|
|
|
@end
|