mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-05-29 15:15:37 +00:00
Monotone-Parent: 2fdf0ead0781ef2362dd389811d5db44ca4cc84a
Monotone-Revision: c91eef7edcfd08d414664c25a590b6268a7e58e2 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2009-11-29T04:19:32 Monotone-Branch: ca.inverse.sogo
This commit is contained in:
@@ -0,0 +1,285 @@
|
||||
/* SOGoDomainDefaults.m - this file is part of SOGo
|
||||
*
|
||||
* Copyright (C) 2009 Inverse inc.
|
||||
*
|
||||
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||
*
|
||||
* This file is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This file is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#import <Foundation/NSDictionary.h>
|
||||
#import <Foundation/NSString.h>
|
||||
#import <NGObjWeb/WOApplication.h>
|
||||
#import <NGObjWeb/WOContext.h>
|
||||
#import <NGObjWeb/WORequest.h>
|
||||
#import <NGExtensions/NSObject+Logs.h>
|
||||
|
||||
#define NEEDS_DEFAULTS_SOURCE_INTERNAL 1
|
||||
#import "SOGoSystemDefaults.h"
|
||||
|
||||
#import "SOGoDomainDefaults.h"
|
||||
|
||||
@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]])
|
||||
{
|
||||
domainDefaults
|
||||
= [SOGoDomainDefaults defaultsSourceWithSource: domainValues
|
||||
andParentSource: systemDefaults];
|
||||
}
|
||||
}
|
||||
|
||||
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"];
|
||||
}
|
||||
|
||||
- (NSString *) mailDomain
|
||||
{
|
||||
return [self stringForKey: @"SOGoMailDomain"];
|
||||
}
|
||||
|
||||
- (NSString *) imapServer
|
||||
{
|
||||
return [self stringForKey: @"SOGoIMAPServer"];
|
||||
}
|
||||
|
||||
#warning should be removed when we make use of imap namespace
|
||||
- (NSString *) imapAclStyle
|
||||
{
|
||||
return [self stringForKey: @"SOGoIMAPAclStyle"];
|
||||
}
|
||||
|
||||
#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"];
|
||||
}
|
||||
|
||||
- (BOOL) forceIMAPLoginWithEmail
|
||||
{
|
||||
return [self boolForKey: @"SOGoForceIMAPLoginWithEmail"];
|
||||
}
|
||||
|
||||
- (BOOL) forwardEnabled
|
||||
{
|
||||
return [self boolForKey: @"SOGoForceIMAPLoginWithEmail"];
|
||||
}
|
||||
|
||||
- (BOOL) vacationEnabled
|
||||
{
|
||||
return [self boolForKey: @"SOGoForceIMAPLoginWithEmail"];
|
||||
}
|
||||
|
||||
- (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;
|
||||
}
|
||||
|
||||
return mailingMechanism;
|
||||
}
|
||||
|
||||
- (NSArray *) mailPollingIntervals
|
||||
{
|
||||
return [self arrayForKey: @"SOGoMailPollingIntervals"];
|
||||
}
|
||||
|
||||
- (NSString *) otherUsersFolderName
|
||||
{
|
||||
return [self stringForKey: @"SOGoOtherUsersFolderName"];
|
||||
}
|
||||
|
||||
- (NSString *) sharedFolderName
|
||||
{
|
||||
return [self stringForKey: @"SOGoSharedFolderName"];
|
||||
}
|
||||
|
||||
- (NSString *) smtpServer
|
||||
{
|
||||
return [self stringForKey: @"SOGoSMTPServer"];
|
||||
}
|
||||
|
||||
- (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"];
|
||||
}
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user