2007-06-19 19:58:21 +02:00
|
|
|
/* UIxJSONPreferences.m - this file is part of SOGo
|
|
|
|
*
|
2016-03-25 02:44:29 +01:00
|
|
|
* Copyright (C) 2007-2016 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.
|
|
|
|
*/
|
|
|
|
|
2015-04-03 23:37:46 +02:00
|
|
|
#import <Foundation/NSDictionary.h>
|
2015-05-01 19:56:43 +02:00
|
|
|
#import <Foundation/NSValue.h>
|
2015-04-03 23:37:46 +02:00
|
|
|
|
2015-04-10 15:44:30 +02:00
|
|
|
#import <NGObjWeb/SoObjects.h>
|
2007-06-19 19:58:21 +02:00
|
|
|
#import <NGObjWeb/WOContext+SoObjects.h>
|
|
|
|
|
2016-03-25 02:44:29 +01:00
|
|
|
#import <NGExtensions/NSObject+Logs.h>
|
|
|
|
|
2016-05-06 20:14:45 +02:00
|
|
|
#import <SOPE/NGCards/iCalRecurrenceRule.h>
|
|
|
|
|
2009-11-29 05:19:32 +01:00
|
|
|
#import <SOGo/NSObject+Utilities.h>
|
2015-04-08 20:19:31 +02:00
|
|
|
#import <SOGo/NSString+Utilities.h>
|
2016-05-25 22:04:58 +02:00
|
|
|
#import <SOGo/SOGoDomainDefaults.h>
|
2009-11-29 05:19:32 +01:00
|
|
|
#import <SOGo/SOGoUser.h>
|
|
|
|
#import <SOGo/SOGoUserDefaults.h>
|
|
|
|
#import <SOGo/SOGoUserSettings.h>
|
|
|
|
#import <SOGo/SOGoUserProfile.h>
|
2015-11-03 20:59:40 +01:00
|
|
|
#import <SOGo/WOResourceManager+SOGo.h>
|
2015-03-24 15:44:50 +01:00
|
|
|
#import <Mailer/SOGoMailLabel.h>
|
|
|
|
|
2007-06-19 19:58:21 +02:00
|
|
|
#import "UIxJSONPreferences.h"
|
|
|
|
|
2015-04-10 15:44:30 +02:00
|
|
|
static SoProduct *preferencesProduct = nil;
|
|
|
|
|
2007-06-19 19:58:21 +02:00
|
|
|
@implementation UIxJSONPreferences
|
|
|
|
|
2016-03-25 02:44:29 +01:00
|
|
|
- (NSDictionary *) _localizedCategoryLabels
|
|
|
|
{
|
|
|
|
NSArray *categoryLabels, *localizedCategoryLabels;
|
|
|
|
NSDictionary *labelsDictionary;
|
|
|
|
|
|
|
|
labelsDictionary = nil;
|
|
|
|
localizedCategoryLabels = [[self labelForKey: @"calendar_category_labels"
|
|
|
|
withResourceManager: [preferencesProduct resourceManager]]
|
|
|
|
componentsSeparatedByString: @","];
|
|
|
|
categoryLabels = [[[preferencesProduct resourceManager]
|
|
|
|
stringForKey: @"calendar_category_labels"
|
|
|
|
inTableNamed: nil
|
|
|
|
withDefaultValue: @""
|
|
|
|
languages: [NSArray arrayWithObject: @"English"]]
|
|
|
|
componentsSeparatedByString: @","];
|
|
|
|
|
|
|
|
if ([localizedCategoryLabels count] == [categoryLabels count])
|
|
|
|
labelsDictionary = [NSDictionary dictionaryWithObjects: localizedCategoryLabels
|
|
|
|
forKeys: categoryLabels];
|
|
|
|
else
|
|
|
|
[self logWithFormat: @"ERROR: localizable strings calendar_category_labels is incorrect for language %@",
|
|
|
|
[[[context activeUser] userDefaults] language]];
|
|
|
|
|
|
|
|
return labelsDictionary;
|
|
|
|
}
|
|
|
|
|
2007-06-19 19:58:21 +02:00
|
|
|
- (WOResponse *) jsonDefaultsAction
|
|
|
|
{
|
2015-04-30 17:19:30 +02:00
|
|
|
NSMutableDictionary *values, *account;
|
2009-11-29 05:19:32 +01:00
|
|
|
SOGoUserDefaults *defaults;
|
2016-05-25 22:04:58 +02:00
|
|
|
SOGoDomainDefaults *domainDefaults;
|
2015-04-10 15:44:30 +02:00
|
|
|
NSMutableArray *accounts;
|
2016-03-25 02:44:29 +01:00
|
|
|
NSDictionary *categoryLabels;
|
2015-08-06 22:07:46 +02:00
|
|
|
NSDictionary *locale;
|
|
|
|
|
2015-04-10 15:44:30 +02:00
|
|
|
if (!preferencesProduct)
|
|
|
|
{
|
|
|
|
preferencesProduct = [[SoProduct alloc] initWithBundle:
|
|
|
|
[NSBundle bundleForClass: NSClassFromString(@"PreferencesUIProduct")]];
|
|
|
|
}
|
|
|
|
|
2007-06-19 19:58:21 +02:00
|
|
|
defaults = [[context activeUser] userDefaults];
|
2016-05-25 22:04:58 +02:00
|
|
|
domainDefaults = [[context activeUser] domainDefaults];
|
2016-03-25 02:44:29 +01:00
|
|
|
categoryLabels = nil;
|
2015-04-06 16:55:42 +02:00
|
|
|
|
2015-04-10 15:44:30 +02:00
|
|
|
//
|
|
|
|
// Default General preferences
|
|
|
|
//
|
|
|
|
if (![[defaults source] objectForKey: @"SOGoLanguage"])
|
|
|
|
[[defaults source] setObject: [defaults language] forKey: @"SOGoLanguage"];
|
|
|
|
|
|
|
|
if (![[defaults source] objectForKey: @"SOGoTimeZone"])
|
|
|
|
[[defaults source] setObject: [defaults timeZoneName] forKey: @"SOGoTimeZone"];
|
2015-08-06 22:07:46 +02:00
|
|
|
|
2015-04-06 16:55:42 +02:00
|
|
|
if (![[defaults source] objectForKey: @"SOGoShortDateFormat"])
|
2015-04-10 15:44:30 +02:00
|
|
|
[[defaults source] setObject: [defaults shortDateFormat] forKey: @"SOGoShortDateFormat"];
|
2015-04-06 16:55:42 +02:00
|
|
|
|
2015-03-24 15:44:50 +01:00
|
|
|
if (![[defaults source] objectForKey: @"SOGoLongDateFormat"])
|
2015-04-10 15:44:30 +02:00
|
|
|
[[defaults source] setObject: [defaults longDateFormat] forKey: @"SOGoLongDateFormat"];
|
2015-03-24 15:44:50 +01:00
|
|
|
|
2015-04-10 15:44:30 +02:00
|
|
|
if (![[defaults source] objectForKey: @"SOGoTimeFormat"])
|
|
|
|
[[defaults source] setObject: [defaults timeFormat] forKey: @"SOGoTimeFormat"];
|
|
|
|
|
|
|
|
if (![[defaults source] objectForKey: @"SOGoLoginModule"])
|
|
|
|
[[defaults source] setObject: [defaults loginModule] forKey: @"SOGoLoginModule"];
|
2015-08-06 22:07:46 +02:00
|
|
|
|
2015-04-10 15:44:30 +02:00
|
|
|
if (![[defaults source] objectForKey: @"SOGoRefreshViewCheck"])
|
|
|
|
[[defaults source] setObject: [defaults refreshViewCheck] forKey: @"SOGoRefreshViewCheck"];
|
|
|
|
|
2016-05-25 22:04:58 +02:00
|
|
|
if ([domainDefaults externalAvatarsEnabled])
|
|
|
|
{
|
|
|
|
if (![[defaults source] objectForKey: @"SOGoGravatarEnabled"])
|
|
|
|
[[defaults source] setObject: [NSNumber numberWithBool: [defaults gravatarEnabled]] forKey: @"SOGoGravatarEnabled"];
|
|
|
|
if (![[defaults source] objectForKey: @"SOGoAlternateAvatar"])
|
|
|
|
[[defaults source] setObject: [defaults alternateAvatar] forKey: @"SOGoAlternateAvatar"];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
[[defaults source] setObject: [NSNumber numberWithInt: 0] forKey: @"SOGoGravatarEnabled"];
|
|
|
|
[[defaults source] removeObjectForKey: @"SOGoAlternateAvatar"];
|
|
|
|
}
|
2015-11-27 22:04:12 +01:00
|
|
|
|
2015-04-10 15:44:30 +02:00
|
|
|
//
|
|
|
|
// Default Calendar preferences
|
|
|
|
//
|
|
|
|
if (![[defaults source] objectForKey: @"SOGoFirstDayOfWeek"])
|
|
|
|
[[defaults source] setObject: [NSNumber numberWithInt: [defaults firstDayOfWeek]] forKey: @"SOGoFirstDayOfWeek"];
|
2015-08-06 22:07:46 +02:00
|
|
|
|
2015-04-10 15:44:30 +02:00
|
|
|
if (![[defaults source] objectForKey: @"SOGoDayStartTime"])
|
|
|
|
[[defaults source] setObject: [NSString stringWithFormat: @"%02d:00", [defaults dayStartHour]] forKey: @"SOGoDayStartTime"];
|
|
|
|
|
|
|
|
if (![[defaults source] objectForKey: @"SOGoDayEndTime"])
|
|
|
|
[[defaults source] setObject: [NSString stringWithFormat: @"%02d:00", [defaults dayEndHour]] forKey: @"SOGoDayEndTime"];
|
2015-08-06 22:07:46 +02:00
|
|
|
|
2016-05-06 20:14:45 +02:00
|
|
|
if (![[defaults source] objectForKey: @"SOGoCalendarWeekdays"])
|
|
|
|
[[defaults source] setObject: [NSArray arrayWithObjects: iCalWeekDayString count: 7] forKey: @"SOGoCalendarWeekdays"];
|
|
|
|
|
2015-04-07 22:32:51 +02:00
|
|
|
if (![[defaults source] objectForKey: @"SOGoFirstWeekOfYear"])
|
|
|
|
[[defaults source] setObject: [defaults firstWeekOfYear] forKey: @"SOGoFirstWeekOfYear"];
|
2015-04-10 15:44:30 +02:00
|
|
|
|
|
|
|
if (![[defaults source] objectForKey: @"SOGoDefaultCalendar"])
|
|
|
|
[[defaults source] setObject: [defaults defaultCalendar] forKey: @"SOGoDefaultCalendar"];
|
|
|
|
|
|
|
|
if (![[defaults source] objectForKey: @"SOGoCalendarEventsDefaultClassification"])
|
|
|
|
[[defaults source] setObject: [defaults calendarEventsDefaultClassification] forKey: @"SOGoCalendarEventsDefaultClassification"];
|
2015-08-06 22:07:46 +02:00
|
|
|
|
2015-04-10 15:44:30 +02:00
|
|
|
if (![[defaults source] objectForKey: @"SOGoCalendarTasksDefaultClassification"])
|
|
|
|
[[defaults source] setObject: [defaults calendarTasksDefaultClassification] forKey: @"SOGoCalendarTasksDefaultClassification"];
|
2015-08-06 22:07:46 +02:00
|
|
|
|
2015-04-10 15:44:30 +02:00
|
|
|
if (![[defaults source] objectForKey: @"SOGoCalendarDefaultReminder"])
|
|
|
|
[[defaults source] setObject: [defaults calendarDefaultReminder] forKey: @"SOGoCalendarDefaultReminder"];
|
2015-08-06 22:07:46 +02:00
|
|
|
|
2015-03-24 15:44:50 +01:00
|
|
|
// Populate default calendar categories, based on the user's preferred language
|
2016-03-25 02:44:29 +01:00
|
|
|
if (![[defaults source] objectForKey: @"SOGoCalendarCategories"])
|
2015-03-24 15:44:50 +01:00
|
|
|
{
|
2016-03-25 02:44:29 +01:00
|
|
|
NSArray *defaultCalendarCategories;
|
|
|
|
|
|
|
|
categoryLabels = [self _localizedCategoryLabels];
|
|
|
|
|
|
|
|
if ((defaultCalendarCategories = [defaults calendarCategories]))
|
|
|
|
{
|
|
|
|
// Calendar categories are taken from SOGo's configuration or SOGoDefaults.plist
|
|
|
|
|
|
|
|
NSMutableArray *filteredCalendarCategories;
|
|
|
|
NSString *label, *localizedLabel;
|
|
|
|
int count, max;
|
2015-08-06 22:07:46 +02:00
|
|
|
|
2016-03-25 02:44:29 +01:00
|
|
|
max = [defaultCalendarCategories count];
|
|
|
|
filteredCalendarCategories = [NSMutableArray arrayWithCapacity: max];
|
2016-01-11 22:32:12 +01:00
|
|
|
|
2016-03-25 02:44:29 +01:00
|
|
|
for (count = 0; count < max; count++)
|
|
|
|
{
|
|
|
|
label = [defaultCalendarCategories objectAtIndex: count];
|
|
|
|
if ((localizedLabel = [categoryLabels objectForKey: label]))
|
|
|
|
{
|
|
|
|
[filteredCalendarCategories addObject: localizedLabel];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
[defaults setCalendarCategories: filteredCalendarCategories];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Calendar categories are taken from localizable strings
|
|
|
|
|
|
|
|
[defaults setCalendarCategories: [categoryLabels allValues]];
|
|
|
|
}
|
2015-03-24 15:44:50 +01:00
|
|
|
}
|
2016-03-25 02:44:29 +01:00
|
|
|
if (![[defaults source] objectForKey: @"SOGoCalendarCategoriesColors"])
|
2015-04-28 21:15:42 +02:00
|
|
|
{
|
2016-03-25 02:44:29 +01:00
|
|
|
NSDictionary *defaultCalendarCategoriesColors;
|
|
|
|
|
|
|
|
if (!categoryLabels)
|
|
|
|
categoryLabels = [self _localizedCategoryLabels];
|
|
|
|
|
|
|
|
if ((defaultCalendarCategoriesColors = [defaults calendarCategoriesColors]))
|
|
|
|
{
|
|
|
|
// Calendar categories colors are taken from SOGo's configuration or SOGoDefaults.plist
|
|
|
|
|
|
|
|
NSArray *defaultCalendarCategories;
|
|
|
|
NSMutableDictionary *filteredCalendarCategoriesColors;
|
|
|
|
NSString *label, *localizedLabel;
|
|
|
|
int count, max;
|
|
|
|
|
|
|
|
defaultCalendarCategories = [defaultCalendarCategoriesColors allKeys];
|
|
|
|
max = [defaultCalendarCategories count];
|
|
|
|
filteredCalendarCategoriesColors = [NSMutableDictionary dictionaryWithCapacity: max];
|
|
|
|
|
|
|
|
for (count = 0; count < max; count++)
|
|
|
|
{
|
|
|
|
label = [defaultCalendarCategories objectAtIndex: count];
|
|
|
|
if ((localizedLabel = [categoryLabels objectForKey: label]))
|
|
|
|
{
|
|
|
|
[filteredCalendarCategoriesColors setObject: [defaultCalendarCategoriesColors objectForKey: label]
|
|
|
|
forKey: localizedLabel];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
[defaults setCalendarCategoriesColors: filteredCalendarCategoriesColors];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Calendar categories colors are set to #CCC
|
|
|
|
|
|
|
|
NSArray *calendarCategories;
|
|
|
|
NSMutableDictionary *colors;
|
|
|
|
int i;
|
2015-04-28 21:15:42 +02:00
|
|
|
|
2016-03-25 02:44:29 +01:00
|
|
|
calendarCategories = [categoryLabels allValues];
|
|
|
|
colors = [NSMutableDictionary dictionaryWithCapacity: [calendarCategories count]];
|
2015-04-28 21:15:42 +02:00
|
|
|
|
2016-03-25 02:44:29 +01:00
|
|
|
for (i = 0; i < [calendarCategories count]; i++)
|
|
|
|
[colors setObject: @"#CCCCCCC" forKey: [calendarCategories objectAtIndex: i]];
|
2015-04-28 21:15:42 +02:00
|
|
|
|
2016-03-25 02:44:29 +01:00
|
|
|
[defaults setCalendarCategoriesColors: colors];
|
|
|
|
}
|
2015-04-28 21:15:42 +02:00
|
|
|
}
|
2015-08-06 22:07:46 +02:00
|
|
|
|
2015-04-10 15:44:30 +02:00
|
|
|
//
|
|
|
|
// Default Contacts preferences
|
|
|
|
//
|
2015-03-24 15:44:50 +01:00
|
|
|
// Populate default contact categories, based on the user's preferred language
|
2015-04-10 15:44:30 +02:00
|
|
|
//
|
2015-03-24 15:44:50 +01:00
|
|
|
if (![defaults contactsCategories])
|
|
|
|
{
|
2015-04-10 15:44:30 +02:00
|
|
|
categoryLabels = [[[self labelForKey: @"contacts_category_labels" withResourceManager: [preferencesProduct resourceManager]]
|
2015-04-03 23:37:46 +02:00
|
|
|
componentsSeparatedByString: @","]
|
2015-03-24 15:44:50 +01:00
|
|
|
sortedArrayUsingSelector: @selector (localizedCaseInsensitiveCompare:)];
|
2015-08-06 22:07:46 +02:00
|
|
|
|
2015-03-24 15:44:50 +01:00
|
|
|
if (!categoryLabels)
|
|
|
|
categoryLabels = [NSArray array];
|
2015-08-06 22:07:46 +02:00
|
|
|
|
2015-03-24 15:44:50 +01:00
|
|
|
[defaults setContactsCategories: categoryLabels];
|
|
|
|
}
|
2015-04-10 15:44:30 +02:00
|
|
|
|
|
|
|
//
|
|
|
|
// Default Mail preferences
|
|
|
|
//
|
|
|
|
if (![[defaults source] objectForKey: @"SOGoSelectedAddressBook"])
|
|
|
|
[[defaults source] setObject: [defaults selectedAddressBook] forKey: @"SOGoSelectedAddressBook"];
|
|
|
|
|
|
|
|
if (![[defaults source] objectForKey: @"SOGoMailMessageForwarding"])
|
|
|
|
[[defaults source] setObject: [defaults mailMessageForwarding] forKey: @"SOGoMailMessageForwarding"];
|
|
|
|
|
|
|
|
if (![[defaults source] objectForKey: @"SOGoMailReplyPlacement"])
|
|
|
|
[[defaults source] setObject: [defaults mailReplyPlacement] forKey: @"SOGoMailReplyPlacement"];
|
2015-08-06 22:07:46 +02:00
|
|
|
|
2015-04-10 15:44:30 +02:00
|
|
|
if (![[defaults source] objectForKey: @"SOGoMailSignaturePlacement"])
|
|
|
|
[[defaults source] setObject: [defaults mailSignaturePlacement] forKey: @"SOGoMailSignaturePlacement"];
|
2015-08-06 22:07:46 +02:00
|
|
|
|
2015-04-10 15:44:30 +02:00
|
|
|
if (![[defaults source] objectForKey: @"SOGoMailComposeMessageType"])
|
|
|
|
[[defaults source] setObject: [defaults mailComposeMessageType] forKey: @"SOGoMailComposeMessageType"];
|
2015-08-06 22:07:46 +02:00
|
|
|
|
2016-02-11 22:45:58 +01:00
|
|
|
if (![[defaults source] objectForKey: @"SOGoMailComposeFontSize"])
|
|
|
|
[[defaults source] setObject: [defaults mailComposeFontSize] forKey: @"SOGoMailComposeFontSize"];
|
|
|
|
|
2015-04-10 15:44:30 +02:00
|
|
|
if (![[defaults source] objectForKey: @"SOGoMailDisplayRemoteInlineImages"])
|
|
|
|
[[defaults source] setObject: [defaults mailDisplayRemoteInlineImages] forKey: @"SOGoMailDisplayRemoteInlineImages"];
|
2015-08-06 22:07:46 +02:00
|
|
|
|
2015-03-24 15:44:50 +01:00
|
|
|
// Populate default mail lablels, based on the user's preferred language
|
|
|
|
if (![[defaults source] objectForKey: @"SOGoMailLabelsColors"])
|
|
|
|
{
|
2015-04-03 23:37:46 +02:00
|
|
|
SOGoMailLabel *label;
|
|
|
|
NSArray *labels;
|
|
|
|
id v;
|
2015-08-06 22:07:46 +02:00
|
|
|
|
2015-04-03 23:37:46 +02:00
|
|
|
int i;
|
2015-08-06 22:07:46 +02:00
|
|
|
|
2015-04-03 23:37:46 +02:00
|
|
|
v = [defaults mailLabelsColors];
|
2015-08-06 22:07:46 +02:00
|
|
|
|
2015-04-03 23:37:46 +02:00
|
|
|
labels = [SOGoMailLabel labelsFromDefaults: v component: self];
|
|
|
|
v = [NSMutableDictionary dictionary];
|
|
|
|
for (i = 0; i < [labels count]; i++)
|
|
|
|
{
|
|
|
|
label = [labels objectAtIndex: i];
|
|
|
|
[v setObject: [NSArray arrayWithObjects: [label label], [label color], nil]
|
|
|
|
forKey: [label name]];
|
|
|
|
}
|
2015-08-06 22:07:46 +02:00
|
|
|
|
2015-04-03 23:37:46 +02:00
|
|
|
[defaults setMailLabelsColors: v];
|
2015-03-24 15:44:50 +01:00
|
|
|
}
|
|
|
|
|
2015-04-10 15:44:30 +02:00
|
|
|
if ([[defaults source] dirty])
|
2015-03-26 18:37:44 +01:00
|
|
|
[defaults synchronize];
|
|
|
|
|
|
|
|
values = [[[[defaults source] values] mutableCopy] autorelease];
|
2015-04-10 15:44:30 +02:00
|
|
|
|
2016-06-14 16:31:45 +02:00
|
|
|
//
|
|
|
|
// Expose additional information that must not be synchronized in the defaults
|
|
|
|
//
|
|
|
|
|
|
|
|
// Expose the SOGoAppointmentSendEMailNotifications configuration parameter from the domain defaults
|
|
|
|
[values setObject: [NSNumber numberWithBool: [domainDefaults appointmentSendEMailNotifications]]
|
|
|
|
forKey: @"SOGoAppointmentSendEMailNotifications"];
|
|
|
|
|
2015-08-06 22:07:46 +02:00
|
|
|
// Add locale code (used by CK Editor)
|
|
|
|
locale = [[preferencesProduct resourceManager] localeForLanguageNamed: [defaults language]];
|
|
|
|
[values setObject: [locale objectForKey: @"NSLocaleCode"] forKey: @"LocaleCode"];
|
2016-01-11 22:32:12 +01:00
|
|
|
[values setObject: [NSDictionary dictionaryWithObjectsAndKeys:
|
|
|
|
[locale objectForKey: @"NSMonthNameArray"], @"months",
|
|
|
|
[locale objectForKey: @"NSShortMonthNameArray"], @"shortMonths",
|
|
|
|
[locale objectForKey: @"NSWeekDayNameArray"], @"days",
|
|
|
|
[locale objectForKey: @"NSShortWeekDayNameArray"], @"shortDays",
|
|
|
|
nil] forKey: @"locale"];
|
2015-08-06 22:07:46 +02:00
|
|
|
|
2016-06-14 16:31:45 +02:00
|
|
|
// We inject our default mail account
|
2015-04-10 15:44:30 +02:00
|
|
|
accounts = [NSMutableArray arrayWithArray: [values objectForKey: @"AuxiliaryMailAccounts"]];
|
2015-04-30 17:19:30 +02:00
|
|
|
account = [[[context activeUser] mailAccounts] objectAtIndex: 0];
|
|
|
|
if (![account objectForKey: @"receipts"])
|
|
|
|
{
|
|
|
|
[account setObject: [NSDictionary dictionaryWithObjectsAndKeys: @"ignore", @"receiptAction",
|
|
|
|
@"ignore", @"receiptNonRecipientAction",
|
|
|
|
@"ignore", @"receiptOutsideDomainAction",
|
|
|
|
@"ignore", @"receiptAnyAction", nil]
|
|
|
|
forKey: @"receipts"];
|
|
|
|
}
|
|
|
|
[accounts insertObject: account atIndex: 0];
|
2015-04-10 15:44:30 +02:00
|
|
|
[values setObject: accounts forKey: @"AuxiliaryMailAccounts"];
|
2015-04-30 17:19:30 +02:00
|
|
|
|
|
|
|
|
2016-01-11 22:32:12 +01:00
|
|
|
return [self responseWithStatus: 200 andJSONRepresentation: values];
|
2007-06-19 19:58:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (WOResponse *) jsonSettingsAction
|
|
|
|
{
|
2009-11-29 05:19:32 +01:00
|
|
|
SOGoUserSettings *settings;
|
2015-04-08 20:19:31 +02:00
|
|
|
id v;
|
2007-06-19 19:58:21 +02:00
|
|
|
|
|
|
|
settings = [[context activeUser] userSettings];
|
|
|
|
|
2015-04-08 20:19:31 +02:00
|
|
|
// We sanitize PreventInvitationsWhitelist if we need to, this is due to the fact
|
|
|
|
// that SOGo <= 2.2.17 used to store it as a JSON *string* within the JSON-blob -
|
|
|
|
// sorry about this engineering brain fart!
|
|
|
|
v = [[settings objectForKey: @"Calendar"] objectForKey: @"PreventInvitationsWhitelist"];
|
|
|
|
|
|
|
|
if (v && [v isKindOfClass: [NSString class]])
|
|
|
|
{
|
|
|
|
[[settings objectForKey: @"Calendar"] setObject: [v objectFromJSONString]
|
|
|
|
forKey: @"PreventInvitationsWhitelist"];
|
|
|
|
}
|
|
|
|
|
2015-08-17 15:55:14 +02:00
|
|
|
// Initialize some default values
|
|
|
|
if (![settings objectForKey: @"Calendar"])
|
|
|
|
[settings setObject: [NSMutableDictionary dictionary] forKey: @"Calendar"];
|
|
|
|
|
|
|
|
if (![settings objectForKey: @"Contact"])
|
|
|
|
[settings setObject: [NSMutableDictionary dictionary] forKey: @"Contact"];
|
|
|
|
|
|
|
|
if (![settings objectForKey: @"Mail"])
|
|
|
|
[settings setObject: [NSMutableDictionary dictionary] forKey: @"Mail"];
|
|
|
|
|
2016-01-11 22:32:12 +01:00
|
|
|
return [self responseWithStatus: 200 andJSONRepresentation: [[settings source] values]];
|
2007-06-19 19:58:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@end
|