2009-11-29 05:19:32 +01:00
|
|
|
/* SOGoDomainDefaults.m - this file is part of SOGo
|
|
|
|
*
|
2015-02-11 20:30:40 +01:00
|
|
|
* Copyright (C) 2009-2015 Inverse inc.
|
2009-11-29 05:19:32 +01: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/NSDictionary.h>
|
|
|
|
#import <Foundation/NSString.h>
|
|
|
|
#import <NGObjWeb/WOApplication.h>
|
|
|
|
#import <NGObjWeb/WOContext.h>
|
|
|
|
#import <NGObjWeb/WORequest.h>
|
|
|
|
#import <NGExtensions/NSObject+Logs.h>
|
|
|
|
|
|
|
|
#import "SOGoSystemDefaults.h"
|
|
|
|
|
|
|
|
#import "SOGoDomainDefaults.h"
|
2010-03-08 16:18:05 +01:00
|
|
|
#import "SOGoConstants.h"
|
2009-11-29 05:19:32 +01:00
|
|
|
|
|
|
|
@implementation SOGoDomainDefaults
|
|
|
|
|
|
|
|
+ (SOGoDomainDefaults *) defaultsForDomain: (NSString *) domainId
|
|
|
|
{
|
|
|
|
NSDictionary *domainValues;
|
|
|
|
SOGoSystemDefaults *systemDefaults;
|
|
|
|
SOGoDomainDefaults *domainDefaults;
|
|
|
|
|
|
|
|
domainDefaults = nil;
|
|
|
|
|
|
|
|
if ([domainId length])
|
|
|
|
{
|
|
|
|
systemDefaults = [SOGoSystemDefaults sharedSystemDefaults];
|
|
|
|
domainValues = [[systemDefaults dictionaryForKey: @"domains"]
|
|
|
|
objectForKey: domainId];
|
|
|
|
if ([domainValues isKindOfClass: [NSDictionary class]])
|
2009-12-02 21:54:45 +01:00
|
|
|
domainDefaults = [self defaultsSourceWithSource: domainValues
|
|
|
|
andParentSource: systemDefaults];
|
2009-11-29 05:19:32 +01:00
|
|
|
}
|
|
|
|
|
2015-09-23 15:38:11 +02:00
|
|
|
if (!domainDefaults)
|
|
|
|
domainDefaults = [SOGoSystemDefaults sharedSystemDefaults];
|
|
|
|
|
2009-11-29 05:19:32 +01:00
|
|
|
return domainDefaults;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL) migrate
|
|
|
|
{
|
|
|
|
static NSDictionary *migratedKeys = nil;
|
|
|
|
|
|
|
|
if (!migratedKeys)
|
|
|
|
{
|
|
|
|
migratedKeys
|
|
|
|
= [NSDictionary dictionaryWithObjectsAndKeys:
|
|
|
|
@"SOGoIMAPServer", @"SOGoFallbackIMAP4Server",
|
|
|
|
@"SOGoMailDomain", @"SOGoDefaultMailDomain",
|
|
|
|
@"SOGoLDAPContactInfoAttribute", @"LDAPContactInfoAttribute",
|
|
|
|
@"SOGoUserSources", @"SOGoLDAPSources",
|
|
|
|
@"SOGoMailKeepDraftsAfterSend", @"SOGoNoDraftDeleteAfterSend",
|
|
|
|
@"SOGoMailAttachTextDocumentsInline", @"SOGoShowTextAttachmentsInline",
|
|
|
|
nil];
|
|
|
|
[migratedKeys retain];
|
|
|
|
}
|
|
|
|
|
|
|
|
/* we must not use a boolean operation, otherwise subsequent migrations will
|
|
|
|
not even occur in the case where rc = YES. */
|
|
|
|
return ([self migrateOldDefaultsWithDictionary: migratedKeys]
|
|
|
|
| [super migrate]);
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSArray *) userSources
|
|
|
|
{
|
|
|
|
return [source objectForKey: @"SOGoUserSources"];
|
|
|
|
}
|
|
|
|
|
|
|
|
/* System-/Domain-level */
|
|
|
|
|
|
|
|
// SOGoDontUseETagsForMailViewer
|
|
|
|
|
|
|
|
- (NSString *) profileURL
|
|
|
|
{
|
|
|
|
return [self stringForKey: @"SOGoProfileURL"];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) folderInfoURL
|
|
|
|
{
|
|
|
|
return [self stringForKey: @"OCSFolderInfoURL"];
|
|
|
|
}
|
|
|
|
|
2012-04-20 15:37:46 +02:00
|
|
|
- (BOOL) mailCustomFromEnabled
|
|
|
|
{
|
|
|
|
return [self boolForKey: @"SOGoMailCustomFromEnabled"];
|
|
|
|
}
|
|
|
|
|
2010-08-06 14:45:02 +02:00
|
|
|
- (BOOL) mailAuxiliaryUserAccountsEnabled
|
|
|
|
{
|
|
|
|
return [self boolForKey: @"SOGoMailAuxiliaryUserAccountsEnabled"];
|
|
|
|
}
|
|
|
|
|
2009-11-29 05:19:32 +01:00
|
|
|
- (NSString *) mailDomain
|
|
|
|
{
|
|
|
|
return [self stringForKey: @"SOGoMailDomain"];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) imapServer
|
|
|
|
{
|
|
|
|
return [self stringForKey: @"SOGoIMAPServer"];
|
|
|
|
}
|
|
|
|
|
2010-11-02 20:31:50 +01:00
|
|
|
- (NSString *) sieveServer
|
|
|
|
{
|
|
|
|
return [self stringForKey: @"SOGoSieveServer"];
|
|
|
|
}
|
|
|
|
|
2013-06-18 22:36:11 +02:00
|
|
|
- (NSString *) imapCASServiceName
|
|
|
|
{
|
|
|
|
return [self objectForKey: @"SOGoIMAPCASServiceName"];
|
|
|
|
}
|
|
|
|
|
2010-03-01 18:56:33 +01:00
|
|
|
#warning should be removed when we make use of imap namespace
|
|
|
|
- (NSString *) imapAclStyle
|
|
|
|
{
|
|
|
|
return [self stringForKey: @"SOGoIMAPAclStyle"];
|
|
|
|
}
|
|
|
|
|
2011-07-05 18:39:49 +02:00
|
|
|
- (NSString *) imapAclGroupIdPrefix
|
|
|
|
{
|
|
|
|
return [self stringForKey: @"NGImap4ConnectionGroupIdPrefix"];
|
|
|
|
}
|
|
|
|
|
2010-03-01 18:56:33 +01:00
|
|
|
- (NSString *) imapFolderSeparator
|
|
|
|
{
|
|
|
|
return [self stringForKey: @"NGImap4ConnectionStringSeparator"];
|
|
|
|
}
|
|
|
|
|
2009-11-29 05:19:32 +01:00
|
|
|
#warning this should be determined from the capabilities
|
|
|
|
/* http://www.tools.ietf.org/wg/imapext/draft-ietf-imapext-acl/ */
|
|
|
|
- (BOOL) imapAclConformsToIMAPExt
|
|
|
|
{
|
|
|
|
return [self boolForKey: @"SOGoIMAPAclConformsToIMAPExt"];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL) aclSendEMailNotifications
|
|
|
|
{
|
|
|
|
return [self boolForKey: @"SOGoACLsSendEMailNotifications"];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL) appointmentSendEMailNotifications
|
|
|
|
{
|
|
|
|
return [self boolForKey: @"SOGoAppointmentSendEMailNotifications"];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL) foldersSendEMailNotifications
|
|
|
|
{
|
|
|
|
return [self boolForKey: @"SOGoFoldersSendEMailNotifications"];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSArray *) calendarDefaultRoles
|
|
|
|
{
|
|
|
|
return [self stringArrayForKey: @"SOGoCalendarDefaultRoles"];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSArray *) contactsDefaultRoles
|
|
|
|
{
|
|
|
|
return [self stringArrayForKey: @"SOGoContactsDefaultRoles"];
|
|
|
|
}
|
|
|
|
|
2014-05-20 23:05:13 +02:00
|
|
|
- (NSString *) subscriptionFolderFormat
|
|
|
|
{
|
|
|
|
return [self stringForKey: @"SOGoSubscriptionFolderFormat"];
|
|
|
|
}
|
|
|
|
|
2013-01-11 15:55:10 +01:00
|
|
|
//
|
|
|
|
// In v2.0.4, SOGoForceIMAPLoginWithEmail was renamed to SOGoForceExternalLoginWithEmail
|
|
|
|
// but we keep backward compatbility for now with previous versions.
|
|
|
|
//
|
|
|
|
- (BOOL) forceExternalLoginWithEmail
|
2009-11-29 05:19:32 +01:00
|
|
|
{
|
2013-01-11 15:55:10 +01:00
|
|
|
if ([self stringForKey: @"SOGoForceExternalLoginWithEmail"])
|
|
|
|
return [self boolForKey: @"SOGoForceExternalLoginWithEmail"];
|
|
|
|
|
2009-11-29 05:19:32 +01:00
|
|
|
return [self boolForKey: @"SOGoForceIMAPLoginWithEmail"];
|
|
|
|
}
|
|
|
|
|
2010-03-02 20:57:30 +01:00
|
|
|
- (BOOL) sieveScriptsEnabled
|
|
|
|
{
|
|
|
|
return [self boolForKey: @"SOGoSieveScriptsEnabled"];
|
|
|
|
}
|
|
|
|
|
2009-11-29 05:19:32 +01:00
|
|
|
- (BOOL) forwardEnabled
|
|
|
|
{
|
2009-12-07 17:16:01 +01:00
|
|
|
return [self boolForKey: @"SOGoForwardEnabled"];
|
2009-11-29 05:19:32 +01:00
|
|
|
}
|
|
|
|
|
2015-02-11 20:30:40 +01:00
|
|
|
- (int) forwardConstraints
|
|
|
|
{
|
|
|
|
unsigned int v;
|
|
|
|
|
|
|
|
v = [self integerForKey: @"SOGoForwardConstraints"];
|
|
|
|
|
|
|
|
return (v > 2 ? 0 : v);
|
|
|
|
}
|
|
|
|
|
2009-11-29 05:19:32 +01:00
|
|
|
- (BOOL) vacationEnabled
|
|
|
|
{
|
2009-12-07 17:16:01 +01:00
|
|
|
return [self boolForKey: @"SOGoVacationEnabled"];
|
2009-11-29 05:19:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) mailingMechanism
|
|
|
|
{
|
|
|
|
NSString *mailingMechanism;
|
|
|
|
|
|
|
|
mailingMechanism = [self stringForKey: @"SOGoMailingMechanism"];
|
|
|
|
if (!([mailingMechanism isEqualToString: @"sendmail"]
|
|
|
|
|| [mailingMechanism isEqualToString: @"smtp"]))
|
|
|
|
{
|
|
|
|
[self logWithFormat: @"mechanism '%@' is invalid and"
|
|
|
|
@" should be set to 'sendmail' or 'smtp' instead",
|
|
|
|
mailingMechanism];
|
|
|
|
mailingMechanism = nil;
|
|
|
|
}
|
|
|
|
|
2012-12-03 22:33:14 +01:00
|
|
|
return [mailingMechanism lowercaseString];
|
2009-11-29 05:19:32 +01:00
|
|
|
}
|
|
|
|
|
2014-08-29 19:16:30 +02:00
|
|
|
- (NSArray *) refreshViewIntervals
|
2009-11-29 05:19:32 +01:00
|
|
|
{
|
2014-08-29 19:16:30 +02:00
|
|
|
return [self arrayForKey: @"SOGoRefreshViewIntervals"];
|
2009-11-29 05:19:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) smtpServer
|
|
|
|
{
|
|
|
|
return [self stringForKey: @"SOGoSMTPServer"];
|
|
|
|
}
|
|
|
|
|
2012-10-16 22:56:48 +02:00
|
|
|
- (NSString *) smtpAuthenticationType
|
|
|
|
{
|
2012-12-03 22:33:14 +01:00
|
|
|
return [[self stringForKey: @"SOGoSMTPAuthenticationType"] lowercaseString];
|
2012-10-16 22:56:48 +02:00
|
|
|
}
|
|
|
|
|
2009-11-29 05:19:32 +01:00
|
|
|
- (NSString *) mailSpoolPath
|
|
|
|
{
|
|
|
|
return [self stringForKey: @"SOGoMailSpoolPath"];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (float) softQuotaRatio
|
|
|
|
{
|
|
|
|
return [self floatForKey: @"SOGoSoftQuotaRatio"];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL) mailKeepDraftsAfterSend
|
|
|
|
{
|
|
|
|
return [self boolForKey: @"SOGoMailKeepDraftsAfterSend"];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL) mailAttachTextDocumentsInline
|
|
|
|
{
|
|
|
|
return [self boolForKey: @"SOGoMailAttachTextDocumentsInline"];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSArray *) mailListViewColumnsOrder
|
|
|
|
{
|
|
|
|
return [self stringArrayForKey: @"SOGoMailListViewColumnsOrder"];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSArray *) superUsernames
|
|
|
|
{
|
|
|
|
return [self stringArrayForKey: @"SOGoSuperUsernames"];
|
|
|
|
}
|
|
|
|
|
|
|
|
/* System-/Domain-/LDAP-level */
|
|
|
|
|
|
|
|
- (int) ldapQueryLimit
|
|
|
|
{
|
|
|
|
return [self integerForKey: @"SOGoLDAPQueryLimit"];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (int) ldapQueryTimeout
|
|
|
|
{
|
|
|
|
return [self integerForKey: @"SOGoLDAPQueryTimeout"];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *) ldapContactInfoAttribute
|
|
|
|
{
|
|
|
|
return [self stringForKey: @"SOGoLDAPContactInfoAttribute"];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSArray *) freeBusyDefaultInterval
|
|
|
|
{
|
|
|
|
return [self arrayForKey: @"SOGoFreeBusyDefaultInterval"];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (int) davCalendarStartTimeLimit
|
|
|
|
{
|
|
|
|
return [self integerForKey: @"SOGoDAVCalendarStartTimeLimit"];
|
|
|
|
}
|
|
|
|
|
2010-03-19 14:08:15 +01:00
|
|
|
- (BOOL) iPhoneForceAllDayTransparency
|
|
|
|
{
|
|
|
|
return [self boolForKey: @"SOGoiPhoneForceAllDayTransparency"];
|
|
|
|
}
|
|
|
|
|
2009-11-29 05:19:32 +01:00
|
|
|
/* overriden methods */
|
|
|
|
- (NSString *) language
|
|
|
|
{
|
|
|
|
NSArray *browserLanguages, *supportedLanguages;
|
|
|
|
NSString *language;
|
|
|
|
WOContext *context;
|
|
|
|
|
|
|
|
/* When we end up here, which means the active user has no language set, we
|
|
|
|
fetch the list of languages that are accepted by his/her browser and we
|
|
|
|
take the first of those which is supported. This ensures that the
|
|
|
|
resulting languages is always available. If not, we fallback on the
|
|
|
|
language of the domain or SOGo. */
|
|
|
|
context = [[WOApplication application] context];
|
|
|
|
browserLanguages = [[context request] browserLanguages];
|
|
|
|
supportedLanguages = [[SOGoSystemDefaults sharedSystemDefaults]
|
|
|
|
supportedLanguages];
|
|
|
|
language = [browserLanguages
|
|
|
|
firstObjectCommonWithArray: supportedLanguages];
|
|
|
|
if (!(language && [language isKindOfClass: [NSString class]]))
|
|
|
|
language = [self stringForKey: @"SOGoLanguage"];
|
|
|
|
|
|
|
|
return language;
|
|
|
|
}
|
|
|
|
|
2010-09-14 16:06:20 +02:00
|
|
|
- (NSArray *) additionalJSFiles
|
|
|
|
{
|
|
|
|
return [self stringArrayForKey: @"SOGoUIAdditionalJSFiles"];
|
|
|
|
}
|
|
|
|
|
2012-04-30 11:50:10 +02:00
|
|
|
- (BOOL) hideSystemEMail
|
|
|
|
{
|
|
|
|
return [self boolForKey: @"SOGoHideSystemEMail"];
|
|
|
|
}
|
|
|
|
|
2012-06-22 01:32:18 +02:00
|
|
|
- (int) searchMinimumWordLength
|
|
|
|
{
|
|
|
|
return [self integerForKey: @"SOGoSearchMinimumWordLength"];
|
|
|
|
}
|
|
|
|
|
2012-07-10 02:29:13 +02:00
|
|
|
- (BOOL) notifyOnPersonalModifications
|
|
|
|
{
|
|
|
|
return [self boolForKey: @"SOGoNotifyOnPersonalModifications"];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL) notifyOnExternalModifications
|
|
|
|
{
|
|
|
|
return [self boolForKey: @"SOGoNotifyOnExternalModifications"];
|
|
|
|
}
|
|
|
|
|
2009-11-29 05:19:32 +01:00
|
|
|
@end
|